Skip to content

Enforce LLM timeout configuration that was previously dead code#20

Merged
Iron-Ham merged 1 commit intomainfrom
fix/llm-timeout-enforcement
Jan 7, 2026
Merged

Enforce LLM timeout configuration that was previously dead code#20
Iron-Ham merged 1 commit intomainfrom
fix/llm-timeout-enforcement

Conversation

@Iron-Ham
Copy link
Owner

@Iron-Ham Iron-Ham commented Jan 7, 2026

Summary

The Configuration struct in FoundationModelsClient defined maxAttempts, requestTimeout, and retryDelay but these values were never used. The session.respond() call had no timeout wrapper, causing the tool to hang indefinitely if Apple Intelligence became unresponsive - this is the likely root cause of #14 where users had to reboot their Mac to recover.

Changes:

  • Wrap LLM generation calls in withTimeout() using Swift's withThrowingTaskGroup to race the operation against a timer
  • Implement exponential backoff on retries (30s → 60s → 120s by default)
  • Change default timeout from 20s to 30s for better first-attempt success rates
  • Make FoundationModelsClient conform to Sendable for Swift 6 strict concurrency
  • Fix unrelated test that was checking for non-existent prompt text

Test plan

  • Build passes with swift build
  • All 49 existing tests pass
  • Manual test: run scg generate with a large diff and verify timeout behavior
  • Manual test: verify exponential backoff by observing retry timing in verbose mode

Fixes #16

The Configuration struct defined maxAttempts, requestTimeout, and
retryDelay but these values were never used - session.respond() had
no timeout wrapper. This caused the tool to hang indefinitely if Apple
Intelligence became unresponsive (requiring Mac reboot to fix).

Now wraps LLM calls in withTimeout() using task groups that race the
operation against a timer. Implements exponential backoff on retries
(30s → 60s → 120s by default).

Also makes FoundationModelsClient Sendable-conformant and fixes an
unrelated test that checked for non-existent prompt text.

Fixes #16
@Iron-Ham Iron-Ham merged commit 62d39a9 into main Jan 7, 2026
1 check passed
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.

LLM timeout configuration is defined but never enforced

1 participant