How to use Claude Code's Monitor tool: since 2.1.310 it watches logs on Bedrock and with telemetry off too, plus a hands-on pipe buffering test

Claude Code 2.1.310 makes Monitor and plugin monitors available on Bedrock, Vertex and Foundry, and when telemetry is turned off. We compare the changelog with older docs, check the SDK fields in a local 2.1.310 install (timeout capped at 1800000ms), and test the same log pipe both ways: without --line-buffered the first event takes 1.213 s, with it 0.009 s.

5 分钟阅读
How to use Claude Code's Monitor tool: since 2.1.310 it watches logs on Bedrock and with telemetry off too, plus a hands-on pipe buffering test

If you wanted Claude Code to keep an eye on logs or CI while it worked, you used to open a second terminal for tail -f, or have the model run it in the background with Bash and report once it finished. The changelog for 2.1.310 (2026-10-23) states that the Monitor tool and plugin monitors now work on Bedrock, Vertex and Foundry, and also when telemetry or nonessential traffic is disabled; long foreground sleeps are now blocked in those environments too.

This matters a lot for anyone who uses a third-party API or turns off telemetry in settings, because many third-party write-ups still say "Monitor is off by default and unavailable on Bedrock or with telemetry off." We compared the official changelog, concept docs that are still circulating, and the SDK type definitions bundled with the Claude Code 2.1.310 installed on our machine, and ran a pipe buffering comparison on Linux.

The bottom line first:

  • Official changelog: since 2.1.310, Monitor and plugin monitors cover Bedrock, Vertex and Foundry, plus sessions with telemetry or nonessential traffic disabled.
  • CLI installed from npm: claude --version shows 2.1.310 (Claude Code); sdk-tools.d.ts contains complete MonitorInput / MonitorOutput definitions.
  • Timeout: the SDK sets a default of 300000ms, and anything above 1800000ms (30 minutes) is capped. The 3600000ms (1 hour) quoted in many reposted docs does not match the current type definitions.
  • Local pipe test: with the same 8 lines of progress output, when grep runs without --line-buffered, the first event takes 1.213 s to arrive; with it, the first one arrives in 0.009 s, then one roughly every 0.15 s.
  • Monitor is for "notify me on every line." If you only want to wait for a process to finish, use Bash's run_in_background (that is exactly what the CLI's built-in description says).

Create an API Key →

What Monitor does

In one sentence: it starts a background watch script, and every line of stdout becomes a notification in the conversation, while you keep editing code in the main session. It is not "tell me when the command finishes"; Bash in the background handles that.

Typical uses:

  • watching deploy.log for Error / deployed
  • polling CI or PR status every few dozen seconds
  • checking whether new files appear in a build directory, or whether a training log has reached a certain step

What 2.1.310 changed (compared with the old docs)

Concept pages that are still circulating (for example, community write-ups of Tool-Monitor) list roughly these limits:

Off by default (server-side feature flag). Unavailable on Amazon Bedrock, Google Cloud, and Microsoft Foundry. Off when DISABLE_TELEMETRY or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is set.

But the Claude Code changelog lists this under Added for 2.1.310:

Added the Monitor tool and plugin monitors on Bedrock, Vertex, and Foundry, and when telemetry or nonessential traffic is disabled; long foreground sleeps are now blocked there too

In other words, if you assumed Monitor "just isn't there" because you had set DISABLE_TELEMETRY=1 or were using a cloud provider endpoint, upgrade to 2.1.310 and try again. On the enterprise side, the same version also added Cloud sessions / Remote Control permissions to custom roles; that is a separate topic not covered here.

Checking locally: version and SDK fields

On Linux we ran:

bash
npm install -g @anthropic-ai/claude-code@2.1.310
claude --version
# 输出:2.1.310 (Claude Code)

Opening sdk-tools.d.ts in the package, here is an excerpt of Monitor's input and output (field names as in the installed package):

typescript
export interface MonitorInput {
  description: string;           // 通知上显示的短标签
  timeout_ms: number;            // 默认 300000;>1800000 会被封顶
  command?: string;              // 每行 stdout = 一条事件
  ws?: { url: string; protocols?: string[] }; // 与 command 互斥
}

export interface MonitorOutput {
  taskId: string;
  timeoutMs: number;             // persistent 时为 0
  persistent?: boolean;          // 用 TaskStop 或会话结束来停
}

The tool description the CLI gives the model also includes a very practical boundary (confirmed against strings in the 2.1.310 binary):

Use the Monitor tool to stream events from a background process (each stdout line is a notification). For one-shot "wait until done," use Bash with run_in_background instead.

How to use it: just tell Claude in plain language

First point Claude Code at your Key. For third-party setups, see Claude Code third-party API setup. An example global ~/.claude/settings.json:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.aicodewith.ai",
    "ANTHROPIC_AUTH_TOKEN": "你的 API Key"
  },
  "model": "claude-sonnet-5-5"
}

In your project, just say:

text
盯着 ./logs/dev.log,出现 Error、FAILED、Traceback 或 Listening on 就告诉我。过滤器记得加 grep --line-buffered。

The model will usually put together a command along these lines (illustrative):

bash
tail -F ./logs/dev.log | grep -E --line-buffered \
  "Listening on|Traceback|Error|FAILED|Killed|OOM"

Key points:

  • Put both the success and failure keywords in the filter: if you only watch for deployed and the process crashes, you just see silence, which you cannot tell apart from "still running."
  • For long session-level watching, use persistent and stop it with TaskStop; the default timer is about 5 minutes.
  • If events come too thick and fast it gets stopped automatically; tighten the grep and start it again.
  • A WebSocket source (ws.url) and command are mutually exclusive; the URL must be ASCII ws:// / wss://, and never put credentials in the URL.

Exclusive: why --line-buffered is a must

On our machine we used the same producer script (8 lines of progress plus a final line deployed ok, with flush=True on each line and about 0.15 s between lines) to compare two grep commands:

PipeFirst event arrivesPace after thatTotal time
grep -E '…'1.213 s9 events bunched at the same momentAbout 1.21 s
grep -E --line-buffered '…'0.009 sAbout one every 0.15 sAbout 1.21 s

The total time is about the same, but what matters to Monitor is when each line becomes a notification. Without --line-buffered, the other end of the pipe may sit waiting on block buffering: the log has clearly reported an error, yet nothing happens in the conversation, which feels exactly like "the monitor is broken."

Choosing between MCP Tasks, Monitor and plain background Bash

NeedUseNotes
Wait for a command to finishBash + run_in_backgroundOne notification when it ends
Push every line as it happensMonitorSince 2.1.310 also works on cloud providers and with telemetry off
An MCP server running its own long taskMCP TasksThe task lives on the server side and can pause for an Elicitation

For workflows like security audits that start many sub-Agents, see Cloudflare security-audit skill, tested; that is a different kind of "parallel isolation," not Monitor.

FAQ

Still no Monitor after upgrading?

First check whether claude --version is ≥ 2.1.310. The stable channel and some Homebrew casks may lag behind npm's @anthropic-ai/claude-code. A third-party gateway only needs to support Messages tool calls; Monitor itself is a client-side tool and does not depend on whether the model "knows how to tail."

What is the maximum timeout?

Go by sdk-tools.d.ts in the 2.1.310 package: 5 minutes by default, capped at 30 minutes. If you need longer, use persistent + TaskStop.

Do events count as authorization?

No. Log lines and WebSocket frames are just data; they cannot be used to approve a file write or loosen the sandbox. This matches the security boundary for Channels and plugin monitors.

Create an API Key →