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

Rule

Copy
Rule()

Bases

TypedDict

Constructors

Attributes

View source on GitHub
constructor
__init__
NameType
nameRequired[str]
awsRuleAws
azureRuleAzure
descriptionstr
enabledbool
env_varsDict[str, str]
gcpRuleGcp
headersIterable[RuleHeader]
match_headersSequenceNotStr[str]
match_hostsSequenceNotStr[str]
match_pathsSequenceNotStr[str]
match_portint
match_schemeLiteral['https']
relay_idstr
rewriteRuleRewrite
typestr
attribute
name: Required[str]
attribute
aws: RuleAws
attribute
azure: RuleAzure
attribute
description: str

Description says what this rule lets the sandbox reach, so an agent driving the sandbox can be told its capabilities. At most 1024 characters.

attribute
enabled: bool
attribute
env_vars: Dict[str, str]

EnvVars are plaintext env vars set for every command in the sandbox while this rule is enabled. Use them for tools that refuse to run unless a credential env var is present (e.g. gh needs GH_TOKEN) even though this rule injects the real credential on the wire — set a dummy value here so the command starts. Explicit per-sandbox env_vars win over these, and provider-managed (AWS/GCP) vars win over both.

attribute
gcp: RuleGcp
attribute
headers: Iterable[RuleHeader]
attribute
match_headers: SequenceNotStr[str]

MatchHeaders restricts a header injection or rewrite rule to requests carrying every listed header, each written "name: value" with a lowercase name and an exact value. Pair with headers of the same name to swap a placeholder the sandbox sends (e.g. "authorization: Bearer account-b") for a real credential, so one host can serve several accounts. Rules are evaluated in order and the first match wins.

attribute
match_hosts: SequenceNotStr[str]

MatchHosts lists the hosts a header injection, rewrite, or relay rule covers.

AWS and GCP rules match their provider's hosts built in; there MatchHosts optionally narrows them to the listed hosts (e.g. "sts.amazonaws.com", "bigquery.googleapis.com"), and when empty the rule covers every host the provider can authenticate. A host no rule covers is passed through without TLS interception. Azure rules do not accept it. A relay rule may also list IP addresses and CIDR blocks (10.0.0.0/8), which match connections the sandbox makes to an IP address rather than a name.

attribute
match_paths: SequenceNotStr[str]

MatchPaths restricts a header injection or rewrite rule to requests whose path matches one of the patterns, so one host can use a different credential per route. The path excludes the query string. A pattern is an exact path (/v1/runs); a prefix, written as the prefix followed by a slash and * or **, which matches any path starting with that prefix (the prefix /v1 also matches /v10); a suffix, written as *, a slash, and then the ending, which matches any path that ends with that text (the ending runs also matches /v1/xruns); or * alone for every path. A wildcard in the middle of a path is not supported. An empty list matches every path. A request whose path is not canonical (a . or .. segment, an empty segment such as //, a backslash, or a percent-encoded slash, backslash, or dot) matches no pattern. Rules are evaluated in order and the first match wins. Rejected on aws, gcp, azure, and relay rules.

attribute
match_port: int
attribute
match_scheme: Literal['https']
attribute
relay_id: str

RelayID is the ID of the LangSmith relay (a connection of kind relay) that carries connections to match_hosts when type is relay. Those connections leave from the relay's connector, and its network and IP, instead of the sandbox host. Access control still applies first, the first enabled matching relay rule wins, and a matched host never falls back to a direct connection.

attribute
rewrite: RuleRewrite
attribute
type: str

Type selects the rule action; attribution adds up to 16 literal plaintext X- metadata headers to every proxy-handled HTTP(S) destination, independently of credential rules. At most one attribution rule is allowed, without matching, provider, relay, rewrite or environment fields.