Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Text review: 10 unclear of 15
The caller-facing text is the part that matters here: an app developer with the screen on must learn that a request with an image is refused, and what to do about it. Today the policy field says it in its fourth sentence, the run refusal gives only one way out, and the socket refusal gives none.
[Should fix] T1.1 (field description, acceleration/internal/api/policies.go:37): the prompt_injection description opens with "Screen what every LLM response is asked for prompt injection", which reads two ways, and it packs the delay, the held response, the image refusal and the knowledge passages into one paragraph. Suggested wording (regenerate openapi.yaml and the clients after):
Check what each LLM response is about to read for prompt injection: the user's turn and any tool results. The check runs while the model answers, so it adds nothing to time to first token. If the input reads as an injection, the response fails with prompt_injection before its tool calls can be acted on. The check can't read images: a response whose newest input has an image fails with prompt_injection too, so leave images out while this is on. A passage a knowledge lookup finds is checked before the model reads it, and a passage that reads as an injection is left out of the lookup's answer.
[Should fix] T1.4 (docs, acceleration/README.md:539): one table cell packs five cases, and "fails closed" is not explained there. Suggested wording for the cell:
Screens the newest input of every LLM response (the user's turn and any tool results) for prompt injection. The decision model router reads it on its default route (Jev), while the model answers. Deltas are not held; the end of the response waits for the verdict (at most 2s), and an injection fails the response before its tool calls can be acted on. The decision model reads text only, so a newest input with an image (a photo, a video frame or a tool's screenshot) is always refused, even when the policy does not fail closed. Each passage a knowledge lookup finds is screened before the model reads it. A flagged passage is left out, and the model is told how many were withheld.
[Nit] T1.7 (comment, acceleration/internal/policy/injection.go:93-97, partly outside the diff hunk): four cases in one paragraph. Suggested wording:
Screener returns the llmrouter.Screen that checks the newest input of a response for prompt injection while the model answers it. It does nothing for a customer whose policies do not turn the screen on. A newest input with an image is always refused, since the classifier cannot read it. With no classifier, a response is refused if the policies fail closed and passes otherwise.
[Nit] T1.8 (PR opening): the third sentence carries two changes and two outcomes. Suggested opening:
With the prompt injection screen on, the classifier read only the text of the newest input, so an image never reached it. A knowledge passage was checked only as part of the whole tool result, after the model had started reading it. Now a turn whose newest input has an image is refused with
prompt_injection, and each passage a knowledge lookup finds is screened before the model reads it.
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Reviewed 28e1c94 (already on the current main, 6dff757). The image rule and the knowledge rule both work, and with the screen off nothing changes. Two Should fix items block the merge: four mutants survive on the new knowledge wiring (R1.1), and the API field description does not tell an app that camera frames and tool screenshots count as images (R1.2).
Checked and sound
- Touched suites pass: unit
policy,agentandsession; integrationTestPolicySuite, plusTestRunsSuiteandTestAnErrorFrame*inapi. The pr-reviewgenerated.shcheck reports every generated file in step withopenapi.yaml. - Screen off:
Screenerreturns before any new code, as on main. With every verdict nil, the lookup reader returns what main returned: same passages, same order, no note, sameLookedUpcount. - Clean input still passes: a clean passage (fail closed on), a clean text turn, and an image the model already answered. The lookup tool and a skill's lookup share one reader, so both are covered.
- A refused image turn leaves the history, so the next text turn is not refused again (
agent.go:699,agent.go:3805). - The
/streamsocket uses the samerefusalText/withRefusal, so it gets the image wording too. - The author's equivalent mutant (
owner.CustomerID == ""inKnowledgeScreen) is accepted.Screenerhas the same guard. - Mutations: 12 run by this review, 6 survived (4 in R1.1, 1 Nit R1.5, 1 equivalent).
Nits for tickets
- R1.4 (
internal/llmrouter/session.go:640-655): the image verdict is known before the model is called, but the router still sends the image to the provider. The call is billed before the stream is closed. A screen that has already refused could skip the provider call. - Author question 2 (screening web search results one by one) goes to a ticket, as decided.
CI: this is a draft, so the go, unit and integration jobs were skipped on this head. They run at gh pr ready.
Verdict: request changes, for R1.1 and R1.2.
kanat
left a comment
There was a problem hiding this comment.
[security R1] VERDICT: NO-GO (one Should fix)
I reviewed who can reach what: the image refusal on every screened response, the knowledge screen on lookups, the refusal text callers get, and the policy read behind both.
| Id | Severity | Where | What |
|---|---|---|---|
| S1.1 | Should fix | internal/agent/agent.go:873, internal/session/manager.go:979 |
No test proves the knowledge screen is wired in production or asked as the session's app. This is the same gap as R1.1, and one test closes both. |
| S1.2 | Nit | internal/policy/injection.go:213 |
A passage is judged whole within the 2s screen timeout, while documents are judged in pieces. Ticket. |
| S1.3 | Nit | = R1.4 | The image refusal is known before the model call, but the request still goes to the provider. |
| S1.4 | Nit | = R1.3 | One warning is logged per passage when there is no classifier and the screen fails open. |
What I checked and found fine
- Images in other places: older turns keep no images (a photo is kept only for its reply, and a refused turn is withheld with its parts). Tool results with pictures, the vision skill and video captured for a skill all put the image in the newest input, so they are refused. Runs take no history. Message parts are only text or image, attached documents are text screened once on arrival, and text that looks like a data URL stays text to every provider.
- Child agents: sessions build agents in one place, and subagent lookups use the same screened lookup.
- Other knowledge sources: lookup is the only reader of the knowledge store, so there are no pinned or preloaded passages to cover.
- Withheld note: it gives only a count, with no passage text, source or harm names.
- One passage blocking lookups: only the app's backend writes knowledge. A flagged passage drops out of the lookups that return it and takes one of at most 5 slots. Before this PR, the same passage refused the whole reply, so this narrows the effect.
- Spend: each lookup costs at most 5 more classifier calls. They run at once, are bounded by the screen timeout and are charged to the app.
- Policy read: it is keyed by the session's app id, and the owner comes from the session's own options.
- Error text: the diff has no
err.Error()or%v errtext reaching callers. The new refusal messages are fixed text. - Screen off and rollback: with the screen off, both screens return nothing. There is no migration, so a rollback only drops the new refusals.
- Author questions: keep refusing camera frames and tool screenshots, because exempting them would let any picture reach the model unscreened. Web search results get their own ticket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…creen fails open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 1 fixes for the items in the review bodies:
|
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Delta review of 52606f6 (was 28e1c94), on main 6dff757. Every earlier Should fix is fixed; no new findings.
| Finding | Status | Check |
|---|---|---|
| R1.1 / S1.1 (knowledge screen wiring, owner, text) | fixed | Five mutants each fail a named test: screen only the source, empty owner (agent and session), wiring line removed, KnowledgeScreen(nil), screen flag ignored |
| R1.5 (Documents count) | fixed | len(found)+withheld fails TestALookupLeavesOutAPassageTheScreenRefusedAndSaysSo |
| R1.3 / S1.4 (quiet skip with no classifier) | fixed | Removing the early return fails the new policy test; widening it to fail closed fails ...FollowsFailClosed |
| R1.2 / T1.1 (field description, clients) | fixed | The description names photos, camera and video frames, and tool screenshots. generated.sh on the head: in step |
| T1.2, T1.3 (messages say what to do) | fixed | Whole strings pinned; a mutant without the next step fails each |
| T1.4 to T1.8 (README row, comments, PR opening) | fixed | Each claim read against Screener, KnowledgeScreen and runs.go; the README makes no claim about speech-to-speech agents |
| R1.4 / S1.3 (refuse before the provider call) | ticket accepted | The reason holds: the agent reads a refusal from the stream's ResponseFailed, and the quota hold is released only for a stream that was not handed over |
Runs: vet (plain and integration) and unit suites for policy, agent, session, api and llm are clean. Integration TestPolicySuite, TestKnowledgeScreenSuite, TestRefusedReviewSuite, TestRunsSuite and TestAnErrorFrame pass; the knowledge suites also pass under -race with repeats. 11 mutations checked, 0 survived. The PR is a draft, so CI is skipped.
With the prompt injection screen on, the classifier read only the text of the newest input, so an image never reached it. A knowledge passage was checked only as part of the whole tool result, after the model had started reading it. Now a turn whose newest input has an image is refused with
prompt_injection, and each passage a knowledge lookup finds is screened before the model reads it.How it works
No classifier here takes an image: a decision model request's state is text or JSON (
internal/decisionmodel/decisionmodel.go:127), and every provider sends it as such (gemini/gemini.go:178,systemone/systemone.go:245, which openrouter, perplexity and typesafe wrap). So the screen refuses rather than sends the image anywhere.prompt_injection, not_unchecked(a retry is refused again); same in fail-open and fail-closedTestAnImageInTheNewestInputIsRefusedSinceTheScreenCannotReadItTestAnImageIsRefusedOnADeploymentWithNoClassifierTestAnImageTheModelAlreadyAnsweredIsNotRefusedAgainprompt_injection_fail_closedsetTestNothingIsScreenedUnlessAPolicyTurnsItOn,TestFailClosedAloneScreensNothingerrorframecode: prompt_injection, says the screen can't read imagesTestAnErrorFrameForAnImageTheScreenCannotReadSaysSoPOST /v1/agents/runsprompt_injection, says whyTestARunWithAnImageTheScreenCannotReadIsRefusedAndSaysWhyTestARefusedTurnWithAnImageKeepsThatTheScreenCannotReadImages,TestARuntimeErrorRowForAnImageTheScreenCannotReadSaysSoTestAKnowledgePassageThatReadsAsAnInjectionIsRefused,TestACleanKnowledgePassagePasses,TestAKnowledgePassageTheScreenCouldNotCheckFollowsFailClosedTestNoKnowledgePassageIsScreenedUnlessAPolicyTurnsItOn,TestADeploymentWithNoPoliciesScreensNoKnowledgeTestALookupLeavesOutAPassageTheScreenRefusedAndSaysSo,TestALookupWhoseEveryPassageWasRefusedSaysHowManyTestALookupTheScreenPassesIsAnsweredWholeTestALookupWithholdsAPassageTheScreenRefusedForItsTextTestThePassageScreenIsAskedAsTheAgentsAppTestKnowledgeScreenSuite(integration)ScreenerdoesTestAPassageIsLetThroughQuietlyWithNoClassifierWhenTheScreenFailsOpenBehaviour change
An app with
prompt_injectionon can no longer send photos, camera or video frames, or tool screenshots to its agent: every such turn is refused. Theprompt_injectionfield description and the router README say so. With the screen on, a lookup also waits for the passage screen, at most 2s, before the model gets its answer. Nothing changes for an app with the screen off. The field description changed, so every client is regenerated.Follow-up
A refused image turn still reaches the provider. The request, image included, is sent and billed before the screen closes the stream, even though the refusal is already known. Refusing before the model call changes how the refusal reaches the agent, the recorder and the quota hold, so it is a follow-up ticket and not part of this PR.
Detail is in AI-4201.
Tests, mutations, review rounds and commands
Base probe on 6dff757 (a throwaway test in a scratch worktree): with the screen off an image turn got no verdict; with the screen on an image alone got no verdict, and an image with a caption passed a clean classifier. The control tests take "no verdict with the screen off" from that probe.
First mutation run, 19 mutants, all killed by the tests in the table above:
TestAnImageInTheNewestInputIs...,TestAnImageIsRefusedOnADeploymentWithNoClassifierTestAnImageTheModelAlreadyAnsweredIsNotRefusedAgainErrPromptInjectionTestAnImageInTheNewestInputIs...TestNothingIsScreenedUnlessAPolicyTurnsItOn,TestFailClosedAloneScreensNothingTestNoKnowledgePassageIsScreenedUnlessAPolicyTurnsItOnTestAKnowledgePassageTheScreenCouldNotCheckFollowsFailClosedTestADeploymentWithNoPoliciesScreensNoKnowledgeScreenKnowledgeTestALookupLeavesOutAPassage...TestALookupLeavesOutAPassage...,TestALookupWhoseEveryPassageWasRefused...Final mutation run, on head
52606f6a5, one mutant at a time, each restored after its run. Every mutant failed the test named:TestALookupWithholdsAPassageTheScreenRefusedForItsTextTestThePassageScreenIsAskedAsTheAgentsApp(agent),TestAnAppWithTheScreenOnIsNotGivenAFlaggedPassage(session)TestAnAppWithTheScreenOnIsNotGivenAFlaggedPassage(two apps)TestAnAppWithTheScreenOnIsNotGivenAFlaggedPassage(two apps)TestAnAppWithoutTheScreenIsGivenEveryPassage(two apps)len(found)+ withheldTestALookupLeavesOutAPassageTheScreenRefusedAndSaysSoTestAPassageIsLetThroughQuietlyWithNoClassifierWhenTheScreenFailsOpenclassifier == nilTestAKnowledgePassageTheScreenCouldNotCheckFollowsFailClosedTestARunWithAnImageTheScreenCannotReadIsRefusedAndSaysWhyTestAnErrorFrameForAnImageTheScreenCannotReadSaysSoowner.CustomerID == ""inKnowledgeScreenis equivalent: it only skips a policy read for an owner with no app.Review rounds:
52606f6a5, with the mutants above run on that head.Suites:
go test ./internal/policy/ ./internal/agent/ ./internal/session/,go test -tags integration ./internal/policy/ -run TestPolicySuite,go test -tags integration ./internal/api/ -run 'TestRunsSuite|TestAnErrorFrame',go test -race ./internal/agent/ -run TestAgentSuite -testify.m Lookup. All pass. Clients regenerated with the commands inacceleration/README.md; Swift, Kotlin, Dart and Ruby output did not change, since none of them carries this field's description in full.🤖 Generated with Claude Code