From b648f7dcd1a71bf26139f790cf27cd7004b425da Mon Sep 17 00:00:00 2001 From: ideallove <20013535+ideallove@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:56:50 +0800 Subject: [PATCH] fix(core): restore maxOutputTokens calculation that was accidentally disabled The maxOutputTokens was hardcoded to undefined in commit ac53a372b, which caused tool calls with large content to be truncated mid-JSON, resulting in "Unterminated string" parse errors. --- packages/opencode/src/session/llm.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/session/llm.ts b/packages/opencode/src/session/llm.ts index d651308032e7..033e4862ce43 100644 --- a/packages/opencode/src/session/llm.ts +++ b/packages/opencode/src/session/llm.ts @@ -150,7 +150,14 @@ export namespace LLM { }, ) - const maxOutputTokens = isCodex ? undefined : undefined + const maxOutputTokens = isCodex + ? undefined + : ProviderTransform.maxOutputTokens( + input.model.api.npm, + params.options, + input.model.limit.output, + OUTPUT_TOKEN_MAX, + ) log.info("max_output_tokens", { tokens: ProviderTransform.maxOutputTokens( input.model.api.npm,