class documentation

Factory that produces independent root _ReplaySafeRunTree instances with no parent link.

When add_temporal_runs=False and no parent was propagated via headers, @traceable functions still need something in the LangSmith tracing_context to call create_child() on — otherwise they cannot create _ReplaySafeRunTree children at all and instead default to creating generic RunTree``s, which are not replay safe. This class fills that role: it sits in the context as the nominal parent so ``@traceable has a create_child() target.

However, create_child() deliberately creates fresh RunTree instances with no parent_run_id. This means every child appears as an independent root run in LangSmith rather than being nested under a phantom parent that was never meant to be visible.

post(), patch(), and end() all raise RuntimeError because this object is purely internal scaffolding — it must never appear in LangSmith. If any of these methods are called, it indicates a programming error.

Method __init__ Create a root factory with the given LangSmith client.
Method create_child Create a root _ReplaySafeRunTree (no parent_run_id).
Method end Factory must never be ended.
Method patch Factory must never be patched.
Method post Factory must never be posted.

Inherited from _ReplaySafeRunTree:

Method __getattr__ Delegate attribute access to the wrapped RunTree.
Method __setattr__ Delegate attribute setting to the wrapped RunTree.
Method to_headers Delegate to the wrapped RunTree's to_headers.
Method _inject_deterministic_ids Inject deterministic run_id and start_time in workflow context.
Method _submit Submit work to the background executor.
def __init__(self, *, ls_client: langsmith.Client, executor: ThreadPoolExecutor, session_name: str | None = None, replicas: Sequence[WriteReplica] | None = None): (source)

Create a root factory with the given LangSmith client.

def create_child(self, *args: Any, **kwargs: Any) -> _ReplaySafeRunTree: (source)

Create a root _ReplaySafeRunTree (no parent_run_id).

Creates a fresh RunTree(...) directly (bypassing self._run.create_child) so children are independent root runs with no link back to the factory.

def end(self, **kwargs: Any) -> NoReturn: (source)
def patch(self, *, exclude_inputs: bool = False) -> NoReturn: (source)
def post(self, exclude_child_runs: bool = True) -> NoReturn: (source)