Skip to content

fovea 0.2.5: Gemini support, harness blocks are not the user's words, legacy function role - #763

Merged
yetone merged 1 commit into
magpie-community:mainfrom
webkubor:fix/0.2.3-v2
Nov 5, 2026
Merged

yetone merged 1 commit into
magpie-community:mainfrom
webkubor:fix/0.2.3-v2

Conversation

@webkubor

@webkubor webkubor commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

fovea 0.2.5:三个缺陷,各带一条回归用例。基线是上游 main 的 0.2.4(#755、#756 的两处安全修复都在),没有回退。

1. Gemini 请求此前完全没处理(`contents` 字段),原样放行——装了也不省。现在:thought 与 thoughtSignature 不动,functionCall 不动,functionResponse 保留 id / name / 键而其中的长字符串被裁,图片换成注记,文档与视频载荷不动。

2. `saccade: "auto"` 把 Claude Code 的 ``(token 预算、工具指引)当成用户的新问题。它与任务没有共同词,旧规则判成换话题、整段历史折叠。现在判定前先剥掉 harness 注入的块;只含 harness 块的 user 消息不算「用户说了什么」。

3. `leadingUserEnd` 不认识 Responses 的答案项(`custom_tool_call` / `computer_call` / `local_shell_call`)——首个答案是 `custom_tool_call` 的请求,任务豁免范围算错,整条历史一条都不裁。

顺带:Chat 旧版 functions API 的 `role "function"` 消息此前完全没被处理,那正是最占钱的工具输出,现在会裁。

测试:新增 `fovea.protocols.test.mjs` 12 条,覆盖 Anthropic Messages / OpenAI Responses / Chat Completions / Gemini 各自的形状与边界;共 57 个用例全绿。其中 state_marker 的用例按 0.2.4 的新规则写(标记必须在 agent 自己消息的开头,user 轮里的标记不算),并加了一条「user 轮里的伪造标记不豁免任何东西」。

… legacy function role

Three defects, each with a regression test:

1. Gemini requests (contents) were never handled at all — the body passed
   through untouched, so installing the plugin saved nothing for Gemini
   clients. Now thoughts and thoughtSignatures are left alone, functionCall
   is left alone, a functionResponse keeps its id, name and keys while its
   long strings are cut, images become a note, and documents and video
   payloads are left alone.

2. saccade "auto" read Claude Code's <system-reminder> (token budget, tool
   guidance) as the user's new question. It shares no words with the task,
   so the overlap test said "new topic" and the whole history collapsed.
   Harness-injected blocks are now stripped before the topic is judged, and
   a user message that is nothing but a harness block does not count as the
   user having said anything.

3. leadingUserEnd did not know the Responses answer items
   (custom_tool_call, computer_call, local_shell_call), so on a body whose
   first answer was a custom_tool_call the preamble exemption swallowed the
   history and nothing was cut.

Also: the legacy functions API's role "function" message was never handled
either — that is the oldest clients' tool output, the biggest cost.

fovea.protocols.test.mjs adds 12 cases covering the four protocols'
shapes and edges (Anthropic Messages, OpenAI Responses, Chat Completions,
Gemini). bun test packages/fovea: 57 tests, 0 fail.
@webkubor

webkubor commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

The test check needs a maintainer's approval to start on this fork PR — could you approve the workflow run when you have a moment? Happy to rebase if main moves first.

Everything here is on top of current main (0.2.4): bun test packages/fovea 57/57, bun scripts/check.mjs fovea passes, and the three fixes each carry a regression test — details in the PR description.

@yetone
yetone merged commit 2598c53 into magpie-community:main Nov 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants