LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithsandbox_ws_executereconnect_ws_stream
Function●Since v0.7

reconnect_ws_stream

Reconnect to an existing command over WebSocket.

Returns a tuple of (message_iterator, control), same as run_ws_stream. The iterator yields stdout, stderr, exit, and error messages. No 'started' message is sent on reconnection.

With the ring buffer reader server model, there is no replay/live phase distinction and no deduplication needed. The server reads from its ring buffer starting at the requested offsets and streams output from there. If the requested offset is older than the buffer's earliest data, the server sends from the earliest available offset.

Copy
reconnect_ws_stream(
  dataplane_url: str,
  api_key: Optional[str],
  command_id: str,
  *,
  stdout_offset: int = 0,
  stderr_offset: int = 0
) -> tuple[Iterator[dict], _WSStreamControl]
View source on GitHub