Skip to content

Stop sessions from hanging when the model provider stops responding - #56

Open
josephschorr wants to merge 1 commit into
mainfrom
bound-llm-calls
Open

josephschorr wants to merge 1 commit into
mainfrom
bound-llm-calls

Conversation

@josephschorr

Copy link
Copy Markdown
Member

A session could stay in Running indefinitely if the model provider stopped sending data partway through a response: the agent waited on it forever, and the session's time budget was never checked again.

Model calls now give up if a response goes silent for 5 minutes, or if the server takes more than 3 minutes to start responding. A stalled call is reported like any other provider error, so channel sessions offer the usual Retry. A call is also cut off when the session's time budget (maxDuration or sessionExpiration) runs out, and the session fails with BudgetExceeded as it would have between turns. Long responses that keep streaming are not affected.

Provider SDKs were built on their default HTTP clients, which have no
timeouts, and the runner sent with no deadline. A stream that went silent
on a live connection could block a turn indefinitely, holding the session
in Running past its maxDuration budget, because the budget was only
checked between turns.

- New pkg/agent/llm/llmhttp: one shared HTTP client with connect/TLS/
  response-header timeouts, HTTP/2 health pings, and a stream-idle abort
  (ErrStreamIdle after 5m with no body bytes). Every Anthropic and
  OpenAI-compatible SDK client is now built through anthropic.NewSDKClient
  or openaicompat.NewClient, which attach it; a guard test refuses bare
  SDK NewClient calls anywhere in pkg/, internal/ or cmd/.
- The runner bounds each provider call by the remaining time budget
  (maxDuration run-time or sessionExpiration, whichever is nearer), so a
  stuck call ends the session as BudgetExceeded instead of outliving it.
  A stream-idle abort flows through the existing provider-error path.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openagentprimitives Ignored Ignored Preview Nov 5, 2026 11:15pm UTC

Request Review

This branch has not been deployed

No deployments
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.

1 participant