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:
@@ -252,6 +252,11 @@ impl MitmStore {
|
||||
self.has_active_function_call.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
/// Force-clear the active function call flag (used to reset stale state).
|
||||
pub fn clear_active_function_call(&self) {
|
||||
self.has_active_function_call.store(false, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
/// Check if there are pending function calls for a cascade.
|
||||
pub async fn has_pending_function_calls(&self, cascade_id: &str) -> bool {
|
||||
let pending = self.pending_function_calls.read().await;
|
||||
|
||||
Reference in New Issue
Block a user