Skip to content

Support timeout and cancellation for session turns #156

Description

@overlord-letta

Summary

runTurn() does not appear to support a per-turn timeout or AbortSignal. Consumers that need bounded runtime behavior have to wrap runTurn()/send() in Promise.race() and then close the session manually.

Proposed surface

Support timeout/cancellation at the turn level, for example:

await session.runTurn(message, { timeoutMs: 120_000 })
await session.runTurn(message, { signal })

The same cancellation story should ideally apply to send() plus stream() flows.

Why this matters

Consumers often need to distinguish:

  • a turn that is still running,
  • a turn that timed out locally,
  • a transport/request timeout,
  • a runtime failure,
  • a user-initiated cancellation.

External Promise.race() wrappers lose that structure and can leave the SDK/session doing work unless the caller remembers to close or abort the session.

Acceptance criteria

  • runTurn() supports either timeoutMs, AbortSignal, or both.
  • Timeout/cancellation produces a typed or at least documented terminal outcome.
  • The SDK cleans up stream listeners/session state after timeout/cancellation.
  • Examples show the recommended pattern for long-running cloud turns.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions