state_marker was found by its text anywhere: any item's string content
or any part's text. A Chat tool result or a user message that read a
file or log containing the marker stayed whole on every turn, and lifted
the task message's protection. carriesState now takes the marker only
where the agent writes its state block: an assistant message (Chat,
Anthropic, or a Responses message item) whose string content, or a
text/output_text part, starts with the marker. Tool results, user text,
nested tool_result parts, function_call_output and a marker in the
middle of a text count for nothing. page/measure.js rebuilt (build.mjs's
transform), README option row and CHANGELOG updated. Ships the 8e4105dd
docs fix too.
Run on mote (Bun 1.4.2, temp HOME), at bf959aa60e plus this change:
- bun test packages/fovea: 45 pass, 0 fail (10 new tests).
- bun test (whole repo): 5932 pass, 19 skip, 0 fail. bun scripts/check.mjs ok.
- Old code (origin/main's middleware) with the new tests: 6 fail -
Chat tool result (string and text part), user string, user text block,
mid-text assistant, Responses user input_text. The Anthropic
tool_result (string, nested part) and function_call_output cases pass
on the old code too: it read only top-level content/text, so those
were not forgeable; the tests keep them that way.
- Broken by hand: role/type check removed, 4 fail; startsWith replaced
by includes, 1 fail (mid-text).
Not tried: a live gateway request, magpie's moejs run of cases.json.
Users who put the marker somewhere other than the start of an assistant
text lose the exemption; fovea is not on npm and the option is off by
default.