Gemini requests (`contents`) are now thinned: thought parts, parts carrying a
thoughtSignature and functionCall parts stay as sent; a functionResponse keeps
its id, name and keys while the long strings inside it are cut; old images
become a note; document and video inlineData stay. saccade "auto" strips
<system-reminder> blocks before judging the topic, and a user message that is
only harness blocks is not the newest question. leadingUserEnd counts
custom_tool_call / computer_call / local_shell_call (and outputs) as answers.
Chat's legacy role "function" messages are thinned like role "tool".
page/measure.js carries the same change (diff of the two files is only the
export line).
What was run at 38385b82 (merged onto main 15f4fa80), on mote (macOS, Bun 1.4.2):
- bun test packages/fovea: 57 pass, 0 fail; bun scripts/check.mjs fovea: ok.
- fovea main vs 0.2.5 through magpie's own moejs middleware runner
(internal/middleware Begin/Request, a throwaway test, not committed):
- Gemini body, 41 turns, 849,212 -> 360,846 bytes (main: unchanged).
Every thought part, thoughtSignature text part and functionCall is
byte-identical; functionResponse ids/names kept, nested strings cut;
image/png -> note, application/pdf untouched; the task turn and the
recent window unchanged; no middleware failures.
- Gemini, 401 turns, 8.5 MB, default options: 3.4 ms in onRequest
(limit 250 ms).
- Claude Code shape with <system-reminder> on every tool_result turn,
saccade auto: a follow-up collapses nothing (main and 0.2.5); a real
topic change with a reminder attached collapses 57 old items on 0.2.5,
none on main.
- Chat role "function": 81,491 -> 25,035 bytes (main: unchanged).
- Responses whose first answer is custom_tool_call: 81,736 -> 25,240
(main: unchanged).
- No new network access or I/O in the diff.
Not tried: a real Gemini account through a live gateway.
65 lines
2.2 KiB
JSON
65 lines
2.2 KiB
JSON
{
|
|
"name": "@magpie-community/middleware-fovea",
|
|
"version": "0.2.5",
|
|
"description": "magpie gateway middleware: keep the recent window sharp, thin old history to head and tail, and on a saccade drop the old context on a new topic — with an evidence page",
|
|
"type": "module",
|
|
"files": [
|
|
"CHANGELOG.md",
|
|
"LICENSE",
|
|
"README.md",
|
|
"benchmark.mjs",
|
|
"build.mjs",
|
|
"cases.json",
|
|
"fovea.middleware.js",
|
|
"fovea.protocols.test.mjs",
|
|
"fovea.test.mjs",
|
|
"page/*",
|
|
"preview.mjs",
|
|
"state-block.example.json"
|
|
],
|
|
"keywords": [
|
|
"magpie",
|
|
"magpie-middleware",
|
|
"context",
|
|
"history",
|
|
"compaction",
|
|
"tool-results",
|
|
"token-budget",
|
|
"saccade",
|
|
"llm-gateway"
|
|
],
|
|
"license": "MIT",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/magpie-community/plugins.git",
|
|
"directory": "packages/fovea"
|
|
},
|
|
"magpie": {
|
|
"middleware": "./fovea.middleware.js",
|
|
"page": {
|
|
"title": "Fovea evidence",
|
|
"titles": {
|
|
"zh": "Fovea 对照证据"
|
|
},
|
|
"file": "page/index.html",
|
|
"icon": "page/icon.svg"
|
|
},
|
|
"permissions": [],
|
|
"options": {
|
|
"threshold": 96000,
|
|
"keep_recent": 12,
|
|
"keep_recent_tokens": 16000,
|
|
"tool_head": 600,
|
|
"tool_tail": 300,
|
|
"text_head": 1200,
|
|
"text_tail": 400,
|
|
"drop_old_images": true,
|
|
"protect": [],
|
|
"saccade": "off",
|
|
"state_marker": "",
|
|
"cut_step": 24
|
|
},
|
|
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9IkZvdmVhIGxvZ28gZm9yIGRhcmsgYmFja2dyb3VuZHMiPgogIDx0aXRsZT5Gb3ZlYSDigJQgc2hhcnAgY2VudHJlLCBmYWRpbmcgcGVyaXBoZXJ5IChkYXJrKTwvdGl0bGU+CiAgPGNpcmNsZSBjeD0iNjQiIGN5PSI2NCIgcj0iNTgiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2U4ZWVmNSIgc3Ryb2tlLW9wYWNpdHk9IjAuMjIiIHN0cm9rZS13aWR0aD0iNiIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjQyIiBmaWxsPSJub25lIiBzdHJva2U9IiNlOGVlZjUiIHN0cm9rZS1vcGFjaXR5PSIwLjUiIHN0cm9rZS13aWR0aD0iNyIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjI1IiBmaWxsPSJub25lIiBzdHJva2U9IiNlOGVlZjUiIHN0cm9rZS1vcGFjaXR5PSIwLjkiIHN0cm9rZS13aWR0aD0iOCIvPgogIDxjaXJjbGUgY3g9IjY0IiBjeT0iNjQiIHI9IjEwIiBmaWxsPSIjOGRiYmY1Ii8+Cjwvc3ZnPgo="
|
|
}
|
|
}
|