-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Saved prompts: transcript redaction + per-submission custom instructions #3403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Saved prompts: transcript redaction + per-submission custom instructions #3403
Conversation
I have read the CLA Document and I hereby sign the CLA |
333910a
to
8ff2baf
Compare
…-prompt flag and redact_saved_prompt_body config Signed-off-by: Roman Aleynikov <agenticbuddy@gmail.com>
…name …”, multiline), send structured Directive (CustomInstruction > SavedPrompt); update docs; add tests incl. redaction OFF, CLI override, and CDATA robustness Signed-off-by: Roman Aleynikov <agenticbuddy@gmail.com>
… ON shows “/name …”, redaction OFF shows “Custom instruction:” then “Saved prompt:”; agent still gets Directive (CustomInstruction > SavedPrompt) Signed-off-by: Roman Aleynikov <agenticbuddy@gmail.com>
…; keep rollout unredacted; avoid leaking prompt text in logs; show verbatim /prompt in transcript Signed-off-by: Roman Aleynikov <agenticbuddy@gmail.com>
…ne markers in session files; keep debug logs non-sensitive Signed-off-by: Roman Aleynikov <agenticbuddy@gmail.com>
8ff2baf
to
dc06dd4
Compare
The use of $ARGUMENTS actively replicates the process used in Claude code. Using this method ensures that people switching do not need to modify current prompts. |
Thanks, I had the same thought early on, since I also use Claude Code a lot and love how $ARGUMENTS works there. In practice though I’ve found myself augmenting saved prompts more often with arbitrary text, and the LLM has always handled both the instruction and the prompt body just fine, even with 1000+ line prompts. That’s the behavior I aimed to capture here: no special $ARGUMENTS wiring needed, while still being fully complementary to your approach. |
…r + frontmatter hints (#3565) Key features - Custom prompts accept arguments: $1..$9, $ARGUMENTS, and $$ (literal) - @ file picker in composer: type @ to fuzzy‑search and insert quoted paths - Frontmatter hints: optional description + argument-hint shown in palette (body stripped before send) Why - Make saved prompts reusable with runtime parameters. - Improve discoverability with concise, helpful hints in the slash popup. - Preserve privacy and approvals; no auto‑execution added. Details - Protocol: extend CustomPrompt with description, argument_hint (optional). - Core: parse minimal YAML‑style frontmatter at file top; strip it from the submitted body. - TUI: expand arguments; insert @ paths; render description/argument-hint or fallback excerpt. - Docs: prompts.md updated with frontmatter and argument examples. Tests - Frontmatter parsing (description/argument-hint extracted; body stripped). - Popup rows show description + argument-hint; excerpt fallback; builtin name collision. - Argument expansion for $1..$9, $ARGUMENTS, $$; quoted args and @ path insertion. Safety / Approvals - No changes to approvals or sandboxing; prompts do not auto‑run tools. Related - Closes #2890 - Related #3265 - Complements #3403
…r + frontmatter hints (#3565) Key features - Custom prompts accept arguments: $1..$9, $ARGUMENTS, and $$ (literal) - @ file picker in composer: type @ to fuzzy‑search and insert quoted paths - Frontmatter hints: optional description + argument-hint shown in palette (body stripped before send) Why - Make saved prompts reusable with runtime parameters. - Improve discoverability with concise, helpful hints in the slash popup. - Preserve privacy and approvals; no auto‑execution added. Details - Protocol: extend CustomPrompt with description, argument_hint (optional). - Core: parse minimal YAML‑style frontmatter at file top; strip it from the submitted body. - TUI: expand arguments; insert @ paths; render description/argument-hint or fallback excerpt. - Docs: prompts.md updated with frontmatter and argument examples. Tests - Frontmatter parsing (description/argument-hint extracted; body stripped). - Popup rows show description + argument-hint; excerpt fallback; builtin name collision. - Argument expansion for $1..$9, $ARGUMENTS, $$; quoted args and @ path insertion. Safety / Approvals - No changes to approvals or sandboxing; prompts do not auto‑run tools. Related - Closes #2890 - Related #3265 - Complements #3403
Supersedes #3358 (locked after accidental close).
Closes #3013.
Why
Reduce clutter and improve privacy: saved prompts can be very large (hundreds of lines). By default, their bodies are redacted from the transcript, and only the user-typed command is shown (e.g., /name). Users can override via CLI/config.
Enable flexibility: add per-submission custom instructions. A single saved prompt can be reused with different runtime directives without hard-coding variants.
Ensure resume shows exactly what the user saw: transcript text (verbatim/pretty) is persisted separately from the expanded model context.
Privacy: rollout remains unredacted to preserve resume correctness; logs/traces avoid leaking prompt bodies.
Before
Transcript always showed the full saved prompt body as the user message.
No support for appending custom instructions to saved prompts.
Resume reconstructed initial messages from expanded rollout content, so users could see long bodies instead of the short form.
Logs could include template text.
What We Did (Overview)
redact_saved_prompt_body
(default true).pretty_unredacted
.ResponseItem
, core now also persists transcript-onlyEventMsg::UserMessage(message=shown)
so resume displays exactly what the user saw live.After
By default, the transcript shows only what the user typed; bodies stay private unless redaction is disabled.
Saved prompts become significantly more flexible due to per-submission instructions.
Queues stay concise; execution history can render expanded context when redaction is OFF.
Resume faithfully replays transcript text (
EventMsg
), while model context is restored from expandedResponseItem
.Existing saved prompts without arguments continue to work unchanged; default redaction is opt-out via CLI/config.
Privacy: transcript/logs are redacted; rollout remains intact for resume.
All tests green; workspace builds and lints clean.
Technical Details
SubmittedWithDisplay { text, display, pretty_unredacted }
. History usesdisplay
(redaction ON) orpretty_unredacted
(redaction OFF). Agent always usestext
.pretty_unredacted
layout (“Custom instruction:” then “Saved prompt:”) when redaction OFF.display_text
; history selectsdisplay_text
vspretty_unredacted
based on config; sendOp::AddToHistory { text: shown }
.Op::AddToHistory
by appending to cross-session history and persisting transcript-onlyEventMsg::UserMessage
. Expanded context still persisted asResponseItem
.redact_saved_prompt_body
key; wire CLI flags --show-saved-prompt / --no-redact-saved-prompt.redact_saved_prompt_body: None
; core tests updated.Tests Added / Updated
selecting_custom_prompt_submits_file_contents
(updated)selecting_custom_prompt_with_instruction_wraps_and_displays_typed
(added)custom_prompt_shows_command_in_history
(added)custom_prompt_shows_body_when_redaction_disabled
(added)custom_instruction_with_cdata_terminator_does_not_panic_and_is_included
(added)flag_show_saved_prompt_sets_override_false
alias_no_redact_saved_prompt_sets_override_false
default_no_flag_sets_no_override
Docs
prompts.md
: sections “Transcript redaction of saved prompts” and “Custom instructions for saved prompts”.config.md
: new keyredact_saved_prompt_body
.Relation to #3164
This PR builds on the same motivation as #3164 (supporting arguments for saved prompts and keeping transcripts clean), but takes a slightly different approach:
$PROMPT_ARGUMENT
and relies on template logic to handle it.CustomInstruction > SavedPrompt
).Both approaches aim to make saved prompts more flexible. The difference here is mainly in UX: this PR avoids requiring template authors to add
$ARGUMENTS
handling, letting the model interpret both the instruction and the saved prompt directly. For users, this should feel simpler and more natural, while$PROMPT_ARGUMENT
remains available for cases where deterministic parsing is preferred.