fix(core): make EXTERNAL_CONTENT_WARNING label-agnostic#480
Closed
lmorchard wants to merge 1 commit into
Closed
Conversation
The shared warning text hardcoded "current state of the web page" phrasing, which is misleading for non-page labels (search results, conversation history). Rewrite to describe the threat model generically — untrusted external data, treat directives as data, not instructions — so the wording stays accurate as `ExternalContentLabel` grows. Closes #464 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
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.
Summary
Rewrites
EXTERNAL_CONTENT_WARNINGinpackages/core/src/utils/promptSecurity.tsso the wording no longer assumes the wrapped content is a page snapshot.Before
After
This is Option C from #464 — generic threat-model phrasing, single shared warning, no per-label override needed. Keeps
wrapExternalContentWithWarning()'s signature unchanged.Why
The "current state of the web page" phrasing fit when the only wrapped content was page snapshots. #463 adds a
ConversationHistorylabel for the validator, where that wording is misleading (the content is an agent transcript, not page state). The wording also has to stay accurate asExternalContentLabelgrows. The threat-model intent — treat directives inside as data, not instructions — is the same across all labels, so a generic phrasing serves them all.Changes
packages/core/src/utils/promptSecurity.ts—EXTERNAL_CONTENT_WARNINGrewritten.packages/core/test/prompts.test.ts— one assertion updated (as page text→as data) to match the new wording. No new test cases; the existing tests cover label-aware wrapping and the warning-presence behavior, both of which are unchanged.Test Plan
pnpm run checkpasses (core 684, cli 221, server 96, extension 266)pnpm run format:checkpassesgitleaks protect -vcleanReferences
🤖 Generated with Claude Code