fix(showcase/aimock/d6/claude-sdk-typescript): tune custom-catchall match for Responses API turn-index discriminator

Mirrors A19b's BIA fix pattern for the Anthropic-family csdkts integration.

Root cause: csdkts uses Anthropic SDK which generates its own toolCallIds (toolu_*) rather than echoing aimock's prescribed call_d6_cc_*. The fixture's toolCallId-gated narration entries never matched on turn-2, causing fall-through to less-specific entries (or 503/no-match).

Fix: replace toolCallId discriminator with turnIndex (count of role:assistant messages). turnIndex is backend-id-invariant — it works regardless of how the backend rewrites tool_call_id values. Same shape as A19b BIA fix.

- Tokyo narration: toolCallId → turnIndex: 1
- AAPL narration: toolCallId → turnIndex: 3
- AAPL emit: added turnIndex: 2
- Tokyo emit: turnIndex: 0

response.content + canonical phrase ("rendered through the custom wildcard catchall") and response.toolCalls UNTOUCHED.

Verified locally on cr5495/fix-a20-csdkts-green at HEAD d178e6730 (post-A21b):
- /tmp/cr/a20v6-green-csdkts.log: 1 passed, INNER_EXIT=0
- iso2 slot, full infra healthy (aimock+pocketbase+dashboard+csdkts)

(cherry picked from commit e66e0eb0ce72c970348183eeb4f4b57c3f5b1d29)
This commit is contained in:
Jordan Ritter
2026-06-16 21:30:14 -07:00
parent d178e67300
commit 80fad7bbfb
@@ -6,20 +6,21 @@
},
"fixtures": [
{
"_comment": "tool-rendering-custom-catchall pill 1: weather in Tokyo \u2014 follow-up after get_weather tool result. Must come before the tool-emitting fixture.",
"_comment": "tool-rendering-custom-catchall — follow-up narration after get_weather tool result. Scoped via turnIndex:1 (assistant-count = 1 means 'one tool-call leg has been emitted; we're now narrating the result'). The Anthropic Responses API path auto-generates tool_call_id at request time, so the older toolCallId pin against a fixture-defined literal never matched on /v1/responses; turnIndex+userMessage is the id-agnostic alternative. Ordered BEFORE the tool-emit sibling so first-match-wins picks narration when the assistant-count gate fires.",
"match": {
"userMessage": "Forecast Tokyo through the wildcard renderer",
"toolCallId": "call_d6_cc_get_weather_001",
"turnIndex": 1,
"context": "claude-sdk-typescript"
},
"response": {
"content": "Tokyo is 22 degrees C and partly cloudy. The custom wildcard renderer should display a card for the get_weather tool call \u2014 rendered through the custom wildcard catchall."
"content": "Tokyo is 22 degrees C and partly cloudy. The custom wildcard renderer should display a card for the get_weather tool call — rendered through the custom wildcard catchall."
}
},
{
"_comment": "tool-rendering-custom-catchall pill 1: weather in Tokyo \u2014 first leg: emit get_weather tool call. The custom catchall renderer fires for this tool since no per-tool renderer is registered.",
"_comment": "tool-rendering-custom-catchall — first prompt 'weather in Tokyo'. Emits get_weather tool call. The custom wildcard renderer fires for any tool the user doesn't explicitly handle. hasToolResult:false on the tool-emitting fixtures.",
"match": {
"userMessage": "Forecast Tokyo through the wildcard renderer",
"hasToolResult": false,
"context": "claude-sdk-typescript"
},
"response": {
@@ -33,20 +34,21 @@
}
},
{
"_comment": "tool-rendering-custom-catchall pill 2: AAPL stock price \u2014 follow-up after get_stock_price tool result. Must come before the tool-emitting fixture.",
"_comment": "tool-rendering-custom-catchall — follow-up narration after get_stock_price tool result. Scoped via turnIndex:3 (assistant-count = 3 means weather-emit + weather-narrate + stock-emit have happened; we're now narrating the AAPL tool result). The Anthropic Responses API path auto-generates tool_call_id at request time, so the older toolCallId pin against a fixture-defined literal never matched on /v1/responses; turnIndex+userMessage is the id-agnostic alternative. Ordered BEFORE the AAPL tool-emit sibling so first-match-wins picks narration once the AAPL assistant-count gate fires.",
"match": {
"userMessage": "Quote AAPL through the wildcard renderer",
"toolCallId": "call_d6_cc_get_stock_price_001",
"turnIndex": 3,
"context": "claude-sdk-typescript"
},
"response": {
"content": "AAPL is trading at $338.37, down 2.96% on the day. The custom wildcard renderer should display a card for the get_stock_price tool call \u2014 rendered through the custom wildcard catchall."
"content": "AAPL is trading at $338.37, down 2.96% on the day. The custom wildcard renderer should display a card for the get_stock_price tool call — rendered through the custom wildcard catchall."
}
},
{
"_comment": "tool-rendering-custom-catchall pill 2: AAPL stock price \u2014 first leg: emit get_stock_price tool call.",
"_comment": "tool-rendering-custom-catchall — second prompt 'What's the current price of AAPL?'. Emits get_stock_price tool call to exercise a DIFFERENT tool through the same wildcard renderer. turnIndex:2 means exactly two prior assistant turns (Tokyo emit + Tokyo narrate) have happened, the AAPL prompt has just arrived, and no AAPL tool-call has been emitted yet. The narration sibling above (turnIndex:3) fires after this emit produces its assistant tool-call message.",
"match": {
"userMessage": "Quote AAPL through the wildcard renderer",
"turnIndex": 2,
"context": "claude-sdk-typescript"
},
"response": {