Fix strict cost accounting for verified Copilot context parser refusals - #114
Open
fanyangCS wants to merge 6 commits into
Open
Fix strict cost accounting for verified Copilot context parser refusals#114fanyangCS wants to merge 6 commits into
fanyangCS wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, fails closed without a matching trusted completion receipt, and is covered by focused regression tests for both new and historical records.
Pull request overview
This PR fixes strict cost-control deadlocks caused by a specific Copilot CLI top-level argument parser failure (unknown option '--context') by classifying only verified, pre-turn, silent failures as unbilled using a trusted agent.io.complete host receipt (including for historical ledger reads), while preserving all existing metering guards.
Changes:
- Add narrow recognition of the
--context defaultparser diagnostic and corroborate it viaagent.io.completereceipt checks to safely projectnot_billed/not_started/$0when no usage was observed. - Thread the host completion receipt through exec finalization and lazily load call-correlated receipts from
events.jsonlwhen re-reading historical usage records. - Add regression tests for new-call finalization, historical idempotence, and fail-closed behavior; regenerate release artifacts / web bundles tied to the source digest.
File summaries
| File | Description |
|---|---|
| tests/test_agent_cli_backend.py | Adds an integration-style adapter test verifying receipt-backed classification behavior with/without observed output. |
| tests/core/test_copilot_parser_refusal.py | New targeted regression suite for Issue #113, including historical projection/idempotence and fail-closed cases. |
| frontend/web/dist/index.html | Regenerated web entrypoint asset hash reference. |
| frontend/web/dist/assets/square-Vz4OpK6j.js | Regenerated bundle chunk to import the updated hashed index module. |
| frontend/web/dist/assets/MapPanel-B55b--j_.js | Regenerated bundle chunk updated to reference the refreshed hashed dependencies. |
| frontend/core/src/release.generated.ts | Regenerated release ID/source digest constants. |
| argus_skill/release_manifest.json | Regenerated release manifest with updated release ID/source digest. |
| argus_skill/core/usage.py | Implements receipt-assisted historical projection and new-call startup receipt plumbing for parser refusal classification. |
| argus_skill/core/runner_errors.py | Adds exact-match parser diagnostic detection + strict receipt corroboration helper. |
| argus_skill/adapters/agent_cli_backend/_exec_spawn.py | Logs agent.io.complete summary and passes it through as startup_receipt. |
| argus_skill/adapters/agent_cli_backend/_exec_finalize.py | Accepts/persists startup_receipt through usage record construction. |
Review details
- Files reviewed: 8/15 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
lbx154
added a commit
that referenced
this pull request
Sep 8, 2026
Keep grounding corrections on the same ACP client; align one-shot loader policy with readiness and remove redundant context defaults. Preserve post-start ACP failures and usage without replaying them. Reuse and harden the reviewed PR #114 implementation: correlate only exact parser refusals with silent host completion receipts, preserve observed metering in both ledger and receipt, and project historical non-billed startup failures without rewriting source records. Co-authored-by: fan yang <5820832+fanyangCS@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #113.
A top-level Copilot CLI parser failure (
error: unknown option '--context') could leave an error usage record with unknown cost. Under strict cost control, that unresolved record then blocked subsequent calls across projects even after the CLI mismatch was repaired. Existing pre-provider refusal handling did not recognize this diagnostic, and the missing session ID prevented normal exact-session usage reconciliation.Fix
--contextparser diagnostic, corroborated by a matching host-generatedagent.io.completereceipt: Copilotrun_exec, correlated call and run label, exit 1, failed/uncompleted turn, no session, no assistant/stdout/JSON/tool activity, and--context defaultin the command arguments.not_billed/not_started/ zero-cost projection. Missing or duplicate completion receipts fail closed; original ledger bytes are not rewritten and execution status remainserror.No broad
unknown optionsubstring rule, budget-policy relaxation, ledger deletion, or new reconciliation subsystem is introduced.The source digest change also requires regenerated release artifacts. A separate follow-up commit runs the supported
python -m argus_skill.release_tools.build_releasepipeline to refresh the JSON release manifest, generated TypeScript release identity, and shipped web/TUI bundles. No handwritten frontend behavior or dependency lockfiles are changed.Verification
main:ruff check argus_skill testsandgit diff --checkpassed.generate_manifest --check, andcheck_artifactspassed; the same 164 targeted tests passed again after the artifact refresh. This corrects the first CI run's stale-manifest failure.Limits / separate work
--context defaultparser failure, not every possible CLI startup error. It does not change the user-facingbudget_exhaustedwording.