Files
magpie/docs
yetone a69cd07075 gateway: a Chat tool call kept with an empty id goes with one made from its place (#2611, RunMintOn)
RunMintOn's session held an assistant turn whose tool call had "id":""
and a tool result with "tool_call_id":"". magpie relayed it unchanged on
Chat->Chat, and WorkBuddy AI turned the whole request away (400, 11133).
Chat->Messages sent tool_use id "" and Chat->Responses gave the call a
random id while its result kept "".

- chatCallIDs (chat_call_ids.go) runs in attempt for every Chat request,
  before the relay, the translation and a plugin's fetch alike (a moved
  WorkBuddy AI goes through the plugin, so the edit must come first). An
  empty, null or missing call id gets "call_" + a hash of the call's
  message index, position, name and arguments: the same on every resend,
  so the prompt-cache prefix holds. A result with an empty tool_call_id
  takes the turn's unanswered calls in order. A body that already has its
  ids comes back byte-identical.
- chatTidy gives a stream's first fragment of each (choice, index) call an
  id when the upstream sent none, and drops an empty id on later ones;
  chatWhole fills a whole reply's empty ids.
- docs/subsystems/gateway-routing.md says so.

Tests (chat_call_ids_test.go), fixtures from the issue's literal bytes,
against a fake that refuses as WorkBuddy AI does:
- TestEmptyCallIDRelayedWithOne, TestEmptyCallIDReachesPluginWithOne
  (movedFake workbuddy-ai), TestEmptyCallIDTranslatedWithOne (messages,
  responses), TestChatCallIDsLeavesWhatHasIDs, TestStreamedCallGivenAnID,
  TestWholeReplyCallGivenAnID.
- Broken by hand, each watched red: edit removed (relay and plugin get
  the 400; translations send an empty or unpaired id); a random id in
  place of the placed one ("the made id changed between requests");
  stream mend off (first fragments' ids ""); whole mend off ("id":"").

Run at this change on origin/main 81313b912:
- gofmt -l: nothing. go vet -tags nogui ./... on darwin, GOOS=linux and
  GOOS=windows: nothing.
- go test -tags nogui -timeout 45m ./...: 64 packages ok; internal/agent
  and internal/gateway failed on "no space left on device" (the disk
  filled under other sessions' runs: agent's testlog.txt write after
  PASS, gateway's TestRotateSpreadsABurstOfNewConversations renaming
  providers.json). Rerun with space free: internal/agent ok 652.9s,
  internal/gateway ok 732.9s.
- Not tried against a real WorkBuddy AI account (no live configs).
2026-10-17 03:53:40 +08:00
..