new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

LangChain · Deep Agents · all subjects

streaming & monitoring

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

Slash command /trace

The /trace command opens the current thread in LangSmith.

Enable LangSmith tracing with /auth command

Run /auth and add your LangSmith API key to enable LangSmith tracing. Tracing is enabled on the next launch and persists across sessions.

LangSmith configuration in ~/.deepagents/.env

To customize the LangSmith project name or configure tracing without the TUI, add keys to ~/.deepagents/.env so tracing is enabled in every session without per-shell exports: LANGSMITH_TRACING=true, LANGSMITH_API_KEY=lsv2_..., DEEPAGENTS_CODE_LANGSMITH_PROJECT=deepagents-code (project for Deep Agents Code's own traces; defaults to "deepagents-code").

DEEPAGENTS_CODE_LANGSMITH_PROJECT scope

Use DEEPAGENTS_CODE_LANGSMITH_PROJECT to name the project that receives Deep Agents Code's own traces. It is scoped to Deep Agents Code, so it is not affected by a LANGSMITH_PROJECT set in a project's .env (which routes that project's application traces).

Override LangSmith project for directory

To override the LangSmith project for a specific working directory, add DEEPAGENTS_CODE_LANGSMITH_PROJECT to a .env in that directory.

Shell environment variables take precedence over .env

Shell exports always take precedence over .env values for LangSmith configuration.

Agent traces vs shell-command traces in LangSmith

Deep Agents Code can produce two kinds of LangSmith traces: Agent traces are Deep Agents Code's own model calls, tool calls, orchestration, and middleware. Shell-command traces are traces emitted by code that Deep Agents Code runs for you in a shell, such as tests, scripts, or a local LangGraph app.

Separate agent traces from app traces with DEEPAGENTS_CODE_LANGSMITH_PROJECT

To send Deep Agents Code's own traces to a dedicated project, set DEEPAGENTS_CODE_LANGSMITH_PROJECT to a project name (e.g., "deepagents-code"). Then configure LANGSMITH_PROJECT for your application traces (e.g., "customer-support-agent"). Deep Agents Code's own reasoning and tool-use traces go to the DEEPAGENTS_CODE_LANGSMITH_PROJECT project, while app traces go to LANGSMITH_PROJECT.

DEEPAGENTS_CODE_LANGSMITH_REPLICA_PROJECTS for dual-write

To mirror agent traces to a second LangSmith project, set DEEPAGENTS_CODE_LANGSMITH_REPLICA_PROJECTS. When set and tracing is active, each agent run is written to both the primary project (DEEPAGENTS_CODE_LANGSMITH_PROJECT, or "deepagents-code" by default) and the project you name here. Leave the variable unset to write to a single project as usual.

LangSmith project link display

When configured, Deep Agents Code displays a status line with a link to the LangSmith project. In supported terminals, click the link to open it directly. You can also use /trace to print the URL and open it in your browser.

LangSmith observability and monitoring

As you add tools, subagents, and backends, use LangSmith to trace how each piece behaves together. Follow the observability quickstart to get set up, and see Going to production for deployment on LangSmith. LangSmith Engine monitors your traces, detects issues, and proposes fixes.

Frontend SDK support for Deep Agent subagent streaming

LangChain frontend SDKs go beyond flat chat transcripts by treating subagents as first-class stream entities. Subagents have their own status, messages, tool-call metadata, and results, allowing the UI to show delegation, progress, errors, and final synthesis without asking users to read interleaved tokens from every worker.

Real-time file sync with tool messages

Watch the stream's messages for ToolMessage instances from file-mutating tools. When write_file or edit_file completes, refresh that specific file. When execute completes, refresh everything since a shell command could modify any file. Use a processedIds Set to avoid processing the same tool call twice.

File-mutating tools set for real-time sync

The tools that trigger file refreshes are: write_file (refresh single file), edit_file (refresh single file), and execute (refresh tree and all files).

Changed files detection pattern

Before each agent run, snapshot the current file contents. After files refresh, compare against the snapshot to identify which files changed. When a user selects a changed file, default to the diff view.

LangSmith tracing setup

To enable LangSmith tracing for agent execution visibility, sign up at smith.langchain.com, create an API key, and set environment variables LANGSMITH_TRACING=true and LANGSMITH_API_KEY.

Deep Agents streaming support

Deep Agents have built-in streaming for real-time updates from agent execution using LangGraph. This allows observation of output progressively and review of agent and subagent work including tool calls, tool results, and LLM responses.

Event streaming in Deep Agents

Event streaming exposes agent runs as typed projections for messages, tool calls, values, and output. Deep Agents add stream.subagents so each delegated task gets its own handle with independent message, tool-call, and nested subagent streams.

Give your agent this brain