Skip to content

Conversation

@cdnsteve
Copy link
Member

@cdnsteve cdnsteve commented Jan 5, 2026

Summary

  • Wrap async for loop with asyncio.timeout() in _execute_with_streaming() to prevent indefinite hangs
  • Increase default timeout from 300s to 7200s (2 hours) for long-running tasks
  • Add graceful TimeoutError handling that returns partial results

Problem

Tasks were hanging indefinitely when the Claude Agent SDK generator didn't signal completion even though work was done. Files would be created but commits never happened because the generator loop never terminated.

Test plan

  • All 47 existing tests pass
  • New test_execute_with_timeout test verifies timeout behavior
  • Timeout returns partial results (work done before hang is preserved)

The async for loop over query() had no timeout, causing tasks to hang
indefinitely when the Claude Agent SDK generator didn't signal completion
even though work was done (files created but never committed).

Changes:
- Wrap async for loop with asyncio.timeout() in _execute_with_streaming()
- Increase default timeout from 300s to 7200s (2 hours) for long tasks
- Add TimeoutError handling to return partial results gracefully
- Add test for timeout behavior

Fixes hung tasks in Sugar autonomous execution where generators never
terminated after Claude finished using tools.
@cdnsteve cdnsteve merged commit 68ffe10 into develop Jan 5, 2026
14 checks passed
@cdnsteve cdnsteve deleted the bugfix/async-query-timeout branch January 5, 2026 15:36
@cdnsteve cdnsteve mentioned this pull request Jan 7, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants