Skip to content

feat(chat-action): carry hidden context in the user turn, not the system prompt#24

Merged
albanm merged 8 commits into
mainfrom
feat-hidden-context-user-turn
Jun 16, 2026
Merged

feat(chat-action): carry hidden context in the user turn, not the system prompt#24
albanm merged 8 commits into
mainfrom
feat-hidden-context-user-turn

Conversation

@albanm

@albanm albanm commented Jun 16, 2026

Copy link
Copy Markdown
Member

Agent action-button "hidden context" is now carried inside the triggering user
turn (wrapped in <hidden-context> sentinels) instead of being merged into the
session system prompt.

What changed

  • A small wire-format helper (wrapHiddenContext / splitHiddenContext).
  • sendMessage wraps the hidden context into the history user turn; the chat
    bubble still displays only the visible prompt.
  • AgentChat.vue no longer mutates the session system prompt on action start or
    on session-clear.
  • Trace reconstruction splits hidden context back out into turn.hiddenContext,
    surfacing it as a distinct trace-overview entry.
  • The moderation gate deliberately classifies the full user message, wrapper
    included.

Why: keep action context scoped to the turn that needs it (not a permanent
system-prompt mutation), make it visible in the trace reviewer, and close a
moderation bypass where the previous approach would have stripped the wrapper.

Regression risks:

  • Hidden context is now turn-scoped, not session-scoped — it no longer persists
    across follow-up messages the way the system-prompt approach did.
  • Moderation now sees the <hidden-context> block for legit UI actions, so an
    action whose context trips the classifier could block the turn. Deliberate
    anti-bypass tradeoff.
  • splitHiddenContext parses stored trace content; a user message literally
    starting with the sentinels would be mis-split in the trace reviewer
    (display-only, low risk).

albanm and others added 8 commits June 16, 2026 10:20
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Action-button hidden context injected at the head of the last user
message is app-authored and trusted; the moderation gate must judge
only the user's own visible text. Add stripHiddenContext() to
moderation/operations.ts (pure, mirroring the UI sentinel format) and
apply it at the gateway call site before startModeration().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@albanm albanm merged commit 20ebd92 into main Jun 16, 2026
3 of 4 checks passed
@albanm albanm deleted the feat-hidden-context-user-turn branch June 16, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant