Repository navigation
fix(agents): exempt tool-execution timeouts from model fallback (#52147) - #75873
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Configure a short Next step before merge Security Review detailsBest possible solution: Merge the focused active-tool timeout exemption after maintainer review and CI/changed-gate proof, keeping LLM-phase timeouts on the existing fallback path. Do we have a high-confidence way to reproduce the issue? Yes. Configure a short Is this the best way to solve the issue? Yes. The proposed active-tool flag mirrors the established compaction exemption, uses existing tool lifecycle state, keeps the new public attempt-result field optional, and avoids broader timeout-policy refactoring. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 6a54aac4892c. |
c22de36 to
d1e3326
Compare
a1b57e9 to
424cf69
Compare
424cf69 to
5235de7
Compare
Detect run-level timeouts that fire while a tool call is still active and keep them out of assistant model fallback. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Thread tool-timeout state through timeout-triggered compaction, generic timeout payload synthesis, and the changelog. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Keep the new attempt-result field optional for third-party harness compatibility while defaulting absent values at the runner boundary. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5235de7 to
cf156be
Compare
obviyus
left a comment
There was a problem hiding this comment.
Verified the runner/failover bug path: run-level timeouts during active tool execution now avoid model fallback while LLM-phase timeouts keep the existing rotation path.
Maintainer follow-up: rebased onto current main, cleaned the commit messages, trimmed redundant comments, and kept the changelog entry in the active Unreleased fixes block.
Local gate: skipped tests per maintainer request; ran conflict-marker and diff sanity checks during the rebase.
Summary
Closes #52147.
When the embedded run-level timer fires while tool execution is in flight (e.g.
process(poll)loops, browser automation, longexec), the LLM has already responded. Today's failover policy still treats this astimedOut && !timedOutDuringCompaction→ rotates auth profiles, then escalates to model fallback withFailoverError: LLM request timed out.That's wrong on three axes:
LLM request timed outerror message is misleading (no LLM request was in flight)This PR mirrors the existing
timedOutDuringCompactionprecedent (PR #46889): a new flag is set whenabortRun(isTimeout=true)fires while at least one tool is still active, and the failover policy adds a parallel exemption. No behavior change for LLM-phase timeouts.The bot's 2026-04-28 review on #52147 verified the gap on current
mainand endorsed this exact approach as the cleanest fix.Detection
Uses the existing
toolStartDatamap inpi-embedded-subscribe.handlers.tools.ts— entries are inserted at tool start (handleToolExecutionStartline 610) and deleted at tool end (handleToolExecutionEndline 828). NewcountActiveToolExecutions(runId)helper filters byrunId:key prefix since the map is shared across runs.The flag is only set in
abortRunwhenisTimeout && !timedOutDuringCompaction && activeCount > 0. Compaction takes precedence (existing behavior).Plumbing
Mirrors the existing
timedOutDuringCompactionflow exactly:EmbeddedRunAttemptResult.timedOutDuringToolExecution: booleanfailover-policy.tsshouldRotateAssistantadds the exemptionassistant-failover.ts+run.tsthread the paramTest plan
continue_normalregardless of profile-rotation statepnpm vitest run src/agents/pi-embedded-runner/run/failover-policy.test.ts src/agents/pi-embedded-runner/run/assistant-failover.test.tspnpm vitest run src/agents/pi-embedded-runner/run/compaction-timeout.test.ts src/agents/pi-embedded-runner/run/llm-idle-timeout.test.tspnpm vitest run src/agents/pi-embedded-runner/run.timeout-triggered-compaction.test.ts src/agents/pi-embedded-runner/run.overflow-compaction.loop.test.tspnpm vitest run src/agents/harness/v2.test.ts src/agents/harness/selection.test.ts src/trajectory/metadata.test.tsScope boundary
Doesn't change behavior for:
timedOutDuringCompaction(untouched)abortRun(true)and is correctly classified as LLM-phase since no tool is in flight by definition during idle wait)Note
AI-assisted (Claude Opus 4.7).
🤖 Generated with Claude Code