Repository navigation
feat: usage ledger wiring, 429 retry classification, no per-step transcript clone - #66
Merged
Merged
Conversation
…script clone Cost & reliability hygiene, three tight changes: - Usage ledger: OpenAiProvider captures the response's usage object and exposes it via the new Provider::last_usage (default None - mocks stay free). The turn loop writes one durable UsageRecord per provider step, anchored to the last committed entry (exactly the request's input scope), as a transition-free replay-safe Record::Usage line. tole status now shows real token totals instead of 0/0. - Retry classification: 429/http-rate-limit responses join timeouts as transient (live E2E hit 429 five times in one session today); audit entry renamed to 'provider transient failure, retrying'. - The per-step s.entries().to_vec() clone is gone: complete() borrows the storage slice directly. Live-verified: fresh run reports 1545 in / 4 out tokens via status.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Sep 12, 2026
…ecovery (#68) * chore(release): v0.3.0 — reliability & long-running work Version bump 0.2.0 -> 0.3.0 (minor: real features per house versioning), CHANGELOG entries for #57-#66, publish workflow extended to ship tole-cli (version-pinned core dependency, published after core), cli manifest pins tole-core 0.3.0. * fix(ci): run security checks on PRs targeting main too The main ruleset REQUIRES 'Cargo Audit' and 'Trivy FS Scan', but security.yml only produced them for PRs targeting develop - release PRs to main were permanently blocked (the documented impossible-required- check trap: admin cannot bypass required checks). Align the trigger set with ci.yml (develop, main). * fix: harden replay safety, guard resume, jail validation, torn-line recovery CodeCora full-scan findings triaged pre-tag (1 CRITICAL + 3 MAJOR real): - turn: derive ReplaySafety from tool risk (CRITICAL #33) - a crash after a Write/Destructive effect ran must not blindly re-execute on resume; Guarded now forces re-consultation of the approver. - turn: Guarded resume actually consults the approver and settles the intent either way (MAJOR #34) - Allow replays once; deny/absent settles the sandwich as failed instead of livelocking every future resume. - jails: component-based path validation everywhere (MAJOR #6, INFO #12) - Windows drive-prefixed/rooted relatives escape via join despite not being is_absolute(); substring '..' both misses them and rejects benign names. Uniform across WriteFileTool, core file_tools, read_file. - storage: torn-line accounting (MAJOR #47) - good_bytes counted before parse made a newline-terminated invalid final line look consumed; the truncation never fired and the next append bricked the session. Now counted only after a successful parse; empty lines still counted. Tests: guarded deny (settles, no livelock), guarded allow (fires exactly once), full workspace green; fmt/clippy clean; CodeCora diff review clean. --------- Co-authored-by: ajianaz <[email protected]>
4 tasks
ajianaz
added a commit
that referenced
this pull request
Sep 22, 2026
…119) (#124) - openai complete(): a non-2xx response is now surfaced as 'http status: N — <scrubbed body snippet>' instead of being mangled by read_json into a misleading 'malformed response'. The phrasing is load-bearing: the turn loop's transient-retry classification (#66) matches 'http status:' so 429/5xx keep auto-retrying. - git add lexical jail: reject Windows drive-letter absolute paths (C:\..., C:/...) that slipped past the '/'/'\\' checks (cora full-scan #30); colon at position 1 only, 'weird:name.txt' stays legal. Unit tests cover all four absolute shapes + relative pass. Co-authored-by: ajianaz <[email protected]>
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.
What (description of the change)
Three tight cost/reliability changes: (1)
Provider::last_usage(defaultNone) +OpenAiProvidercapturing the responseusageobject; the turn loop writes one durableUsageRecordper provider step, anchored to the last committed entry, via a transition-free replay-safe usage-only commit. (2) Retry classification extended: 429/rate-limit joins timeout as transient. (3) Removed the per-steps.entries().to_vec()clone —complete()borrows the storage slice.Why (the problem you're solving)
tole statushas always shown 0/0 tokens because provider usage was never captured although the whole ledger + display path existed. Live E2E today hit 429 five times in one session — the timeout-only retry classification missed the most common transient. The per-step full-transcript clone is a needless O(n) allocation per provider step on long sessions (Manus context-engineering post: prefill dominates agent cost — every needless allocation on the request path compounds).Testing (how you verified this works)
usage_rows_are_written_durably_per_step(2 steps → 2 rows, anchored to real entries, CLI-sum compatible),no_usage_rows_without_provider_usage(mock without usage → 0 rows),provider_429_rate_limit_retried_once; 3 existing retry tests updated to the new audit label. Full suite 155 green, both feature profiles, fmt + clippy -D warnings clean, CodeCora scan clean.usage: 1545 in / 4 out tokensintole status(was 0/0).