new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

LangChain · Agents · all subjects

langsmith integration

23 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

LangSmith Gateway initialization flag

Use the `--gateway` flag when initializing an agent project to scaffold it for Gateway use from the start: `mda init my-agent --gateway`.

Python LangSmith Gateway example

To configure LangSmith Gateway with ChatOpenAI in Python: import `os` and `ChatOpenAI` from `langchain_openai`. Set the api_key from the `LANGSMITH_GATEWAY_API_KEY` environment variable and base_url to `"https://gateway.smith.langchain.com/v1"`. Pass these to `ChatOpenAI(model="moonshotai/Kimi-K3", api_key=api_key, base_url=base_url)` and then to `define_deep_agent`.

JavaScript LangSmith Gateway example

To configure LangSmith Gateway with ChatOpenAI in JavaScript: import `defineDeepAgent` from `managed-deepagents` and `ChatOpenAI` from `@langchain/openai`. Set the apiKey from the `LANGSMITH_GATEWAY_API_KEY` environment variable and baseURL to `"https://gateway.smith.langchain.com/v1"`. Pass these to `new ChatOpenAI({ model: "moonshotai/Kimi-K3", apiKey, configuration: { baseURL } })` and then to `defineDeepAgent`.

Monitor stage uses LangSmith observability

In the Monitor stage of the agent lifecycle, running agents are traced and monitored using LangSmith's observability features. This involves tracing requests and inspecting runs.

Govern stage enforces policies through LLM Gateway

In the Govern stage of the agent lifecycle, model access, spend, and data policies are enforced. This is done by routing calls through the LLM Gateway with spend and redaction policies.

LangSmith Engine connects lifecycle stages

LangSmith's Engine component connects the five stages of the agent lifecycle together, enabling integration between Build, Test, Deploy, Monitor, and Govern stages through UI and webhooks.

Agent Auth self-hosted configuration via environment variable

For self-hosted LangSmith instances, set the LANGSMITH_API_URL environment variable to point to the /api-host path: `export LANGSMITH_API_URL="https://your-langsmith-instance.com/api-host"`. Then initialize the client normally without additional parameters.

Agent Auth self-hosted configuration explicit Python

For self-hosted LangSmith in Python, pass both api_key and api_url to Client: `client = Client(api_key="you••••••ey", api_url="https://your-langsmith-instance.com/api-host")`.

Agent Auth self-hosted configuration explicit JavaScript

For self-hosted LangSmith in JavaScript, pass both apiKey and apiUrl to Client constructor: `const client = new Client({ apiKey: 'you••••••ey', apiUrl: 'https://your-langsmith-instance.com/api-host' });`.

OAuth provider callback URL for LangSmith Cloud

For LangSmith Cloud, set the OAuth provider callback URL to `https://smith.langchain.com/host-oauth-callback/{provider_id}` where provider_id is your unique provider identifier (e.g., 'github-local-dev').

OAuth provider callback URL for self-hosted LangSmith

For self-hosted LangSmith, set the OAuth provider callback URL to `https://{your-langsmith-instance}/host-oauth-callback/{provider_id}` where your-langsmith-instance is your instance URL and provider_id is your unique provider identifier.

Agent Auth authentication flow in LangGraph

When authentication is required during agent execution, the SDK throws an interrupt that pauses execution and presents the OAuth URL to the user. After the user completes OAuth authentication, the agent resumes execution from the point it left off.

Agent Auth token storage and refresh

Agent Auth automatically stores and refreshes OAuth tokens so that future uses of the service by either the user or agent do not require an OAuth flow.

Agent Auth out-of-band OAuth flow JavaScript

For out-of-band OAuth flows outside LangGraph context, call `client.authenticate()` and check if status is 'pending'. If pending, provide authResult.authUrl to the user and use `client.waitForCompletion(authResult.authId)` to wait for completion.

Agent Auth troubleshooting 405 Method Not Allowed

If you receive a 405 Method Not Allowed error with self-hosted Agent Auth, ensure LANGSMITH_API_URL points to the /api-host path: `export LANGSMITH_API_URL="https://your-instance.com/api-host"`.

Agent Auth troubleshooting malformed OAuth callback URL

Ensure your OAuth provider's redirect URI matches your LangSmith instance URL exactly: `https://your-instance.com/host-oauth-callback/{provider_id}`.

Create OAuth provider in Agent Auth JavaScript

Use `client.createOAuthProvider()` with providerId, name, clientId, clientSecret, authUrl, and tokenUrl parameters to register an OAuth provider.

Agent Auth beta status

Agent Auth is in beta and under active development. To provide feedback or use this feature, reach out to the LangChain team on the forum.

Authenticate from agent in Agent Auth Python

Call `client.authenticate()` with provider, scopes, and user_id parameters. Optionally specify agent_id to scope tokens to a specific agent. By default, tokens are scoped to the calling agent using the Assistant ID parameter.

Agent Auth installation for Python

To install Agent Auth for Python, use `pip install langchain-auth` or `uv add langchain-auth`.

Agent Auth installation for JavaScript

To install Agent Auth for JavaScript, use `npm install @langchain/auth`.

Initialize Agent Auth client in Python

Import Client from langchain_auth and initialize it with an API key: `client = Client(api_key="you••••••ey")`.

Initialize Agent Auth client in JavaScript

Import Client from @langchain/auth and initialize it with an API key: `const client = new Client({ apiKey: 'you••••••ey' });`.

Give your agent this brain