Skip to content

Add long-context usage warning indicator#13254

Open
dagmfactory wants to merge 2 commits into
masterfrom
dagm/long-context-v2
Open

Add long-context usage warning indicator#13254
dagmfactory wants to merge 2 commits into
masterfrom
dagm/long-context-v2

Conversation

@dagmfactory

@dagmfactory dagmfactory commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Adds a long-context usage warning indicator to the agent input footer, with the client deciding visibility from server-provided threshold and input data.

  • What: Thread the server's total_input_tokens (latest primary-agent call input tokens of the latest persisted charged/BYOK request) through the proto stream, GraphQL restore, and local persistence, and expose each model's longContextThreshold on LlmContextWindow.
  • The footer warning shows when provider == OpenAI && total_input_tokens > threshold for the active model.
  • Why: Signal to users when a conversation has entered OpenAI's long-context pricing tier, without the server computing a boolean — the client recomputes against the active model's threshold (e.g. on model switch).
  • How:
    • crates/persistence/src/model.rs, app/src/ai/agent/conversation.rs: persist/apply total_input_tokens (nonzero overwrites, zero keeps previous, matching server merge semantics).
    • crates/graphql/src/api/..., crates/warp_graphql_schema/api/schema.graphql: totalInputTokens on conversation usage; nullable longContextThreshold on LlmContextWindow; LLMContextWindow.long_context_threshold on the client model metadata.
    • app/src/ai/blocklist/usage/mod.rs: LongContextWarningState now holds tokens + active model provider/threshold and derives visibility; UI rendering (icon, tooltip, yellow warning theme) is unchanged.

Counterparts:

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • app/src/ai/blocklist/usage/mod_tests.rs: threshold boundary (at vs +1), no-threshold model (Auto), non-OpenAI providers hidden despite threshold, model-switch recompute (lower/higher/non-OpenAI), zero tokens, icon behavior.
  • crates/persistence/src/model_tests.rs: total_input_tokens JSON round-trip and legacy-row default.
  • cargo nextest targeted run (56 tests) passes; ./script/format run; cargo clippy --all-targets -- -D warnings clean on touched packages (warp, persistence, warp_graphql).

Screenshots / Videos

https://www.loom.com/share/e2ea70c8db7a4ce6ada8c766c5a425da

different themes:
https://www.loom.com/share/9d0d634e82314f39ba8e1eab0c69363e

Agent Mode

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

Plan: https://staging.warp.dev/drive/notebook/yJt0g7NfiwnSYuQdNfQAO1
Conversation: https://staging.warp.dev/conversation/4321295c-fe0b-4a19-9382-44738d7db792

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

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Jun 30, 2026
@dagmfactory dagmfactory marked this pull request as ready for review June 30, 2026 21:31
@oz-for-oss

oz-for-oss Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@dagmfactory

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR adds long-context pricing-warning state, wiring from conversation usage/model metadata, a themed context-window chip warning, and persistence/API fields for total input token counts.

Concerns

  • The warning visibility path does not consult the new LongContextWarning feature flag, so the new UI can appear outside the intended dogfood/flag rollout.
  • This is a user-facing UI change, but the PR description does not include screenshots or a screen recording demonstrating the warning end to end. Please attach visual evidence for this change before merge.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

{
let usage = conversation.context_window_usage();
let icon = icon_for_context_window_usage(usage);
let show_long_context_warning = self.long_context_warning_state.is_visible();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] This bypasses the new LongContextWarning feature flag, so any user with threshold metadata can see the UI outside the intended rollout. Gate the visibility on FeatureFlag::LongContextWarning.is_enabled().

Suggested change
let show_long_context_warning = self.long_context_warning_state.is_visible();
let show_long_context_warning = FeatureFlag::LongContextWarning.is_enabled()
&& self.long_context_warning_state.is_visible();

@dagmfactory dagmfactory requested a review from danielpeng2 June 30, 2026 22:30
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