Guard streamed tool terminals and retain Usage #46

Merged
weichen merged 9 commits from feature/fast-slow-u3-r04-stream-guard into main 2026-10-19 09:20:09 +00:00
Owner

An incomplete streamed tool call can otherwise execute as a successful checkpoint. The runtime requires a complete stream and valid call identity/JSON; it rejects empty tool_calls and legacy function_call finishes, preserves returned Usage on terminal failure, and does not retry that failure. Streamed delta identity is carried to the single event owner.

Validation: both empty-terminal variants failed before the guard and passed afterward; GOWORK=off go vet ./... and GOWORK=off go test -count=1 ./... passed at a5e3c7c. Independent reviewer replayed both variants and retained Usage. Keep this PR draft until the U3 r0.4 model-quality and delivery gates pass.

Refs: U3 r0.4 design and implementation plan; Dev PR #512.

An incomplete streamed tool call can otherwise execute as a successful checkpoint. The runtime requires a complete stream and valid call identity/JSON; it rejects empty `tool_calls` and legacy `function_call` finishes, preserves returned Usage on terminal failure, and does not retry that failure. Streamed delta identity is carried to the single event owner. Validation: both empty-terminal variants failed before the guard and passed afterward; `GOWORK=off go vet ./...` and `GOWORK=off go test -count=1 ./...` passed at a5e3c7c. Independent reviewer replayed both variants and retained Usage. Keep this PR draft until the U3 r0.4 model-quality and delivery gates pass. Refs: U3 r0.4 design and implementation plan; Dev PR #512.
weichen added 1 commit 2026-10-14 02:10:49 +00:00
Reject incomplete streamed tool calls
ci / docker-checkout-hostgateway (pull_request) Successful in 0s
ci / vet-and-test (pull_request) Successful in 51s
94afd71f00
Why: a model tool finish could execute partial JSON or an unterminated SSE stream, while post-Usage errors could lose their charge.

Evidence: missing-DONE, malformed-JSON, identity, non-object and post-Usage RED→GREEN tests; GOWORK=off go vet ./... and go test -count=1 ./... passed.

Impact: invalid tool terminals fail without execution or automatic retry and retain returned Usage; valid text and multi-part tool streams keep working.

Refs: runtime/llm/sse.go; runtime/loop.go
weichen added 1 commit 2026-10-14 02:22:42 +00:00
Preserve streamed tool delta identity
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
ci / vet-and-test (pull_request) Successful in 52s
e86e74bc36
Why: Backend emitted tool deltas from a separate goroutine, racing with serialized run events and occasionally losing a UI delta.

Evidence: Backend race detector reproduced concurrent event writes; Agent-Native identity test RED→GREEN; full vet and tests pass.

Impact: runtime tool delta events now carry provider slot and call ID for single-owner downstream projection.

Refs: runtime/loop.go; runtime/event_vocabulary_test.go
weichen changed title from [WIP] Guard incomplete streamed tool calls to [WIP] Guard incomplete tool streams and preserve delta identity 2026-10-14 02:25:40 +00:00
weichen added 1 commit 2026-10-14 03:49:08 +00:00
Reject empty tool-call stream terminals
ci / docker-checkout-hostgateway (pull_request) Successful in 0s
ci / vet-and-test (pull_request) Successful in 53s
6e972335c9
Why: A provider can report finish_reason=tool_calls without emitting any tool call. Treating it as a successful empty answer hides an incomplete operation.

Evidence: New SSE regression failed before the guard and passed afterward; full go vet and go test -count=1 ./... passed.

Impact: Inconsistent tool terminals fail closed while preserving returned Usage; valid text and tool streams are unchanged.

Refs: U3 r0.4 independent review issue 2
weichen changed title from [WIP] Guard incomplete tool streams and preserve delta identity to [WIP] Guard streamed tool terminals and retain Usage 2026-10-14 04:00:56 +00:00
weichen added 1 commit 2026-10-14 04:12:06 +00:00
Reject legacy empty function-call terminals
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
ci / vet-and-test (pull_request) Successful in 55s
a5e3c7c817
Why: The parser also recognizes function_call as a tool finish, but cannot execute a legacy call when no deltas were collected. It must fail closed like tool_calls.

Evidence: The function_call variant failed before this guard and passed afterward; full Agent-Native vet/test passed.

Impact: Inconsistent legacy tool terminals fail with returned Usage preserved; valid streams are unchanged.

Refs: U3 r0.4 independent review Important 2 closure
weichen added 1 commit 2026-10-14 07:51:14 +00:00
Record content-free stream terminal observations
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
ci / vet-and-test (pull_request) Successful in 52s
6a1dcddb48
Why: The r0.4 trial could prove that the parser missed [DONE] but could not distinguish clean EOF, malformed frames, read failure, or provider error without retaining raw SSE.

Evidence: RED receipts fast-slow-u3-r05-task1-terminal-red.json and task1-http-error-red.json; GREEN targeted receipt and full vet/test/race receipt fast-slow-u3-r05-task1-agent-native-full.json.

Impact: Add bounded scalar diagnostics and successful HTTP status to terminal events while preserving the existing incomplete-tool rejection, returned Usage, and retry behavior.

Refs: U3 r0.5 approved design and plan; Agent-Native PR #46
weichen added 1 commit 2026-10-19 02:46:18 +00:00
Merge Agent-Native main into the U3 stream guard branch
ci / vet-and-test (pull_request) Successful in 52s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
governance / governance (pull_request) Successful in 16s
42b22b436b
weichen added 1 commit 2026-10-19 02:55:17 +00:00
agent-exec transport ed24e191762d6f6e3b41589f552e7744/cd1765c54231
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
governance / governance (pull_request) Successful in 14s
ci / vet-and-test (pull_request) Successful in 49s
5b21325da7
weichen added 1 commit 2026-10-19 03:02:48 +00:00
agent-exec transport 4838630332e6bb1220f0e63e947ddb81/599831d96200
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
governance / governance (pull_request) Successful in 18s
ci / vet-and-test (pull_request) Successful in 52s
b6a843337c
weichen added 1 commit 2026-10-19 03:51:08 +00:00
agent-exec transport d7776a79d43bd8fd44e6c0d78873761b/9585ecb5ab4b
governance / governance (pull_request) Successful in 17s
ci / docker-checkout-hostgateway (pull_request) Successful in 0s
ci / vet-and-test (pull_request) Successful in 54s
28f3ea7674
weichen marked the pull request as ready for review 2026-10-19 09:20:06 +00:00
weichen merged commit 9c24e220dd into main 2026-10-19 09:20:09 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-Native#46