Surface disjoint inference / platform credits in conversation usage#11441
Draft
jefflloyd wants to merge 1 commit into
Draft
Surface disjoint inference / platform credits in conversation usage#11441jefflloyd wants to merge 1 commit into
jefflloyd wants to merge 1 commit into
Conversation
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>
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.
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 newplatformCreditsSpent: Float!field toConversationUsageMetadataso 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 /AIConversationselection and surface it to the rest of the client.crates/persistence/src/model.rs: persistplatform_credits_spent: f32alongsidecredits_spent, with#[serde(default)]so older serialized payloads still deserialize.app/src/ai/agent/conversation.rs: updatecredits_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 theconvert_usage_metadatahelper to acceptplatform_credits_spentand 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'splatform_credits_spentas0.0when constructing outboundstream_finished::ConversationUsageMetadata, sinceAIConversation::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.platform_credits_spent: 0.0to every explicitConversationUsageMetadataliteral in test helpers / fixtures that don't go throughDefault.Production safety
Prod is currently in
platform_credits_mode: report, so the server returnsdecimal.Zerofor 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 inCargo.tomlis 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 ofCargo.toml:Once warpdotdev/warp-proto-apis#312 is merged, the directive can be re-removed and
Cargo.tomlline 308 bumped to the merged rev.Linked Issue
ready-to-specorready-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 --testscd /Users/jlloyd/Developer/warp && cargo fmt --checkcd /Users/jlloyd/Developer/warp && cargo clippy --workspace --all-targets --all-features --tests -- -D warnings./script/runManual 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
Related
Co-Authored-By: Oz oz-agent@warp.dev