Skip to content

add agent prompt history sqlite table#12208

Open
evelyn-with-warp wants to merge 2 commits into
masterfrom
evelyn/improve-history-match
Open

add agent prompt history sqlite table#12208
evelyn-with-warp wants to merge 2 commits into
masterfrom
evelyn/improve-history-match

Conversation

@evelyn-with-warp
Copy link
Copy Markdown
Contributor

@evelyn-with-warp evelyn-with-warp commented Jun 4, 2026

Description

Created agent_prompt table, to track submitted prompt, with write cap as 2k (for read/fuzzy match latency concern), and apply NLD history match on both agent_prompt & cmd history, whichever match comes later.

Did not reuse ai_queries table, as it didn't have a write cap for its purpose and subjective to session restoration setting.

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

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

https://www.loom.com/share/38649a38140d4ef18aac09216d87a575

We tested two queries, after deleting current sqlite DB tables and zsh history

  • hello: it failed by command not found, so it will not write to command history, so it always lands on the whitelist of AI mode
  • make a pr: it firstly lands on inputclassifier, and if we manually toggle it to be shell, it will run an invalid make command. It will be written to command history as it doesn't return command not found. The next time running it, it will be lock to shell by history match. If we manual toggle (or /agent) again, the next run will lock to AI by history match too.

Agent Mode

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

@cla-bot cla-bot Bot added the cla-signed label Jun 4, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Jun 4, 2026

@evelyn-with-warp

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

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Overview

This PR adds a SQLite-backed agent prompt history store, loads it into an in-memory prompt-history model, captures submitted agent prompts, and uses those prompts for NLD history matching behind the new nld_prompt_history_match feature. No approved spec context was available for implementation-vs-spec validation.

Concerns

  • The new prompt-history persistence path stores full agent prompt text even when session restoration is disabled, putting sensitive prompt contents outside the existing AI-history retention control.

Security

  • Agent prompts can contain secrets, source snippets, credentials, or other sensitive user text. Persisting them independently of the session-restoration setting creates a local retention path users may reasonably expect to be disabled.

Verdict

Found: 0 critical, 1 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

history.append(prompt.clone(), start_ts);
});
let prompt_sender = model_event_sender.clone();
let insert_agent_prompt_event = ModelEvent::InsertAgentPrompt { prompt, start_ts };
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] [SECURITY] This writes the full prompt to SQLite even when restore_session_enabled is false, so users who disabled session restoration still retain agent prompts locally. Gate InsertAgentPrompt on the same retention/privacy setting or add an explicit prompt-history opt-in before persisting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any process to resolve data compliance called out by Oz?
nld history may not suit for only storing agent prompt with restore_session , but we might gate it with if is nld on?

@evelyn-with-warp evelyn-with-warp requested a review from szgupta June 4, 2026 22:25
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