Skip to content

events: pair every model_call_started with a model_call_finished - #1691

Merged
justrach merged 1 commit into
mainfrom
fix/model-call-pairing
Oct 20, 2026
Merged

justrach merged 1 commit into
mainfrom
fix/model-call-pairing

Conversation

@justrach

Copy link
Copy Markdown
Owner

Fixes #1665.

Root cause

agent_request.request emitted model_call_started at the top of its rebuild loop. A request rebuilt before its response (a WebSocket reanchor, a stream reconnect, a steer, a recovered overflow) emitted another model_call_started without closing the attempt before it. A request that ended with an error closed nothing.

Fix

  • New model_call.Call tracks the open attempt.
  • A rebuilt request closes the attempt with ok: false, retried: true before the next one starts.
  • An error return closes it (errdefer) with ok: false, retried: false.
  • Successful attempts emit the same event as before.
  • The --schema events and the SDK event types document the optional retried field.

Not changed

Recovery is still reported as transport detail rather than a typed retry event, and there is no attempt-budget control. Both are separate from pairing.

Tests

  • New: two starts close the first as retried, a double finish emits once, and a failure closes with retried: false.
  • Model-call, schema and request unit tests: 199 pass.
  • Tier-1 pre-push gate is green.

A request rebuilt before its response (a WebSocket reanchor, a stream
reconnect, a steer, a recovered overflow) emitted another
model_call_started without closing the attempt before it, and a request
that ended with an error closed nothing. Strict JSON clients could not
pair attempts.

model_call.Call tracks the open attempt. A rebuilt request closes it
with ok=false and retried=true before the next one starts; an error
return closes it with ok=false and retried=false. Successful attempts
are unchanged. The schema and SDK event types document the optional
retried field.

Fixes #1665
@justrach
justrach merged commit ff700cf into main Oct 20, 2026
6 checks passed
@justrach
justrach deleted the fix/model-call-pairing branch October 20, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pair JSON model-call lifecycle events across WebSocket reanchors

1 participant