Repository navigation
feat(core): Attribute the cost of every core model call - #2926
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
11 screenshot changes — 11 changed · 0 added · 0 removed Review screenshots in Frameshift |
dcramer
approved these changes
Nov 8, 2026
Member
|
rebase this |
Core code now calls completeText, completeObject, and completeDecision through chat/core-model. Each call names its operation and where its cost goes. Calls bound to a Conversation append one junior cost event per priced call, so titles, catch-ups, vision summaries, image prompt enrichment, and review reply matching show up in Conversation cost and the auxiliary breakdown. An ast-grep rule blocks direct imports from chat/pi/client. Co-Authored-By: David Cramer <[email protected]>
A real turn now stores a cost event for its title. Loaded history spends nothing, so the row comparison skips cost events.
sentry-junior
Bot
force-pushed
the
feat/attributed-model-calls
branch
from
November 8, 2026 18:42
dc055d9 to
93cc672
Compare
23 tasks done
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.
Several core model calls dropped their
costUsd: titles, catch-ups, vision summaries, image prompt enrichment, and review reply matching. Now no core call can skip cost attribution.Core code calls
completeText,completeObject, andcompleteDecisionfrom the newchat/core-model.ts. Each call must pass:operation: a closed union such asconversation_titleorvision_summary. It also setsgen_ai.prompt.nametojunior.<operation>, so span names stay the same.cost: where the cost goes.{ conversationId, turnId? }: the host appends onejunior/<operation>structured_eventwithcontent.costUsdfor each priced call. The write is best effort, like pluginonCost.{ owner: "caller" }: allowed only forbrief_update,guardian_action_review, andpassive_reply_route. Their own events (brief_updated,guardian_action_reviewed,passive_reply_routed) already store the cost, so nothing is counted twice.{ owner: "none" }: no stored Conversation. The cost stays on the span.A new ast-grep rule (
no-direct-core-model-calls) blocks imports of those three functions from@/chat/pi/clienteverywhere inpackages/junior/srcexceptcore-model.tsandplugins/model.ts.The auxiliary cost reader already counts any
structured_eventwithcontent.costUsd, soauxiliary-costs.tsneeds no change. The new operations get labels inTelemetryMetrics.tsx.Call sites
spawnAgentandcreateAutomation), catch-up (api/conversations/catch-up.ts), vision summaries (attachments and thread backfill), image prompt enrichment, and review item reply matching.junior briefs runCLI usesowner: "caller"because its report sums each version's cost. The catch-up eval harness usesowner: "none". A vision call made without a Conversation id, such as a local run, also usesnone.Not covered: image generation and web search bill through other gateway paths, not these three functions. Compaction is handled in #2925.
Checks
tests/integration/api/conversations/catch-up.test.ts: after a catch-up, the Conversation detail shows ajunior/conversation_catch_upauxiliary cost.pnpm ast-grep:lint. Rantscfor junior, junior-evals, and the dashboard, plus oxlint and prettier on the changed files.via @dcramer.
--
View Session [Sentry]