Addresses that name where runs are sent.
Addressing runs to an address is enabled per workspace. A workspace without it rejects the runs, so tracing is lost rather than falling back to a project. This API may change without notice.
An address is a plain string, lrn:agents/{id}/environments/{environment}. The
constructors here validate one and return it as an Address; anywhere an
address is accepted, any str is validated the same way. The environment is
one of local, development, staging or production, and is always
rendered lowercase.
Example:
import langsmith as ls
support = ls.address.agent("customer-support", "production")
@ls.traceable(address=support)
def handle(order): ...
with ls.tracing_context(
address="lrn:agents/customer-support/environments/staging"
):
handle(order)(beta) A validated address string.
(beta) Build the address of an agent's environment.
(beta) Validate an address string, lowercasing its environment.
Only agent addresses, lrn:agents/{id}/environments/{environment}, exist.
(beta) Read the address named by the LANGSMITH_AGENT_* env vars.
Reads LANGSMITH_AGENT_ID and LANGSMITH_AGENT_ENVIRONMENT, and returns
None if neither is set.
Return each LANGSMITH_AGENT_* env var an address reads, with its value.
The LANGSMITH_AGENT_* / project env vars can't address a run.
Raised for half an address, an invalid one, or an address beside a project.
Tracing entry points (@traceable, trace, tracing_context,
create_run) catch it, log it and leave the call untraced, so a bad
environment never breaks the code being traced. Explicit ingestion calls
(batch_ingest_runs, multipart_ingest) let it raise for runs that name no
destination, rather than drop part of a batch the caller built.
Generic utility functions.