Skip to content

streamText fullStream iteration has no iteration-level timeout (can hang the agent) #515

@lmorchard

Description

@lmorchard

Summary

In WebAgent.generateAndProcessAction, the LLM call passes a timeout to streamText(...), but the response is consumed with:

// packages/core/src/webAgent.ts (~line 1002 / 1017)
const streamResult = streamText({ ...this.providerConfig, timeout: this.llmProviderTimeoutMs, abortSignal: this.abortSignal, ... });
for await (const part of streamResult.fullStream) { ... }

The timeout/abortSignal cover the initial request, but the for await (... fullStream) iteration itself is not independently bounded. If the provider stalls mid-stream (partial data then silence, or a zombie TCP connection with no FIN), the loop can hang indefinitely.

Why it matters

This is a second potential source of indefinite agent freezes (distinct from the browser-side hang fixed in #511). It would present similarly: no progress, process idle on a socket read.

Suggested fix

Bound the stream consumption — e.g. an inactivity/overall timeout via Promise.race around the iteration, or an AbortController tied to a watchdog that fires if no stream event arrives within a window. Verify the AI SDK's abortSignal actually interrupts an in-flight for await on this provider.

Context

Flagged while diagnosing #511. Not the confirmed cause there (that was browser-side), but the same indefinite-hang class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions