Skip to content

Surface disjoint inference / platform credits in conversation usage#11441

Draft
jefflloyd wants to merge 1 commit into
masterfrom
jlloyd/split-inference-and-platform-credits
Draft

Surface disjoint inference / platform credits in conversation usage#11441
jefflloyd wants to merge 1 commit into
masterfrom
jlloyd/split-inference-and-platform-credits

Conversation

@jefflloyd
Copy link
Copy Markdown
Contributor

Description

Surfaces the disjoint inference vs. platform credit split on the warp client. Companion to:

Concretely:

  • crates/warp_graphql_schema/api/schema.graphql: add the new platformCreditsSpent: Float! field to ConversationUsageMetadata so the cynic-generated GraphQL types include it.
  • crates/graphql/src/api/queries/get_conversation_usage.rs, crates/graphql/src/api/ai.rs: request the new field in the conversation-usage query / AIConversation selection and surface it to the rest of the client.
  • crates/persistence/src/model.rs: persist platform_credits_spent: f32 alongside credits_spent, with #[serde(default)] so older serialized payloads still deserialize.
  • app/src/ai/agent/conversation.rs: update credits_spent() to sum inference + platform (and round), and copy the new proto field into the persisted metadata on every request finish.
  • app/src/server/server_api/ai.rs: extend the convert_usage_metadata helper to accept platform_credits_spent and pass it through from both GraphQL conversion sites.
  • app/src/ai/blocklist/controller/shared_session.rs, app/src/terminal/shared_session/replay_agent_conversations.rs: emit the proto's platform_credits_spent as 0.0 when constructing outbound stream_finished::ConversationUsageMetadata, since AIConversation::credits_spent() already returns the bundled total and a non-zero disjoint value would double-count on viewers. Both call sites have an inline comment explaining the contract.
  • Add platform_credits_spent: 0.0 to every explicit ConversationUsageMetadata literal in test helpers / fixtures that don't go through Default.

Production safety

Prod is currently in platform_credits_mode: report, so the server returns decimal.Zero for platform credits today. This change is purely additive on the client; existing clients that don't read the new field continue to behave as before.

Dev / testing

The dev-only [patch."https://github.com/warpdotdev/warp-proto-apis.git"] block in Cargo.toml is intentionally not committed here so the PR diff stays clean. To run this branch locally before the proto PR lands, uncomment the directive at the bottom of Cargo.toml:

[patch."https://github.com/warpdotdev/warp-proto-apis.git"]
# Uncomment for local development of warp-proto-apis
warp_multi_agent_api = { path = "../warp-proto-apis/apis/multi_agent/v1/gen/rust" }

Once warpdotdev/warp-proto-apis#312 is merged, the directive can be re-removed and Cargo.toml line 308 bumped to the merged rev.

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.

No external Linear ticket; this is a follow-on to a credit-counting bug investigation. See the related conversation in the related section below.

Testing

  • cd /Users/jlloyd/Developer/warp && cargo check --workspace --tests
  • cd /Users/jlloyd/Developer/warp && cargo fmt --check
  • cd /Users/jlloyd/Developer/warp && cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
  • I have manually tested my changes locally with ./script/run

Manual e2e testing is gated on the server-side PR landing (the new field comes in over the wire from warp-server). I'll do an e2e pass once the upstream PRs are in.

Screenshots / Videos

N/A — no user-visible UI changes in this PR. The new field is plumbed but not yet surfaced in any UI component.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Related

Co-Authored-By: Oz oz-agent@warp.dev

The server side of this change splits `creditsSpent` (now pure
inference) from a new `platformCreditsSpent` field (compute / sandbox)
on `ConversationUsageMetadata` so the bundled total stops
double-counting platform credits on consumers that sum the two
buckets. Mirror the same split on the warp client:

- `crates/warp_graphql_schema/api/schema.graphql`: add the new
  `platformCreditsSpent: Float!` field to `ConversationUsageMetadata`
  so the cynic-generated GraphQL types include it.
- `crates/graphql/src/api/queries/get_conversation_usage.rs`,
  `crates/graphql/src/api/ai.rs`: request the new field in the
  conversation-usage query / `AIConversation` selection and surface it
  to the rest of the client.
- `crates/persistence/src/model.rs`: persist
  `platform_credits_spent: f32` alongside `credits_spent`, with a
  `#[serde(default)]` so older serialized payloads still deserialize.
- `app/src/ai/agent/conversation.rs`: update `credits_spent()` to sum
  inference + platform (and round), and copy the new proto field into
  the persisted metadata on every request finish.
- `app/src/server/server_api/ai.rs`: extend the
  `convert_usage_metadata` helper to accept `platform_credits_spent`
  and pass it through from both GraphQL conversion sites.
- Add `platform_credits_spent: 0.0` to every explicit
  `ConversationUsageMetadata` literal in the test helpers / fixtures
  that don't go through `Default`.
- `app/src/ai/blocklist/controller/shared_session.rs`,
  `app/src/terminal/shared_session/replay_agent_conversations.rs`:
  emit the proto's `platform_credits_spent` as `0.0` when constructing
  outbound `stream_finished::ConversationUsageMetadata`, since
  `AIConversation::credits_spent()` already returns the bundled total
  and a non-zero disjoint value would double-count on viewers.

The new proto field lives in
warpdotdev/warp-proto-apis#312; once that lands, this
branch will need its `warp_multi_agent_api` rev bumped before going
out of draft. While in draft you can run this branch locally by
uncommenting the dev-only `[patch."https://github.com/warpdotdev/warp-proto-apis.git"]`
block at the bottom of `Cargo.toml`.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant