You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1 #21522
The Description field contains only - and has no actual content explaining the bug or what behavior is observed
Steps to reproduce is empty (_No response_) — please describe what you were doing when the error occurred (e.g., which model/provider you are using, what action triggered it)
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
Thanks for updating the issue! It now has the information needed to investigate. We appreciate the screenshot and the context about this being a regression in 1.4.0.
Activity
github-actions commentedon Apr 8, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
-and has no actual content explaining the bug or what behavior is observed_No response_) — please describe what you were doing when the error occurred (e.g., which model/provider you are using, what action triggered it)Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
maxOutputTokens must be >= 1error when sending a message (closed)If you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Apr 8, 2026
Thanks for updating the issue! It now has the information needed to investigate. We appreciate the screenshot and the context about this being a regression in 1.4.0.
darsh12 commentedon Apr 8, 2026
Just a DP. After I removed oh-my-opencode, opencode started working
Hoshino-Yumetsuki commentedon Apr 8, 2026
thank for your suggestion, i will open a issue in omo`s repository
Jedeiah commentedon Apr 9, 2026
哥,找到问题了吗? 我今天也遇到了,同时在code-yeongyu/oh-my-openagent 仓库里没看到你提的issue。
Hoshino-Yumetsuki commentedon Apr 9, 2026
我是更新就行了,我已经把issue关了
Yiaichen commentedon Apr 10, 2026
我更新到最新版本一样有这个问题
Jedeiah commentedon Apr 11, 2026
@Yiaichen 回复你的评论:
根本原因是 oh-my-openagent 读取到某些模型的能力缓存 limit.output = 0,
没有做防御性校验,直接把 0 透传成 maxOutputTokens=0 发给 OpenCode,
OpenCode 1.4.0+ 要求 maxOutputTokens >= 1 所以报错。
以下是合理的临时方案(可丢给Ai让它去解决):
方案 A(限自定义模型,且要覆盖所有 agent 用到的模型才有效):
如果你用的是自定义 provider 里声明的模型,可以在 opencode.json 的对应模型
条目下加 limit.output,让 oh-my-openagent 读到正确值而不是缓存里的 0:
{ "provider": { "your-provider": { "models": { "your-model-id": { "limit": { "output": 4096, "context": 128000 } } } } } }注意:oh-my-openagent 会启动多个 agent,每个 agent 用不同模型。
必须给所有涉及的模型都加上 limit.output,漏一个就还会触发。
对 opencode 内置识别的标准模型(如 anthropic/claude-sonnet)无效。
方案 B(治本,推荐):
直接给 oh-my-openagent 的 dist/index.js 打补丁,
在写入和透传 maxOutputTokens 的三个关键路径上过滤掉 <= 0 的值。
文件路径(以 macOS 为例,Windows 路径类似):
~/.cache/opencode/packages/oh-my-openagent@latest/node_modules/oh-my-openagent/dist/index.js改动 1 - applySessionPromptParams 写入时(搜 model.maxTokens !== undefined):
改前:
...model.maxTokens !== undefined ? { maxOutputTokens: model.maxTokens } : {}改后:
...typeof model.maxTokens === "number" && model.maxTokens > 0 ? { maxOutputTokens: model.maxTokens } : {}改动 2 - 读取会话参数发请求时(搜 storedPromptParams.maxOutputTokens !== undefined):
改前:
改后:
改动 3 - compatibility 结果写回时(搜 compatibility.maxTokens !== undefined):
改前:
改后:
改完后删除模型能力缓存再重启:
rm ~/.cache/oh-my-opencode/model-capabilities.json # macOS/LinuxWindows: 删除
%USERPROFILE%\.cache\oh-my-opencode\model-capabilities.jsontakam-alex-christian commentedon Apr 22, 2026
This issues was caused by the oh-my-opencode plugin. Adding the following to each model in ~!/.config/opencode.jsonc resolved the issue for me.
"limit": { "output": 4096, "context": 128000 }