history-trim 0.1.1: declare compressToolResults and preserveSystemPrompt, two regression cases (manjughosa, #681)
Declares history-trim's existing compressToolResults (true) and
preserveSystemPrompt (false) options in the package manifest, matching what
history-trim.middleware.js does when they are absent, and adds two
regression cases: a long surrogate-only tool result in the turn being sent
stays whole, and a repeated message is dropped even when its keys are in a
different order. No middleware runtime change. Version 0.1.0 -> 0.1.1 so
the new manifest is packed onto dist.
Run at the reviewed head 06c179d (and merged onto main d9a6c45), on mote:
- bun test packages/history-trim: 23 pass, 0 fail
- bun scripts/check.mjs: exit 0; bun test scripts/: 0 fail
Broken by hand: turning off the `index >= currentTurnStart` guard in
cutToolResults fails the new surrogate case (and "the turn being sent is
never cut"); dropping .sort() in canonical() fails the key-order case.
Not tried: a real request through a magpie gateway with the middleware on.
This commit is contained in:
@@ -778,5 +778,61 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "a long surrogate-only tool result in the turn being sent stays whole",
|
||||
"options": {
|
||||
"maxToolLength": 256
|
||||
},
|
||||
"request": {
|
||||
"model": "m",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "go"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "reading"
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"content": "😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "a repeated message goes even when its keys are ordered differently",
|
||||
"request": {
|
||||
"model": "m",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "same"
|
||||
},
|
||||
{
|
||||
"content": "same",
|
||||
"role": "user"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "ok"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expect_request": {
|
||||
"model": "m",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "same"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "ok"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/middleware-history-trim",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Send a request's history smaller: blank-line runs folded, a system prompt written twice and a message repeated right after itself dropped, a past tool result longer than maxToolLength cut, as magpie gateway middleware",
|
||||
"type": "module",
|
||||
"files": ["history-trim.middleware.js", "README.md", "LICENSE", "PROVENANCE.json"],
|
||||
@@ -9,6 +9,10 @@
|
||||
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/history-trim" },
|
||||
"magpie": {
|
||||
"middleware": "./history-trim.middleware.js",
|
||||
"options": { "maxToolLength": 2000 }
|
||||
"options": {
|
||||
"maxToolLength": 2000,
|
||||
"compressToolResults": true,
|
||||
"preserveSystemPrompt": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user