You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix Pi RPC completion handling and multi-turn usage accounting #638
CR's Pi RPC adapter stops scanning at agent_end in internal/llmadapters/pi_rpc.go. Pi 1.0 documents agent_settled as the end of automatic work: retries and recovery can follow agent_end. Usage currently flows through overwrite-style mergeUsage, losing earlier completed turns.
Observed baseline and hypothesis
Environment: local Pi 1.0.0, isolated local mock provider; no paid model or Git-provider writes.
A mocked HTTP 503 produced agent_end with willRetry: true, then a successful retry and agent_settled. Replaying the captured stream through CR's scanner returned empty structured output rather than the successful JSON: 0/1 recovered answers.
A synthetic two-turn stream reported 100 + 200 input tokens; CR retained 200 rather than 300.
Existing Pi adapter tests, including installed-runtime extension preflight, pass. They do not cover these contracts.
Hypothesis: honoring session settlement and summing authoritative completed-message usage preserves successful recovery and accurate spend without changing review safety.
Acceptance
Add failing regression tests before production changes.
Consume through agent_settled, including retries/recovery; do not close stdin at a recoverable agent_end.
Preserve terminal provider error/abort diagnostics; reject truncated or unsettled streams rather than accepting stale/partial output.
Sum completed assistant-turn usage once, including cache/cost fields; do not add cumulative streaming updates or duplicate agent_end.messages snapshots.
Update helper fixtures and document the supported completion contract/version implications.
Run targeted adapter tests, full Go suite and lint.
Success and rollback
Target: 1/1 recovered successful answer, exactly 300 input tokens for the two-turn fixture, no double counting or safety regression. Validation is local/synthetic, not a deployed outcome. Roll back by reverting the adapter change if runtime smoke tests regress completion or cancellation.
Draft implementation: #641. Local/mock-provider verification recovered the successful answer after a 503 retry (baseline 0/1, now 1/1), preserved permanent-failure diagnostics, and reported 300 input tokens for the 100 + 200 fixture. Supported one-hour cache usage is also preserved and summed. Targeted race tests, repeated settlement tests, full-suite rerun, and lint with Go 1.26.3 passed. This is local/synthetic evidence, not a deployed outcome; GitHub CI and the dedicated pinned-runtime gate (#639) remain pending. RPC is retained; session persistence and Durable remain deferred.
Activity
zzwong commentedon Oct 2, 2026
Draft implementation: #641. Local/mock-provider verification recovered the successful answer after a 503 retry (baseline 0/1, now 1/1), preserved permanent-failure diagnostics, and reported 300 input tokens for the 100 + 200 fixture. Supported one-hour cache usage is also preserved and summed. Targeted race tests, repeated settlement tests, full-suite rerun, and lint with Go 1.26.3 passed. This is local/synthetic evidence, not a deployed outcome; GitHub CI and the dedicated pinned-runtime gate (#639) remain pending. RPC is retained; session persistence and Durable remain deferred.
fix(pi): honor settled runs and sum usage [#638]
test(pi): gate the installed Pi 1.0.0 RPC runtime [#639] (#646)