Files
plugins/packages/agy-cli/test
yetone 369643183f agy-cli 0.1.73: a batching call Hermes split into one call per entry is folded back (#1150)
NieiR traced a Hermes Agent turn (agy 1.5.9, chat/completions) that
ended in 409 "some tool results do not belong to the active response"
(#1150): agy called Hermes' batching tool once, tool_call({calls: [4]}),
and Hermes wrote it into its history as four tool_calls of one entry
each. The first kept the bridge's toolu_ id; the other three got
call_<hex> ids of Hermes' own, each with a result. Only the first
matched a bridge call, so the round was refused and Hermes gave up the
turn.

foldSplitCalls, run on the canonical body before anything reads it,
folds such a round back into the one agy made: the calls' array field
joined in order under the first (bridge) id, and their results joined
in order as that call's one result (an error only if every part was).
It folds only when a run of same-named calls opens with a bridge id
(toolu_ + 24 hex), every other id is not one, every input is an object
with the same single array field, and either every call has its result
or none has (a round still waiting). Two calls the bridge made itself
are never folded. README (zh, en) says so.

Not in this change: NieiR's second finding, that #selfPollCapped stays
off for a turn once any of its calls was seen by the client, so an
orphaned turn keeps generating every 150s until the 30-minute result
timeout. Left for its own commit.

Run (mote, HOME=$(mktemp -d)):
- packages/agy-cli bun test (all suites, smoke included): 36 pass,
  0 fail; repeat-batch.mjs alone: 46 pass.
- bun scripts/check.mjs agy-cli: ok.

Broken by hand: origin/main's index.mjs with the new tests: the split
round answers 409, as reported; the never-fold test passes on both.

Not tried: real Hermes Agent against real agy. The test drives the
bridge through its real entry points with a fake agy.
2026-11-16 12:57:58 +08:00
..