Repository navigation
feat(provider): link each model call to its Ace charge - #958
Merged
Merged
Conversation
In multi-step tool streams the SDK can start the next step's fetch while finish-step awaits the snapshot, so the step could save the next call and hold. Capture the call first in both the processor and onStepFinish.
The call identity sat in a mutable slot on the shared request context, so in a multi-step stream the next step's fetch could overwrite it before the consumer handled the previous finish-step. The fetch wrapper now stamps the call id (and, on the managed route, the validated hold) onto the response it returns; the processor and onStepFinish read the step's own response headers. Non-managed responses never carry a hold. The trace key for the HTTP attempt becomes http_call_id so it no longer collides with the tool-call call_id on tool.* events.
Local usage listed storage under a record's id without checking it, so a legacy or corrupt session or message file with no id made Settings → Usage fail with a 500. Such records have nothing to list; skip them.
KB (KB-syntheticsciences)
requested review from
Aayam Bansal (aayambansal) and
Ishaan Gangwani (ishaan1124)
as code owners
October 6, 2026 17:56
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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 does this PR do, and why?
Links every model call the CLI makes to the Ace (Atlas) charge it caused, so developers can audit "what did this task cost?" per call. Roadmap step 1 (run audit) and #4 (receipts on calls).
requestID). Managed (Ace) requests sendx-openscience-call,-message,-attemptand-session; non-managed requests send none.x-openscience-hold-id(validated^(hold|orgh)_…) travel on each step's own response, so a step can never pick up the next step's call. Step-finish parts saveusage.call/usage.hold(optional fields; old sessions still parse) andmodel.responsetraces carryhttp_call_id/hold.settings-usagetests fail depending on test order).Companion Atlas PR (link table, hold-id header, reasoning tokens on the ledger, audit by session): https://github.com/synthetic-sciences/atlas/pull/380
Linked issue
No issue; roadmap work (call → charge link, phase 1). Design spec available on request.
How did you verify it?
test/provider/call-link.test.ts(headers only on managed, hold validation, spoofing, retries),test/session/call-link-step.test.ts(realstreamText, lagging consumer: each step keeps its own call and hold),usage-loggingandcall-link-parttests,settings-usagetest for records without an id.bun run typecheckgreen; SDK regenerated (no further diff). Full backend suite: every remaining failure also fails onmainor is timing-flaky there.Checklist
bun run checkis green — format and typecheck green; backend suite failures all pre-existing onmain(see above)./tooling/repo/generate.tswas run and thetooling/sdkoutput committed