mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-27 14:24:47 -06:00
fed5b96a6f
* fix: universal tool_call/tool_result orphan detection for OpenAI-compat providers The Anthropic provider had orphan detection for mismatched tool_call ↔ tool_result pairs, but OpenAI-compatible providers (Chat Completions, Google, Responses API) had none. When an Anthropic model runs behind an OpenAI-compat API (e.g. Azure) or cancellation creates orphans, the API rejects the malformed request. - Rewrite sanitize_messages() with orphan detection: synthesize error tool results for unmatched tool_calls, drop tool results with no matching tool_call, fill empty tool_call IDs with positional remap - Call sanitize_messages() from Responses API _convert_messages() * fix: address review feedback on orphan detection - Track answered IDs per-turn (local_answered) instead of scanning all of out, preventing false matches from reused IDs across turns - Drop empty-ID tool results that have no remap entry instead of passing them through with invalid empty tool_call_id - Increment empty_result_idx for every empty result, not just remapped - Remove dead result_ids peek-ahead code - Add test for repeated tool_call IDs across turns