Split last-request/cache usage, emit terminal usage, and retry stream errors by default (N3 WP6) #35

Merged
weichen merged 1 commits from feature/n3-usage-retry-wp6 into main 2026-10-07 16:32:53 +00:00
Owner

Why: cache tokens were parsed but never accumulated, the usage event carried only cumulative totals and was skipped on terminal paths (audit N20 residual), and stream retry was host-opt-in so subagents, the verifier, and squad runs were never retried.

What: cache read/write tokens accumulate; usage event carries Last* + cache and is emitted on budgetStop and turn-failed paths too; Config.RetryAttempts defaults to 2 (negative disables) with auto_retry_start/end events on the loop event surface.

Evidence: GOWORK=off go vet + go test -count=1 ./... green; the only-before-first-delta invariant holds under the library default.

Impact: default retry becomes a library default (host wrappers should be retired to avoid double retries).

Refs: Agent-System-Documents#43 (N3 plan WP6), audit N20

Why: cache tokens were parsed but never accumulated, the usage event carried only cumulative totals and was skipped on terminal paths (audit N20 residual), and stream retry was host-opt-in so subagents, the verifier, and squad runs were never retried. What: cache read/write tokens accumulate; usage event carries Last* + cache and is emitted on budgetStop and turn-failed paths too; Config.RetryAttempts defaults to 2 (negative disables) with auto_retry_start/end events on the loop event surface. Evidence: GOWORK=off go vet + go test -count=1 ./... green; the only-before-first-delta invariant holds under the library default. Impact: default retry becomes a library default (host wrappers should be retired to avoid double retries). Refs: Agent-System-Documents#43 (N3 plan WP6), audit N20
weichen added 1 commit 2026-10-07 16:31:36 +00:00
Split last-request/cache usage, emit terminal usage, and retry stream errors by default (N3 WP6)
ci / vet-and-test (pull_request) Successful in 49s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
87ff3946df
Why: cache tokens were parsed but never accumulated, the usage event
carried only cumulative totals and was skipped on terminal paths
(audit N20 residual), and stream retry was host-opt-in so subagents,
the verifier, and squad runs were never retried.
Evidence: GOWORK=off go vet + go test -count=1 ./... green;
TestUsageEventSplitsLastAndCache (event carries Last*/cache),
TestUsageAccumulatesCacheTokens, TestBudgetStopEmitsTerminalUsage,
TestDefaultRetryAttemptsTwo (0 value = 2 retries with
auto_retry_start events), TestNegativeRetryAttemptsDisables (negative
= off), TestRetryNeverDuplicatesForwardedDeltas (the only-before-first-delta
invariant holds under the library default).
Impact: usage events now carry Last* and cache fields and are emitted
on budget/error terminal paths too; Config.RetryAttempts defaults to
2 (negative disables) so every host gets the existing retry semantics
without wrapping; default (unset) host wrappers should be retired to
avoid double retries.
Refs: Agent-System-Documents#43 (N3 plan WP6), audit N20
weichen merged commit 16fdad92c4 into main 2026-10-07 16:32:53 +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#35