mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-28 16:09:34 +00:00
The Responses client-tool restore raised an upstream function_call back to custom_tool_call and tool_search_call without touching its item ID, so the client received a custom_tool_call carrying the upstream's fc_ ID. That combination is invalid: once the item lands in the client's history, any later replay to an upstream that validates item IDs fails the whole request with "Invalid 'input[N].id': 'fc_...'. Expected an ID that begins with 'ctc'", and every following message re-submits the same bad item. Re-prefix the ID to match the type it is raised to, keeping the suffix so the ID stays stable and unique per upstream item. IDs without a known tool-call prefix are left alone rather than guessed at. The lowering direction has to reverse this, because the WebSocket HTTP bridge replays restored items back to the upstream and would otherwise lose the upstream's own ID. normalizeLoweredFunctionItemID now maps a ctc_/tsc_ call ID back to fc_ instead of dropping it, which makes the round trip lossless; output item IDs (ctco_/tso_) still have no function-protocol counterpart and are still dropped. The helper was renamed from dropInvalidLoweredFunctionItemID to match what it now does. The stream restorer keeps the upstream ID for its own bookkeeping so later upstream events still match the call, and emits the client-facing ID on output_item.added/done and the custom_tool_call_input events. Closes #6071