Shell tool: no upper bound on the timeout a model can ask for, so one call can hold a turn for hours
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- tooling
调研方向
阅读 packages/opencode/src/tool/shell.ts 了解 v1 的超时处理,阅读 packages/core/src/tool/bash.ts 了解 MAX_TIMEOUT_MS;对比 v2 路径 packages/core/src/tool/plugin/shell.ts。使用 sleep 3000 和 timeout: 14400000 这类慢命令复现问题,然后把前台超时限制在现有最大值或配置值。完成标准是:过长的超时请求不再超过上限阻塞,同时命令仍会在该边界处转入后台运行。
由索引模型根据 Issue 内容生成。
描述
Description
The shell tool takes whatever timeout the model sends. There's no upper bound, so one call can hold the turn for hours.
We run opencode headless for coding agent evals, with a 60 minute limit per run. In four runs the model (Kimi K3 and K3.1 Pro) started a full Gradle test suite with timeout set to 3600000, 7200000 and 14400000 ms. That suite takes about an hour in our environment, so the call never came back and the run got cut at the limit with no answer. Before that call each run had made 44 to 110 tool calls and all of them completed.
The timeout message also tells the model to "retry with a larger timeout value", so it pushes models toward big numbers. In one run the model went from 120 s to 30 minutes on the retry.
In 1.19.6, packages/opencode/src/tool/shell.ts only rejects a negative value and then uses params.timeout ?? defaultTimeoutMs. packages/core/src/tool/bash.ts has MAX_TIMEOUT_MS = 10 * 60 * 1_000 and checks it in its schema, but the shell tool doesn't use it.
From reading dev (fe8def685) a foreground call looks the same: packages/core/src/tool/plugin/shell.ts takes a NonNegativeInt and uses input.timeout || DEFAULT_TIMEOUT_MS. A command that's still running at its timeout moves to the background now, which is the behavior we want, but a model that asks for 4 hours still blocks for 4 hours first.
What I'd like is a maximum for the foreground timeout: 10 minutes like MAX_TIMEOUT_MS, or a setting for it. Past the maximum, move the command to the background on v2 or stop it on v1. For v1, just applying the existing MAX_TIMEOUT_MS in the shell tool would fix it for us.
Related: #63748 asks for a configurable default. This one is about the upper bound.
Plugins
A small internal hooks plugin. It doesn't change the timeout.
OpenCode version
1.19.5 (where we saw it). 1.19.6 and dev fe8def685 from reading the source.
Steps to reproduce
- Have the model call the shell tool with a slow command and a long timeout, for example
sleep 3000withtimeout: 14400000. - The call blocks until the command ends. Nothing gives the turn back to the model before that.
Screenshot
No response
Operating System
Linux (container)
Terminal
none, headless
- 主要语言
- TypeScript
- 星标
- 227k
- 派生
- 30.7k
- 平均合并
- 3 小时 57 分钟
- 30 天内合并 PR
- 484
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
[Site] Active section detection should respect scroll-margin-top可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area/web reproduced type/bug
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#65384 · 1 条评论 ·
维护者通常 1 天内回复
-
area/cli type/feature version/v2
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#65379 · 1 条评论 ·
维护者通常 1 天内回复
-
inference/go type/feature
难度 1/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#65148 · 1 条评论 ·
维护者通常 1 天内回复
-
area/providers type/feature version/v2
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#64845 · 1 条评论 ·
维护者通常 1 天内回复
-
area/providers platform/macos status/repro-simulated type/bug version/v2
难度 2/5 1-3 小时 新手友好度 78/100
anomalyco/opencode#64723 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
swc-project/swc-ai-issues#1001 ·
-
check:passed streams:add
难度 1/5 1 小时以内 新手友好度 62/100
维护者通常 1 天内回复
-
fix(table): CollapseColumn uses wrong caret icon for expandable row toggle可能已有人在做 @redhat-chai-bot 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
patternfly/patternfly-react#12727 ·
维护者通常 1 天内回复
-
CLI OAuth login fails behind an authenticating proxy: GET /api/v1/user omits Proxy-Authorization未关闭
难度 1/5 1 小时以内 新手友好度 85/100
lightdash/lightdash#33086 · 1 条评论 ·
维护者通常 1 天内回复
-
assessment bug course exercise programming
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复