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
Pythonlangsmithutilsget_tracer_agent_environment
Function●Since v0.14

get_tracer_agent_environment

Copy
get_tracer_agent_environment() -> Optional[str]
View source on GitHub

Get the agent environment for a LangSmith tracer.

Experimental: in beta and enabled per workspace. A workspace without agent addressing rejects the runs, so tracing is lost rather than falling back to a project.

Must be one of local, development, staging or production -- matched case-insensitively, surrounding space ignored. The endpoint rejects anything else rather than defaulting it, so a near miss like prod fails the whole batch.

Read from LANGSMITH_AGENT_ENVIRONMENT only. Unlike most LangSmith variables it has no LANGCHAIN_ alias, so that the newer namespace is the only one to learn for this. There is also no default -- an agent-addressed run must name its environment.

Read once per process and cached; call .cache_clear() to re-read.