How does the AI Bot handoff actually handle session state when triggered from a Studio SNIPPET action?

How does the AI Bot handoff actually handle session state when triggered from a Studio SNIPPET action? The outbound flow needs to push a structured context object to the /api/v2/ai/bots/{botId}/sessions endpoint before the call bridges. Studio builds the payload step by step. First, it grabs the caller email from interaction attributes. Then a SNIPPET action appends the last three transaction IDs using context.transactions.push({id: tx.id, score: parseFloat(tx.conf)}). The trace output shows the JSON looks clean.

The handoff node drops a 422 Unprocessable Entity straight from the AI service. The response points to a schema mismatch in the context block. Specifically, the intent_history array expects a confidence_score float, but the script keeps injecting strings. We’ve tried casting them inline. The bot endpoint still rejects it.

The Studio instance is running 24.2.3 in UK2. Architect definitions match the payload structure exactly. Direct Postman requests to the same endpoint work fine. It’s only the SNIPPET action inside the flow that mangles the types. The trace logs show the object gets stringified twice before the HTTP request fires. Not sure if the action auto-serializes JSON objects or if the outer quotes need stripping manually. The debug panel won’t show anything when the node fails. We don’t see the raw payload in the trace.

Checking the bot session API docs again. The confidence_score field is strictly typed. Maybe the SNIPPET action forces everything to a string during the variable assignment phase. The script now includes explicit type checks. The flow still fails at the exact same node. The error payload stays identical.

{
 "error_code": "422",
 "message": "Invalid context structure for bot session initialization",
 "details": [
 "context.intent_history[0].confidence_score: expected type FLOAT, got STRING",
 "context.metadata.last_transaction: exceeds maximum length of 256 characters"
 ]
}