thought_signature #13638
|
Hello, With ai-proxy, since the OpenAI-compatible API does not expose an equivalent field, the gateway cannot currently generate or reconstruct this value automatically during request translation. Supporting this would require provider-specific state management within the gateway to capture the @dosu, how can we move forward? |
Replies: 2 comments 1 reply
|
Hey @mohamedDev, You've correctly identified the core challenge — the ai-proxy plugin is stateless by design, processing each request independently with no session-level context preserved between calls [1]. There's no mechanism today to capture a field like Here are the potential paths forward: 1. Client-side management (workaround, works today) 2. Provider-specific hook in the newer architecture 3. Feature request for stateful session support If you'd like to move this forward as a feature, I'd suggest opening a GitHub issue describing the use case (Gemini tool calls requiring In the meantime, option 1 (client-side management) is the most practical path. To reply, just mention @dosu. Docs are dead. Just use Dosu. |
|
Hi @mohamedDev, no gateway-side state is needed here, and I could not reproduce a gap in APISIX. Two clarifications first:
Environment
Routeroutes:
- uri: /chat
plugins:
ai-proxy:
provider: gemini
auth:
header:
Authorization: "Bearer $GEMINI_API_KEY"
#ENDStep 1: tool call through APISIX, signature comes backcurl -s http://127.0.0.1:9080/chat -H 'Content-Type: application/json' -d '{
"model": "gemini-3-flash-preview",
"messages": [{"role":"user","content":"What is the weather in Kuala Lumpur right now? You must use the get_weather tool."}],
"tools": [{"type":"function","function":{"name":"get_weather","description":"Get current weather for a city",
"parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}]
}'Response (HTTP 200): {
"id": "GQ96apaKJJXIjuMP-N2s2Q4",
"model": "gemini-3-flash-preview",
"choices": [{
"finish_reason": "tool_calls",
"index": 0,
"message": {
"role": "assistant",
"tool_calls": [{
"extra_content": {
"google": { "thought_signature": "EuYCCuMCARFNMg9ubbt9iH0M...<truncated>" }
},
"function": { "arguments": "{\"city\":\"Kuala Lumpur\"}", "name": "get_weather" },
"id": "3qslm5ut",
"type": "function"
}]
}
}]
}Identical shape to calling Google directly (verified as a control). With Step 2: turn 2 through APISIX with the signature echoed, workscurl -s http://127.0.0.1:19080/chat -H 'Content-Type: application/json' -d '{
"model": "gemini-3-flash-preview",
"messages": [
{"role":"user","content":"What is the weather in Kuala Lumpur right now? You must use the get_weather tool."},
{"role":"assistant","tool_calls":[{"id":"3qslm5ut","type":"function",
"function":{"name":"get_weather","arguments":"{\"city\":\"Kuala Lumpur\"}"},
"extra_content":{"google":{"thought_signature":"EuYCCuMCARFNMg9ubbt9iH0M...<full value from step 1>"}}}]},
{"role":"tool","tool_call_id":"3qslm5ut","content":"{\"temp_c\": 31, \"condition\": \"thunderstorm\"}"}
],
"tools": [{"type":"function","function":{"name":"get_weather","description":"Get current weather for a city",
"parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}]
}'Response (HTTP 200): Step 3: same request with
|
Hi @mohamedDev, no gateway-side state is needed here, and I could not reproduce a gap in APISIX. Two clarifications first:
generateContentformat. Thegeminiprovider proxies to Google's own OpenAI-compatible endpoint (/v1beta/openai/chat/completions).tool_calls[].extra_content.google.thought_signature, and the client sends them back unchanged in the next request's history. See https://ai.google.dev/gemini-api/docs/openaiEnvironment
apache/apisix:3.17.0-debian, standalone mode), gateway on:9080