[Bug]: TerminalSession never sets timeout=True on TerminalObservation when commands time out

Aperta
#6,991 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@zsicheng0214 ci sta già lavorando.

Dal 19/11/2026.

  • #6987 di @zsicheng0214 — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Read openhands-tools/openhands/tools/terminal/terminal/terminal_session.py and openhands-tools/openhands/tools/terminal/definition.py to trace how the two timeout handlers construct observations. PR #6987 is already open and implements this fix. The issue names tests/tools/terminal/test_terminal_timeout_flag.py and the terminal test suite as verification; done means both handlers report timeout=True while preserving the stated text and other behavior.

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

Descrizione

priority:low ready-for-dev
Is there an existing issue for the same bug?
  • I have searched existing issues and this is not a duplicate.
Bug Description

TerminalObservation (openhands/tools/terminal/definition.py) defines timeout: bool = Field(default=False, description="Whether the command execution timed out."), but neither TerminalSession._handle_hard_timeout_command() nor TerminalSession._handle_nochange_timeout_command() passes timeout=True when constructing TerminalObservation.from_text(...).

Expected Behavior

obs.timeout should be True whenever _handle_hard_timeout_command or _handle_nochange_timeout_command produces a timeout TerminalObservation.

Actual Behavior

Reproducible with uv run python -c: calling session._handle_hard_timeout_command(command="sleep 10", terminal_content="", ps1_matches=[], timeout=2.0) returns an observation whose prose suffix says [The command timed out after 2.0 seconds. ...] while obs.timeout is False. Downstream hooks and post-tool observers inspecting structured ObservationEvent fields never observe timeout=True.

Discovered via TraceTrial-Bench (arXiv:2610.32285, mechanism nodes E3 & E6). Companion fix ready in #6987.

Acceptance Criteria
  • _handle_hard_timeout_command sets timeout=True on TerminalObservation
  • _handle_nochange_timeout_command sets timeout=True on TerminalObservation
  • Unit tests pass via uv run pytest tests/tools/terminal/test_terminal_timeout_flag.py

OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Confirmed on main (1.62.0): TerminalObservation.timeout (openhands-tools/openhands/tools/terminal/definition.py) defaults to False, and TerminalSession._handle_hard_timeout_command() and _handle_nochange_timeout_command() in openhands-tools/openhands/tools/terminal/terminal/terminal_session.py construct TerminalObservation.from_text(...) without passing timeout=True, so serialized ObservationEvents never report a timeout. The two timeout handlers are the authoritative construction sites for these prose-suffixed timeout observations, and PR #6987 already implements exactly this fix with a test file.

Bounded scope: pass timeout=True in only those two handlers in openhands-tools/; add unit coverage under tests/tools/terminal/. Non-goals: changing observation text, is_error, exit codes, or the soft-timeout still-running path; altering the LLM-visible string; touching other TerminalObservation construction sites, timeout policy defaults, event schemas, TypeScript clients, or docs.

Actual Behavior

_handle_hard_timeout_command and _handle_nochange_timeout_command return TerminalObservations whose prose suffix says the command timed out, while obs.timeout remains the default False; structured ObservationEvent fields downstream therefore never show timeout=True.

Steps to Reproduce

With a mocked backend terminal, call session._handle_hard_timeout_command(command="sleep 10", terminal_content="", ps1_matches=[], timeout=2.0) and inspect the returned observation: its text says the command timed out, but obs.timeout is False.

Desired Behavior

Every TerminalObservation produced by _handle_hard_timeout_command or _handle_nochange_timeout_command carries timeout=True and is visible as timeout: true in the serialized ObservationEvent, so hooks and post-tool observers can detect timed-out commands from structured fields.

Acceptance Criteria
  • TerminalSession._handle_hard_timeout_command returns a TerminalObservation with timeout is True (e.g. calling it with command="sleep 10", terminal_content="", ps1_matches=[], timeout=2.0).
  • TerminalSession._handle_nochange_timeout_command returns a TerminalObservation with timeout is True (e.g. calling it with command="sleep 10", terminal_content="waiting...", ps1_matches=[]).
  • Both timeout handlers' observation text, exit code, and is_error behavior are unchanged: for the mocked-backend calls above, the text still contains "The command timed out after 2.0 seconds." / "has no new output", exit_code == -1, and is_error is False.
  • An observation produced by TerminalSession.execute outside the two timeout handlers has timeout is False: e.g. TerminalExecutor(...).execute(TerminalAction(command="echo ready", timeout=2)) returns an observation with timeout is False.
  • uv run pytest tests/tools/terminal/test_terminal_timeout_flag.py passes, and the existing uv run pytest tests/tools/terminal/ suite is green.
Lingua principale
Python
Stelle
1.4k
Fork
797
Merge medio
1g 17h
PR unite (30g)
354

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 OpenHands/software-agent-sdk

Tutte le issue di OpenHands/software-agent-sdk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.