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
Pythonlangsmith_runtime_overridesRuntimeOverrides
Class●Since v0.7

RuntimeOverrides

Copy
RuntimeOverrides(
    self,
    aio_to_thread: Optional[AioToThread] = None,
)

Constructors

Attributes

View source on GitHub

Parameters

NameTypeDescription
aio_to_threadOptional[AioToThread]
Default:None

Custom async-to-thread implementation, with signature async def (default_aio_to_thread, ctx, func, /, *args, **kwargs). default_aio_to_thread is LangSmith's default implementation, which the override can call to fall back to default behavior (e.g., when outside a constrained runtime context). ctx is the contextvars.Context LangSmith wants func to run inside; tracing state will be read back from this Context after the call. Override for runtimes like Temporal that don't support asyncio.run_in_executor.

constructor
__init__
NameType
aio_to_threadOptional[AioToThread]
attribute
aio_to_thread: aio_to_thread

Overrides for LangSmith runtime behavior.

This class allows overriding default async implementations for environments that don't support certain asyncio features (e.g., Temporal doesn't support run_in_executor).

Example:

import langsmith import contextvars

async def my_aio_to_thread( default_aio_to_thread, ctx, func, /, *args, **kwargs ): # Custom implementation return ctx.run(func, *args, **kwargs)

langsmith.set_runtime_overrides(aio_to_thread=my_aio_to_thread)

Reset to defaults

langsmith.set_runtime_overrides()