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

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithrun_helpersget_current_run_tree
Function●Since v0.14

get_current_run_tree

Copy
get_current_run_tree() -> Optional[run_trees.RunTree]

Used in Docs

  • Access the current run (span) within a traced function
  • Cost tracking
  • Implement distributed tracing
  • Trace LangChain agents (Python and JS/TS)
  • Trace with OpenTelemetry
View source on GitHub

Get the current run tree.

Uses a weakref-based lookup to avoid memory leaks from captured contexts. The RunTree may return None if it has been garbage collected.