Skip to content

fix(ai): investigations finish inside their clock and close out inside the context limit - #2719

Merged
Makisuo merged 3 commits into
mainfrom
triage/chat-agent-budgets
Nov 16, 2026
Merged

Makisuo merged 3 commits into
mainfrom
triage/chat-agent-budgets

fix(ai): a failed first answer past the cap waits for the retry

a7978bb
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Nov 16, 2026 in 2m 34s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge. No test covers a first attempt that fails with a typed error past the cap; every other path the change adds is pinned.
1 note · tests covered · risk medium

Past its attempt cap the first model call is no longer cut: the low-effort retry races it and the first answer wins, while investigation passes move to 15 minutes and the close-out runs on its own 5-minute clock with 120k characters of evidence. Safe to merge; the one earlier note on PhaseTurn.agent still stands.

  • retriedPastCap keeps the first attempt streaming and races the retry beside it
  • A first attempt answering with finish.reason: error past the cap waits for the retry
  • INVESTIGATION_BUDGET moves to 15 minutes; CLOSE_OUT_MAX_DURATION caps the close-out at 5
  • CLOSE_OUT_EVIDENCE_CHARS drops to 120k, leaving the round after submission room

Still open from earlier reviews

What was checked
  • budgets.test.ts now bounds pass plus closeOutAgent clock plus margin under TURN_STALE_MS, which ChatSession.ts:357 only trips past
  • Both forked attempts are interrupted by Effect.ensuring finalizers, so no fiber outlives the call
  • The race and the close-out clock are asserted as behavior (model-call-span.test.ts:840, autonomous-phases.test.ts:61)

a7978bb · Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.