Shell tool: no upper bound on the timeout a model can ask for, so one call can hold a turn for hours

Aperta Adatta ai principianti
#65,254 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
tooling

Direzione di ricerca

Leggi packages/opencode/src/tool/shell.ts per la gestione dei timeout della v1 e packages/core/src/tool/bash.ts per MAX_TIMEOUT_MS; confronta il percorso v2 in packages/core/src/tool/plugin/shell.ts. Riproduci con un comando lento come sleep 3000 e timeout: 14400000, quindi limita il timeout in primo piano al massimo esistente o a un valore configurato. È completato quando un timeout richiesto lungo non blocca più oltre il limite e il comando passa comunque in background al limite.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/core platform/linux type/feature version/v2
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
  1. Have the model call the shell tool with a slow command and a long timeout, for example sleep 3000 with timeout: 14400000.
  2. 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

Lingua principale
TypeScript
Stelle
227k
Fork
30.7k
Merge medio
3h 57m
PR unite (30g)
484

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.