fix: clear stale tool state in completions handler to prevent hang
Tool definitions stored in MitmStore from /v1/responses requests were persisting and getting injected into /v1/chat/completions requests. This caused Gemini to return functionCalls instead of text, and since the completions handler has no function call handling logic, it would poll forever waiting for text that never came. Fix: clear active_tools, active_tool_config, and has_active_function_call at the start of handle_completions. Also add clear_active_function_call() method to MitmStore.
This commit is contained in:
@@ -78,6 +78,12 @@ pub(crate) async fn handle_completions(
|
||||
}
|
||||
};
|
||||
|
||||
// Clear any stale tool definitions from other endpoints (e.g. /v1/responses)
|
||||
// to prevent them leaking into completions requests. The completions endpoint
|
||||
// does not support our custom tool call flow, so tools must never be injected.
|
||||
state.mitm_store.clear_tools().await;
|
||||
state.mitm_store.clear_active_function_call();
|
||||
|
||||
let token = state.backend.oauth_token().await;
|
||||
if token.is_empty() {
|
||||
return err_response(
|
||||
|
||||
Reference in New Issue
Block a user