Fix: add watchdog timer to unblock Gemini when OpenClaw tool call stalls#51
Open
kbaker827 wants to merge 1 commit intoIntent-Lab:mainfrom
Open
Fix: add watchdog timer to unblock Gemini when OpenClaw tool call stalls#51kbaker827 wants to merge 1 commit intoIntent-Lab:mainfrom
kbaker827 wants to merge 1 commit intoIntent-Lab:mainfrom
Conversation
Tool calls involving web search or slow external services could leave Gemini stuck in the "execute" state indefinitely. The URLSession has a 120s hard timeout, but that's long enough to make the conversation feel completely frozen. Race the delegate call against a 60s watchdog using withTaskGroup. The first result wins and cancels the other child task. If the watchdog fires, Gemini receives a clear timeout failure and can speak an apology instead of hanging silently. Fixes Intent-Lab#12 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Gemini delegates a task that involves a slow OpenClaw skill (web search, sending a message to an external service, etc.), the conversation freezes. The UI shows Running: execute... and Gemini never speaks again. The underlying cause is that there is no per-call deadline — the conversation just waits for the 120s URLSession hard timeout, which is far too long for a voice interaction.
Fixes #12
Solution
Race the
delegateTaskcall against a 60-second watchdog insidewithTaskGroup. The first child to finish wins, the other is cancelled immediately:If the gateway responds in time, the watchdog task is cancelled and no behaviour changes. If the gateway stalls, Gemini receives a clear failure message after 60 seconds and can speak an apology, keeping the conversation alive.
Test plan
🤖 Generated with Claude Code