westering

An offline policy lab for a graded stall rescue ladder. It reads recorded traces of agent work, detects looping and fixation stalls, and replays scripted scenarios against the ladder, recording which rung clears the stall.

Westering reads recorded traces of agent work and catches two stall shapes, looping and tool fixation, each with the span of steps that shows it. A graded ladder then answers a stall in a fixed order, a nudge, a sharper prompt, a smaller subtask, and a fork, and every scripted rescue prints as one JSON timeline. Everything runs offline against synthetic input.

The pages in this handbook are the same pages as the docs/ directory of the repository, and every output block in them was captured from a real run of the binary.

Install

Westering is a Rust command line tool, published on crates.io. Cargo builds it from source with Rust 1.88 or newer, and each release also carries prebuilt binaries.

From crates.io

cargo install westering --locked

This builds the latest published version and puts westering in the cargo bin directory, usually ~/.cargo/bin. With cargo-binstall installed, cargo binstall westering fetches the archive a release carries for the machine, where it carries one, instead of building from source. The section on prebuilt binaries below names those archives.

From a clone

git clone https://github.com/david-engelmann/westering.git
cd westering
cargo build --release

The binary lands at target/release/westering. A debug build with cargo build lands at target/debug/westering, which is the path every example in these docs uses.

From the main branch

cargo install --git https://github.com/david-engelmann/westering --locked

This builds the main branch, which can hold changes that no release carries yet, and puts westering in the cargo bin directory.

Prebuilt binaries

Westering builds and passes its test suite on Linux, macOS, and Windows.

Each release carries archives for macOS on Apple silicon and Intel, Linux on x86_64 and aarch64, and Windows on x86_64 as a zip holding westering.exe, with a SHA256SUMS file beside them. The Linux binaries are static musl builds, so they run on any Linux distribution whatever its C library version. Every archive carries a build provenance attestation, which gh attestation verify <archive> --repo david-engelmann/westering checks.

The install.sh script at the repository root downloads the archive for the current Linux or macOS machine over HTTPS, checks it against SHA256SUMS, runs the binary once, and installs it into $HOME/.local/bin. --to <dir> or WESTERING_INSTALL_DIR picks another directory, and --version <tag> or WESTERING_VERSION picks a release other than the latest.

curl -fsSLO https://raw.githubusercontent.com/david-engelmann/westering/main/install.sh
sh install.sh

On Windows, download the zip from the release page, compare the hash Get-FileHash -Algorithm SHA256 <zip> prints with the zip's line in SHA256SUMS, ignoring the case of the letters since Get-FileHash prints uppercase hex and SHA256SUMS holds lowercase, and put westering.exe on your PATH.

Check the install

An installed binary runs as westering from the path, and a build from a clone runs as ./target/debug/westering, the path the block below uses.

$ ./target/debug/westering --help
An offline policy lab for a graded stall rescue ladder. It reads recorded traces of agent work, detects looping and fixation stalls, and replays scripted scenarios against the ladder, recording which rung clears the stall.

Usage: westering <COMMAND>

Commands:
  detect     Run the stall detectors over a trace file or a tool call log
  import     Print the native trace a tool call log imports to
  intervene  Run a scripted sandbox session
  mcp        Serve the Model Context Protocol over standard input and output

Options:
  -h, --help     Print help
  -V, --version  Print version

As a Claude Code plugin

The repository is also a Claude Code plugin, which adds the Agent Skill and the MCP server to the client in one step. The plugin carries the skill and the MCP server but not the binary, so install the binary first.

claude plugin install westering --marketplace david-engelmann/westering

Inside a session the same step is /plugin install westering --marketplace david-engelmann/westering.

Command line reference

Westering has four subcommands. detect, import and intervene each print one JSON document to standard output and read only the files they are handed, and mcp serves detect and intervene as tools to an MCP client. The root also prints the version.

$ ./target/debug/westering --help
An offline policy lab for a graded stall rescue ladder. It reads recorded traces of agent work, detects looping and fixation stalls, and replays scripted scenarios against the ladder, recording which rung clears the stall.

Usage: westering <COMMAND>

Commands:
  detect     Run the stall detectors over a trace file or a tool call log
  import     Print the native trace a tool call log imports to
  intervene  Run a scripted sandbox session
  mcp        Serve the Model Context Protocol over standard input and output

Options:
  -h, --help     Print help
  -V, --version  Print version

detect

$ ./target/debug/westering detect --help
Run the stall detectors over a trace file or a tool call log

Usage: westering detect [OPTIONS] --trace <TRACE>

Options:
      --trace <TRACE>        Path to a trace file or a tool call log
      --format <FORMAT>      How to read the file [default: trace] [possible values: trace, openai, anthropic, auto]
      --progress <PROGRESS>  The rule that marks a logged call as progress, tool-result when not named [possible values: tool-result, call-result]
  -h, --help                 Print help

detect reads one trace file, runs the looping and tool fixation detectors over it, and prints the detections. The trace format page describes the input and the detectors page describes the rules.

--format names how the file is read. trace, the default, is the native trace format, openai and anthropic read a tool call log, and auto decides from the file. --progress names the rule that marks a logged call as progress, tool-result when it is not named, and it is refused beside the trace format. The importing agent logs page describes the formats and the rules.

$ ./target/debug/westering detect --trace examples/logs/openai_chat.json --format auto
{
  "detections": [
    {
      "detail": "call pattern of length 1 repeated 4 times with no progress",
      "evidence_span": {
        "end_step": 5,
        "start_step": 2
      },
      "pattern": [
        "search_files(path=\"src\", query=\"retry_limit\")"
      ],
      "shape": "looping",
      "trace_id": "openai_chat"
    }
  ],
  "trace_id": "openai_chat"
}

import

$ ./target/debug/westering import --help
Print the native trace a tool call log imports to

Usage: westering import [OPTIONS] --trace <TRACE>

Options:
      --trace <TRACE>        Path to a trace file or a tool call log
      --format <FORMAT>      How to read the file [default: auto] [possible values: trace, openai, anthropic, auto]
      --progress <PROGRESS>  The rule that marks a logged call as progress, tool-result when not named [possible values: tool-result, call-result]
  -h, --help                 Print help

import prints the native trace a trace file or a tool call log reads as, the document detect reads, in the same pretty form. Its --format defaults to auto, and its --progress is the one detect takes. Detect run on the printed document gives the detections it gives on the log, so an imported log can be kept and run again as a trace.

$ ./target/debug/westering import --trace examples/logs/openai_chat.json > target/imported.json && ./target/debug/westering detect --trace target/imported.json | grep -E '"(shape|start_step|end_step)"'
        "end_step": 5,
        "start_step": 2
      "shape": "looping",

intervene

$ ./target/debug/westering intervene --help
Run a scripted sandbox session

Usage: westering intervene [OPTIONS] --scenario <SCENARIO>

Options:
      --scenario <SCENARIO>  The scripted scenario to run [possible values: fixation-clears-on-nudge, loop-clears-on-nudge, loop-needs-fork, loop-needs-sharper, loop-needs-subtask, loop-never-clears]
      --fixtures <FIXTURES>  Path to a directory of recorded judgment fixtures
  -h, --help                 Print help

intervene runs one of the six committed scripted scenarios in a local sandbox and prints the session record. With --fixtures <dir> the session also consults recorded judgment answers, as the judgment fixtures page describes. Any other scenario name is refused.

$ ./target/debug/westering intervene --scenario no-such-scenario; echo "exit $?"
error: invalid value 'no-such-scenario' for '--scenario <SCENARIO>'
  [possible values: fixation-clears-on-nudge, loop-clears-on-nudge, loop-needs-fork, loop-needs-sharper, loop-needs-subtask, loop-never-clears]

For more information, try '--help'.
exit 2

mcp

$ ./target/debug/westering mcp --help
Serve the Model Context Protocol over standard input and output

Usage: westering mcp

Options:
  -h, --help  Print help

mcp serves detect and intervene as tools over the Model Context Protocol on standard input and output until its input ends, and then exits 0. The MCP server page describes the tools, the protocol versions, and a client configuration.

Version

$ ./target/debug/westering --version
westering 0.1.0

--version and -V print the package version at exit 0. They are read at the root alone, so westering detect -V is refused as an unexpected argument.

Exit codes

CodeMeaning
0The command ran and printed its document, or help or the version was printed
1An internal failure outside the tool's own refusals, such as a document nested past the reader ceiling, or a write failure on a large output
2A refusal, a malformed or unreadable trace, log or fixture file, an unknown scenario, or a malformed invocation
120Standard output could not take a small output, discovered when the output buffer is flushed at exit

Each code below was captured from a real run.

$ ./target/debug/westering detect --trace examples/looping_trace.json > /dev/null; echo "exit $?"
exit 0
$ ./target/debug/westering detect --trace target/missing_trace.json; echo "exit $?"
error: trace file cannot be read, target/missing_trace.json
exit 2
$ python3 -c "print('[' * 10000 + ']' * 10000)" > target/deep_trace.json && ./target/debug/westering detect --trace target/deep_trace.json; echo "exit $?"
error: trace file is nested too deeply, target/deep_trace.json
exit 1

Exit code 120 needs a standard output that refuses writes. A pipe whose reader has already closed is one.

$ python3 -c "import os, subprocess; r, w = os.pipe(); os.close(r); print('exit', subprocess.run(['./target/debug/westering', 'detect', '--trace', 'examples/looping_trace.json'], stdout=w).returncode)"
error: stdout: Broken pipe (os error 32)
exit 120

A refusal of a trace, log or fixture file prints exactly one line that starts with error: on standard error, and prints nothing to standard output. A malformed invocation, such as an unknown scenario name or a flag with no value, is refused by the argument parser, which prints its error line and then a usage hint, as the unknown scenario example above shows, also at exit status 2.

MCP server

westering mcp serves the detect and intervene commands as tools over the Model Context Protocol. It reads JSON-RPC 2.0 messages from standard input, one message per line, and writes one response line for each request to standard output. It reads only the files and directories a tool call names, never touches the network, and prints the same bytes for the same input.

Connect a client

Install the binary as the install page describes, so westering is on the path. Claude Code adds the server with one command.

claude mcp add westering -- westering mcp

The Claude Code plugin in this repository adds the server and the Agent Skill together. The plugin carries the skill and the MCP server but not the binary, so install the binary first.

claude plugin install westering --marketplace david-engelmann/westering

Inside a session the same step is /plugin install westering --marketplace david-engelmann/westering. The client names the plugin's server plugin:westering:westering, and its tools reach the agent as mcp__plugin_westering_westering__detect and mcp__plugin_westering_westering__intervene.

A client that reads an mcpServers configuration takes this entry.

{
  "mcpServers": {
    "westering": {
      "command": "westering",
      "args": ["mcp"]
    }
  }
}

A relative path in a tool call is read from the directory the client starts the server in.

The third session of An agent uses the skill gives Claude Code this server through --mcp-config. The client reports the server as connected with both tools, and the agent calls detect and then intervene.

Tools

ToolArgumentsResult
detectExactly one of trace, a trace document given inline, and path, a file path. Optional format and progressThe document westering detect prints
intervenescenario, one of the six scripted scenarios, and optional fixtures, a directory of recorded judgment fixturesThe session record westering intervene prints

format names how detect reads its input. trace, the default, is the native trace format. openai and anthropic read a tool call log, inline under the trace id inline or from a file under the file's name, and auto decides from the file and takes only path. progress names the rule that derives progress for a tool call log, tool-result by default or call-result, and it is refused beside the trace format.

A call that runs answers the document as structuredContent and one text block holding the document exactly as the command prints it. A refusal answers one text block holding the text of the error line the command prints, without its error: prefix, with isError set to true, so the model reads it and can correct the call. An argument the tool does not take, a missing or extra input, and a value outside its set are refused the same way.

A conversation

A client opens with initialize, sends the notifications/initialized notification, which gets no response, and calls tools. The third request below names a file that does not exist.

$ printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"example","version":"1.0.0"}}}' '{"jsonrpc":"2.0","method":"notifications/initialized"}' '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"detect","arguments":{"path":"examples/looping_trace.json"}}}' '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"detect","arguments":{"path":"examples/missing_trace.json"}}}' | ./target/debug/westering mcp
{"id": 1, "jsonrpc": "2.0", "result": {"capabilities": {"tools": {}}, "protocolVersion": "2025-11-25", "serverInfo": {"name": "westering", "version": "0.1.0"}}}
{"id": 2, "jsonrpc": "2.0", "result": {"content": [{"text": "{\n  \"detections\": [\n    {\n      \"detail\": \"call pattern of length 1 repeated 4 times with no progress\",\n      \"evidence_span\": {\n        \"end_step\": 4,\n        \"start_step\": 1\n      },\n      \"pattern\": [\n        \"grep(pattern=config, path=src)\"\n      ],\n      \"shape\": \"looping\",\n      \"trace_id\": \"trace-loop-001\"\n    }\n  ],\n  \"trace_id\": \"trace-loop-001\"\n}\n", "type": "text"}], "isError": false, "structuredContent": {"detections": [{"detail": "call pattern of length 1 repeated 4 times with no progress", "evidence_span": {"end_step": 4, "start_step": 1}, "pattern": ["grep(pattern=config, path=src)"], "shape": "looping", "trace_id": "trace-loop-001"}], "trace_id": "trace-loop-001"}}}
{"id": 3, "jsonrpc": "2.0", "result": {"content": [{"text": "trace file cannot be read, examples/missing_trace.json", "type": "text"}], "isError": true}}

Protocol versions

The server answers clients of both protocol eras from one process and keeps no state between lines.

A legacy client opens with initialize. The server answers with the version the client asked for when it is 2025-11-25 or 2025-06-18, and with 2025-11-25 otherwise. It does not echo 2025-03-26, since that revision requires a server to accept JSON-RPC batches and this server answers a batch as an invalid request. Legacy clients also get ping.

A modern client names the revision 2026-07-28 on every request under io.modelcontextprotocol/protocolVersion in the request's _meta, and may first ask server/discover. Every modern result carries resultType set to complete and names the server under io.modelcontextprotocol/serverInfo in its _meta. A request that names any other version under that member is refused with the error -32022 and the versions the server supports.

$ printf '%s\n' '{"jsonrpc":"2.0","id":"d1","method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}}' '{"jsonrpc":"2.0","id":"d2","method":"tools/list","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2099-01-01"}}}' | ./target/debug/westering mcp
{"id": "d1", "jsonrpc": "2.0", "result": {"_meta": {"io.modelcontextprotocol/serverInfo": {"name": "westering", "version": "0.1.0"}}, "cacheScope": "public", "capabilities": {"tools": {}}, "resultType": "complete", "supportedVersions": ["2026-07-28"], "ttlMs": 3600000}}
{"error": {"code": -32022, "data": {"requested": "2099-01-01", "supported": ["2026-07-28"]}, "message": "Unsupported protocol version"}, "id": "d2", "jsonrpc": "2.0"}

Errors

CodeWhen
-32700The line is not UTF-8 or does not parse as JSON, answered under the id null
-32600The message is not a single request object, or its id, jsonrpc, method or params is malformed
-32601The method is not one the server serves in that era
-32602tools/call names an unknown tool or carries a malformed name or arguments, or params is a list
-32022A modern request names a protocol version other than 2026-07-28

A notification, a well formed message with no id, never gets a response. A blank line is skipped. When standard input ends the server exits 0. If standard output cannot take a response, the server exits 1 with one error: line on standard error.

Importing agent logs

detect and import read the tool call logs that agent frameworks write, as well as the native trace format. A log records the tool, the arguments and the result of each call, and no log records whether a call moved the work forward, so westering derives that progress flag from the recorded results under a rule you can name.

The repository carries three synthetic logs under examples/logs, each written for this repository and each showing a stall.

LogShapeStall
openai_chat.jsonOne OpenAI Chat Completions request with its messages and declared toolsThe same search repeated with the same empty result, a loop
codex_session.jsonlOpenAI Responses items wrapped under payload, as a Codex session file holds themThe same patch reapplied and the same failing test rerun, a two call cycle
claude_code_session.jsonlAnthropic messages wrapped under message, as a Claude Code transcript holds themGrep searches under new patterns that all find nothing while Glob and Read go unused, a fixation

Detect a stall in a log

Name the format, or let auto decide from the file.

$ ./target/debug/westering detect --trace examples/logs/claude_code_session.jsonl --format auto
{
  "detections": [
    {
      "detail": "tool Grep made 4 of 4 calls with no progress while Glob, Read went unused",
      "evidence_span": {
        "end_step": 6,
        "start_step": 3
      },
      "pattern": [
        "Grep"
      ],
      "shape": "tool_fixation",
      "trace_id": "claude_code_session"
    }
  ],
  "trace_id": "claude_code_session"
}

The trace id is the file name without its last extension. The steps count the tool calls from zero in the order the log records them.

With no --format, detect reads the native trace format, exactly as it did before logs were supported.

$ ./target/debug/westering detect --trace examples/logs/claude_code_session.jsonl; echo "exit $?"
error: trace file is not valid JSON, examples/logs/claude_code_session.jsonl
exit 2

See the trace a log imports to

import prints the native trace a file reads as, the document detect reads, so an imported log can be inspected, kept, and run again. Its format defaults to auto. The first events of the Codex style log show how each call reads.

$ ./target/debug/westering import --trace examples/logs/codex_session.jsonl | head -n 14
{
  "events": [
    {
      "call": "shell(command=[\"cargo\", \"test\", \"parser\"])",
      "progress": true,
      "step": 0,
      "tool": "shell"
    },
    {
      "call": "apply_patch(\"*** Begin Patch\\n*** Update File: src/parser.rs\\n@@ fn read...[138 chars 69fb0db10061b1d6])",
      "progress": true,
      "step": 1,
      "tool": "apply_patch"
    },

The call text is the tool name followed by its arguments in parentheses. Named arguments stand as name=value in sorted name order with each value as JSON text, and arguments that are not a JSON object stand as one value. A name of ASCII letters, digits, underscores, hyphens and full stops stands bare, and any other name stands as its JSON text, so {"a=1, b": 2} reads t("a=1, b"=2) and never as the two arguments t(a=1, b=2). A value whose JSON text runs past 80 characters shows its first 60 characters, three dots, and in brackets its length and its 64 bit FNV-1a digest, so two different long values read differently unless their digests collide. A float that is not finite shows as NaN, Infinity or -Infinity.

Each call id is read once. A record that names a call id seen earlier in the file, the shape of a streamed message written once per content block, adds no second call, so a log that gives one id to two different calls reads as one call. A call whose id is empty has no id, so it adds its own call and matches no result.

The goal of the imported trace is the first user message that carries words of its own, and its available tools are the tools the log declares, or every tool it calls when it declares none. Detect reads the output of import back to the same detections it gives on the log.

Formats

--formatReads
traceThe native trace format, the detect default
openaiChat Completions tool_calls and tool messages, and Responses function_call, custom_tool_call and their output items, in one JSON document or in JSON Lines
anthropictool_use blocks in assistant messages and tool_result blocks in user messages, with is_error read as a failed call, in one JSON document or in JSON Lines
autoA native trace when the file is one object holding trace_id and events, then anthropic when the anthropic reader finds a tool call in it, then openai when the openai reader finds one, the import default

A JSON Lines record wrapped under message, as Claude Code transcripts write it, or under payload with the type response_item, as Codex session files write it, is unwrapped first.

Progress rules

--progress names how a logged call counts as progress, and it applies only to an imported format.

--progressA call makes progress when
tool-result, the defaultits result differs from every earlier result of the same tool
call-resultno earlier call with the same call text returned the same result

Under both rules a call whose result is marked as an error makes no progress, and so does a call with no result in the log. The rules can disagree. Under call-result every Grep in the Claude Code style log is a new call, so none of them repeats and no stall is found.

$ ./target/debug/westering detect --trace examples/logs/claude_code_session.jsonl --format auto --progress call-result
{
  "detections": [],
  "trace_id": "claude_code_session"
}

A progress rule beside the trace format is refused.

$ ./target/debug/westering detect --trace examples/looping_trace.json --progress call-result; echo "exit $?"
error: progress applies only to an imported format, not to the trace format
exit 2

Refusals

Each refusal prints one line on standard error and nothing on standard output. A log file that cannot be read, is not UTF-8, is neither one JSON document nor JSON Lines, or carries a later line that does not parse is refused at exit status 2, and so is a log with no tool call in the named format. A log nested past the reader ceiling is refused at exit status 1, as a trace file is.

$ ./target/debug/westering detect --trace examples/logs/claude_code_session.jsonl --format openai; echo "exit $?"
error: log holds no tool calls in the openai format, examples/logs/claude_code_session.jsonl
exit 2

Under auto a file that is none of the three is refused.

$ printf '{"note": "no calls here"}' > target/neither.json && ./target/debug/westering import --trace target/neither.json; echo "exit $?"
error: log file is in no format auto reads, target/neither.json
exit 2

Your own logs

Codex and Claude Code each keep one JSON Lines file per session in their own data directory, and an application built on the OpenAI or Anthropic APIs can write its request messages to a file. Point detect at such a file with --format auto. Keep real logs out of this repository, as the contributing guide asks. The MCP server reads the same formats through its detect tool.

Trace format

westering detect --trace <file> reads one JSON object that records a session of agent work. Every trace in this repository is synthetic and written for it.

Fields

FieldTypeRule
trace_idstringMust not be empty
goalstringThe task the agent was given
tools_availablelist of stringsThe tools the agent could call
eventslist of objectsOne object per call, in step order
syntheticbooleanNot read by the loader, and by repository convention every committed trace sets it to true

Each event carries four fields.

FieldTypeRule
stepintegerStrictly greater than the step before it. Detection reads from step 0, so an event at a negative step is accepted and left out of every detection
toolstringThe tool that was called
callstringThe call signature, compared as exact text by the looping detector
progressbooleanWhether the call advanced the goal

The committed fixation example shows the shape.

$ cat examples/fixation_trace.json
{"events":[{"call":"grep(pattern=config, path=src)","progress":false,"step":0,"tool":"grep"},{"call":"grep(pattern=settings, path=src)","progress":false,"step":1,"tool":"grep"},{"call":"grep(pattern=config, path=docs)","progress":false,"step":2,"tool":"grep"},{"call":"grep(pattern=conf, path=src)","progress":false,"step":3,"tool":"grep"},{"call":"grep(pattern=config, path=tests)","progress":false,"step":4,"tool":"grep"}],"goal":"Find the config file and report its path","synthetic":true,"tools_available":["grep","read","edit","test","finish"],"trace_id":"trace-fixation-001"}

Refusals

A trace that breaks a rule is refused with one error line on standard error and exit status 2. An empty object has no trace_id, so it fails at that field.

A file nested past the reader's depth ceiling is refused before any field is read, with the line error: trace file is nested too deeply, followed by the path, and exit status 1. That holds even when the file also breaks a field rule.

$ printf '{}' > target/empty_trace.json && ./target/debug/westering detect --trace target/empty_trace.json; echo "exit $?"
error: trace_id is not a non-empty string
exit 2

A path that cannot be read is refused the same way.

$ ./target/debug/westering detect --trace target/missing_trace.json; echo "exit $?"
error: trace file cannot be read, target/missing_trace.json
exit 2

The other refusals name the field that failed, for example events is not a list, event progress is not a boolean, and event steps are not strictly increasing.

Bring your own trace

Westering reads any JSON file in the trace format. This walkthrough writes one by hand and runs the detectors over it.

1. Write the trace

Record each tool call your agent made as one event, in step order. Set progress to true on a call that moved the goal forward and false on one that did not. Westering does not infer progress, so this field is the judgment you bring.

$ cat examples/bring_your_own_trace.json
{
  "trace_id": "byo-trace-001",
  "goal": "Make the failing unit test pass",
  "tools_available": [
    "read",
    "edit",
    "test",
    "finish"
  ],
  "events": [
    {
      "step": 0,
      "tool": "read",
      "call": "read(path=src/parse.rs)",
      "progress": true
    },
    {
      "step": 1,
      "tool": "test",
      "call": "test(name=parse_empty)",
      "progress": false
    },
    {
      "step": 2,
      "tool": "edit",
      "call": "edit(path=src/parse.rs, line=40)",
      "progress": false
    },
    {
      "step": 3,
      "tool": "test",
      "call": "test(name=parse_empty)",
      "progress": false
    },
    {
      "step": 4,
      "tool": "edit",
      "call": "edit(path=src/parse.rs, line=40)",
      "progress": false
    },
    {
      "step": 5,
      "tool": "test",
      "call": "test(name=parse_empty)",
      "progress": false
    },
    {
      "step": 6,
      "tool": "edit",
      "call": "edit(path=src/parse.rs, line=40)",
      "progress": false
    },
    {
      "step": 7,
      "tool": "test",
      "call": "test(name=parse_empty)",
      "progress": false
    }
  ],
  "synthetic": true
}

The agent read the file, then ran the same test and the same edit in turn, four test runs and three edits, without progress.

2. Run detect

$ ./target/debug/westering detect --trace examples/bring_your_own_trace.json
{
  "detections": [
    {
      "detail": "call pattern of length 2 repeated 3 times with no progress",
      "evidence_span": {
        "end_step": 6,
        "start_step": 1
      },
      "pattern": [
        "test(name=parse_empty)",
        "edit(path=src/parse.rs, line=40)"
      ],
      "shape": "looping",
      "trace_id": "byo-trace-001"
    }
  ],
  "trace_id": "byo-trace-001"
}

The looping detector found the two call cycle. The evidence span covers the steps where the cycle repeated, and detail says how long the cycle was and how many times it repeated.

3. Fix what the detector refuses

A field with the wrong type is refused with one line naming it.

$ printf '{"trace_id":"x","goal":"g","tools_available":["read"],"events":[{"step":1,"tool":"read","call":"read()","progress":"no"}]}' > target/bad_trace.json && ./target/debug/westering detect --trace target/bad_trace.json; echo "exit $?"
error: event progress is not a boolean
exit 2

Where traces come from

Westering reads OpenAI and Anthropic tool call logs directly, Codex session files and Claude Code transcripts among them, as the importing agent logs page shows. For a log in any other shape, convert it into this shape with a short script, and decide per call what counts as progress for your task. Keep real traces out of this repository, as the contributing guide asks.

Detectors

The detectors are deterministic rules over a recorded trace. No model decides whether a stall happened.

Stall windows

A stall window is a maximal run of consecutive events in which no event reports progress. Both detectors look only inside stall windows, so a reported evidence span never contains a call that made progress.

Looping

Looping is the same call, or a short cycle of calls, repeating with no progress. Inside a window the detector reports a looping stall when one of these holds.

PatternRepeats needed
A single call3 consecutive times
A cycle of 2 to 4 calls2 consecutive times

Calls are compared as exact text, so grep(pattern=config, path=src) and grep(pattern=config, path=docs) are different calls. After a match the search resumes at the step after its span, so one window can yield more than one looping detection.

$ ./target/debug/westering detect --trace examples/looping_trace.json
{
  "detections": [
    {
      "detail": "call pattern of length 1 repeated 4 times with no progress",
      "evidence_span": {
        "end_step": 4,
        "start_step": 1
      },
      "pattern": [
        "grep(pattern=config, path=src)"
      ],
      "shape": "looping",
      "trace_id": "trace-loop-001"
    }
  ],
  "trace_id": "trace-loop-001"
}

Tool fixation

Tool fixation is one tool called again and again with varying calls while other available tools go unused. A span qualifies for a tool when all of these hold.

ConditionRule
Calls to the toolAt least 4
Share of the spanThe tool makes at least three quarters of the calls
VarietyThe calls to the tool are not all identical
Unused toolsAt least one tool in tools_available makes no call in the span

The detector reports the shortest qualifying span for each tool, and a window yields at most one fixation detection per tool. The fixation example has five varied grep calls with no progress, and the report names the shortest span of four.

$ ./target/debug/westering detect --trace examples/fixation_trace.json
{
  "detections": [
    {
      "detail": "tool grep made 4 of 4 calls with no progress while read, edit, test, finish went unused",
      "evidence_span": {
        "end_step": 3,
        "start_step": 0
      },
      "pattern": [
        "grep"
      ],
      "shape": "tool_fixation",
      "trace_id": "trace-fixation-001"
    }
  ],
  "trace_id": "trace-fixation-001"
}

Output

detect prints one JSON document with the trace_id and a detections list ordered by span. Each detection carries the shape, the pattern, the evidence_span with its first and last step, and a detail sentence. A trace with no stall prints an empty detections list.

Ladder and scenarios

When a detector fires inside a sandbox session, the ladder answers with one rung. The rungs fire in a fixed order.

OrderRungWhat the agent is told
1nudgeStop and change approach
2sharper_promptThe exact stalled pattern, and not to repeat it
3smaller_subtaskDo only the work inside the stalled span first
4forkSplit the work into separate attempts and keep the one that progresses

A rung fires only after every lower rung has been tried for that stall, and a rung that has been tried never fires again for it. The ladder here ends at fork. The last rung, kill, belongs to arvin and is never built or called from this repository.

Scenarios

westering intervene --scenario <name> runs one scripted test agent in a local sandbox. Each agent stalls until it receives the rung it responds to, then recovers and finishes, except the agent of loop-never-clears, which responds to no rung and stays stalled. The table comes from running each scenario.

ScenarioStall shapecleared_byoutcome
loop-clears-on-nudgeloopingnudgecleared
loop-needs-sharperloopingsharper_promptcleared
loop-needs-subtaskloopingsmaller_subtaskcleared
loop-needs-forkloopingforkcleared
fixation-clears-on-nudgetool fixationnudgecleared
loop-never-clearsloopingnullstalled

The agent that never responds shows the whole ladder in order.

$ ./target/debug/westering intervene --scenario loop-never-clears | grep -E '"(at_step|rung|outcome)"'
      "at_step": 2,
      "rung": "nudge"
      "at_step": 5,
      "rung": "sharper_prompt"
      "at_step": 8,
      "rung": "smaller_subtask"
      "at_step": 11,
      "rung": "fork"
  "outcome": "stalled",

Session record

The session record is one JSON document. It carries the goal, every event the agent emitted, the detections that fired, one entry in interventions per rung with its step, message, and the detection that fired it, and the outcome. The README shows the full record for loop-clears-on-nudge. The same scenario always prints the same bytes.

Judgment fixtures

Judgment enters a session only after a detector fires, and it never fires, skips, or reorders a rung. There are two judgment points.

PointAskedAnswer kindRecorded on the intervention as
severityBefore a rung fires, about the detectionscore between 0 and 1severity
recoveryAfter a rung, about the events that follow itchoice of recovering, still_stalled, or getting_worserecovery

Either point may also answer with an abstention.

Playback

--fixtures <dir> loads every .json file in the directory as one recorded pair. A pair answers only a request that matches its recorded request exactly, and any other request gets no answer. Nothing calls a model or the network.

An answer is recorded only when it is trusted. A trusted answer is a score or a choice with a confidence of at least 0.6. An abstention, a malformed answer, or a lower confidence records nothing, and that point of the session runs exactly as it runs without the flag.

The committed fixtures live in fixtures. For loop-clears-on-nudge the severity fixture abstains and the recovery fixture answers recovering at 0.95 confidence, so the only change to the session record is one added line.

$ diff <(./target/debug/westering intervene --scenario loop-clears-on-nudge) <(./target/debug/westering intervene --scenario loop-clears-on-nudge --fixtures fixtures)
70a71
>       "recovery": "recovering",

Fixture shape

A fixture file holds exactly four fields.

FieldContent
synthetictrue
judgment_pointseverity or recovery
requestThe detection for severity, or the rung, the shape, the pattern, and the following events for recovery
responseOne answer of the kind the point takes, or an abstention
$ cat fixtures/recovery-loop-clears-on-nudge.json
{
  "judgment_point": "recovery",
  "request": {
    "events": [
      {
        "call": "read(path=src/config.py)",
        "progress": true,
        "step": 3,
        "tool": "read"
      },
      {
        "call": "test(target=config)",
        "progress": true,
        "step": 4,
        "tool": "test"
      },
      {
        "call": "finish(summary=config located)",
        "progress": true,
        "step": 5,
        "tool": "finish"
      }
    ],
    "pattern": [
      "grep(pattern=config, path=src)"
    ],
    "rung": "nudge",
    "shape": "looping",
    "trace_id": "sandbox-loop-clears-on-nudge"
  },
  "response": {
    "choice": "recovering",
    "confidence": 0.95,
    "kind": "choice",
    "probabilities": {
      "getting_worse": 0.01,
      "recovering": 0.95,
      "still_stalled": 0.04
    }
  },
  "synthetic": true
}

A fixture that breaks the shape stops the run with one error line that names the file and the defect. Two fixtures that record the same request also stop the run.

Performance

This page reports how westering detect scales with the size of a trace, from a thousand events to a million. It names the machine the numbers came from, gives the bounds behind each stage of a run, and shows how to rerun the measurement. Every timing and memory number on it was read from a run of a release build. Every count of work now is a count the unit tests pin, and the counts before this change come from one run of an instrumented copy of the old detector that the tree does not keep.

What was measured

The measurement is a Rust example at examples/perf. It writes a synthetic trace in each of eight shapes at 1000, 10000, 100000 and 1000000 events, runs the release binary over each trace three times and keeps the best wall time, runs it a fourth time under the system time command to read the peak resident memory, and prints the detection count and a checksum of the output bytes. Every trace is a pure function of its shape and its event count, and a test pins the SHA-256 digest of every shape at 1000 and 10000 events, so the same command writes the same traces on any machine.

ShapeWhat it holdsDetections at 1000 events
no_windowsDistinct calls that all make progress, so no stall window opens and the run costs the reader and the writer alone0
long_distinctOne stall window of distinct calls, three tools in turn0
short_windowsWindows of eight calls closed by a progress call, each holding a run of three identical calls and four varied reads222
long_identicalOne call repeated through one stall window1
near_cyclesA cycle of four calls whose last call changes on every turn, so no cycle repeats twice in a row0
fixation_heavySixteen tools taking turns in blocks of six varied calls in one stall window, with one available tool unused16
loop_runsRuns of three identical calls back to back in one stall window, each run a looping catch333
share_edgeA fixation share held at exactly three quarters in one stall window, built so that no span qualifies2

The last two shapes are the adversarial ones. loop_runs packs as many looping matches into one window as the rules allow, and share_edge keeps the fixation share a few calls short of its threshold across the whole second half for a third of the starts in its first half.

Machine and load

The numbers come from an Apple M3 Max with 16 cores and 128 GiB of memory under macOS 14.6. The load average stood near 85 when the run began and near 28 when it ended.

The machine was shared with other work through every run, so the wall times are inflated and move from one run to the next. The two binaries took turns on every run of every trace, which spreads a load that comes and goes across both without making it equal for each. The no_windows rows show it, since that shape runs no search at all and still came out slower after the change at 1000000 events. The growth from one size to the next is the reading that counts.

Results

The before columns are the detector as it stood before this change and the after columns the detector as it stands now. Each time is the best of three runs in seconds. A run that passed the cap of 120 seconds was stopped and its memory was not read.

ShapeEventsDetectionsSeconds beforeSeconds afterPeak RSS MiB beforePeak RSS MiB after
no_windows100000.00770.00712.82.8
no_windows1000000.03990.03718.48.9
no_windows10000000.33840.329762.362.3
no_windows100000003.86164.4899598.3598.3
long_distinct100000.00800.00702.52.5
long_distinct1000000.03820.03768.99.1
long_distinct10000000.71610.854768.972.6
long_distinct100000005.64756.1049599.3599.2
short_windows10002220.00830.00963.02.9
short_windows1000022220.05440.051210.811.6
short_windows100000222220.87090.923681.080.4
short_windows100000022222212.24168.5524684.8569.1
long_identical100010.00670.00702.72.7
long_identical1000010.03720.03489.59.3
long_identical10000010.45010.352662.370.6
long_identical100000014.05184.0180597.4597.5
near_cycles100000.00670.00692.72.6
near_cycles1000000.04910.03839.29.2
near_cycles10000000.37070.387267.863.5
near_cycles100000005.59963.0548595.7595.7
fixation_heavy1000160.00760.00692.92.7
fixation_heavy10000160.03690.03709.57.7
fixation_heavy100000160.29280.315964.265.2
fixation_heavy1000000163.26152.8591633.5633.6
loop_runs10003330.00620.00632.62.6
loop_runs1000033330.06630.039212.811.6
loop_runs100000333333.36150.3563130.5100.6
loop_runs1000000333333over 120, stopped3.2618not read804.2
share_edge100020.00450.00442.52.5
share_edge1000020.03030.02368.07.3
share_edge10000020.73170.223067.462.1
share_edge1000000254.19212.8577597.2597.2

The output checksums of the two binaries agree in all 31 rows where both finished, so the new detector prints the same bytes on every shape at every size the old one reached. On the six linear shapes the two binaries stand within the noise of the machine, one ahead at one size and the other at the next. The two adversarial shapes show the change. From 100000 events to 1000000, loop_runs went from 3.36 seconds to past the cap before the change and from 0.36 to 3.26 seconds after it, and share_edge went from 0.73 to 54.19 seconds before and from 0.22 to 2.86 seconds after. In the first probe, taken before any change under a load average near 190, the old binary passed the cap on share_edge at 1000000 events as well.

Bounds

Write n for the events in a trace, W for the events in one stall window, A for the entries in tools_available, p for the calls one tool makes in a window, and d for the detections.

StageBoundReason
ReaderLinear in the bytes of the fileThe JSON reader visits each byte a bounded number of times and keeps a key index for every object, so a repeated key costs one lookup, and the trace builder reads four fields per event and compares each step with the one before it
Stall windowsO(n)One pass over the events
Looping searchO(W) per window, at most 10 W counted unitsThe calls of a window are gathered once and the search resumes after each match, and each offset it tries costs at most nine comparisons of a candidate cycle, a match paying for its own span
Fixation searchO(W log W + W A log W) per window, at most W (5 + A + the bit length of W) counted units beside the sortFrom each start a binary search over the share levels of the tool's calls finds the first end that meets the share and the variety conditions, each tool's levels are sorted once in O(p log p), and the variety test looks each available tool up in a sorted map and searches its positions by bisection, which the counted units count as one unit each
Whole detectorO(n log n + n A log n), at most n (15 + A + the bit length of n) counted units beside the sortsThe sum of the two searches over every window
Final sortO(d log d)One sort of the detections by span start
WriterLinear in the bytes printedEach fixation detection names the available tools it left unused, so the output can hold d times A names
SandboxA fixed boundA scripted session reruns detect over at most 200 steps

Before this change two searches were quadratic. After every looping match the looping search gathered the calls of the rest of the window again, so a window with m matches cost m times its length, and loop_runs holds one match for every three events. From every start of a tool the fixation search walked forward in steps of the share deficit, and where the share stands at its edge that deficit stays at a few calls, so in share_edge the walk from every start in the first half crossed the whole second half.

Counted work

In the test build alone the two searches count one unit for every call they gather, every comparison of a candidate cycle, every call position they gather or level, every start they try, every probe of the binary search, and every available tool they examine. Outside the test build the counter does nothing, and no source file under src reads a clock. Unit tests in src/detect_work_tests.rs hold the counts under the bounds above and pin each count in the table below exactly, which makes the bounds deterministic pins rather than timings.

TraceCounted workUnits nowBoundUnits before this change
loop_runs at 200000 eventsThe looping search46666820000006667033335
share_edge at 200000 eventsThe fixation search24844225000000626503759
loop_runs at 200000 eventsThe whole detector467330272000006668954939
share_edge at 200000 eventsThe whole detector35094187000000627828753

The units now are the counts the unit tests pin. The units before this change come from one run of an instrumented copy of the old detector, with the same counter at the same places, that the tree does not keep, so that column is a record of that run and cannot be rerun from the tree. The old detector fails every one of these pins.

A test in tests/detect_reference.rs keeps a verbatim copy of the detector as it stood before this change and requires the same detections and the same printed bytes from both over 3600 generated traces, over six shapes of its own built on the model of the shapes above, and over the eight shapes above as the measurement writes them, at sizes up to 1000 events.

Memory and the worker stack

The binary runs its work on a worker thread with a 512 MiB stack, sized so a document nested to the reader's ceiling is refused on the tool's own terms. That stack is reserved address space and not resident memory. The kernel backs a page of the stack with memory only when the thread touches it, and the resident memory numbers above show it. Every run over 1000 events peaked between 2.5 and 3.0 MiB of resident memory, far below the 512 MiB the stack reserves, so almost none of the stack is ever resident. Resident memory grows with the trace instead. With no stall window it stood near 600 MiB at 1000000 events, about 630 bytes per event and about eight times the size of the trace file, most of it the reader's, which holds the file text, the parsed document and the trace at the same time while it builds the trace. A shape with many detections adds the detections and the printed document on top, which is why loop_runs peaks near 800 MiB at 1000000 events.

Rerun the measurement

Build the release binary and run the example from the repository root.

cargo build --release
cargo run --release --example perf -- measure

The measure command takes these options.

OptionDefaultMeaning
--bin PATHtarget/release/westeringA binary to measure. Repeat it to measure several binaries in turn
--sizes LIST1000,10000,100000,1000000Event counts, comma separated
--shapes LISTevery shapeShape names, comma separated
--runs N3Timed runs per binary and trace, the best of which is kept
--cap SECONDS120The wall time after which a run is stopped
--dir PATHtarget/perfWhere the traces and outputs are written
--keepoffKeep the traces and outputs instead of removing each after its row

To compare the detector before and after a change, build the earlier commit, set its binary aside, build the current tree, and pass both. The two binaries take turns on every run, and the output checksum column prints one checksum when the outputs agree and the word differs with every checksum when they do not.

git checkout <earlier-commit>
cargo build --release
cp target/release/westering target/westering-before
git checkout -
cargo build --release
cargo run --release --example perf -- measure --bin target/westering-before --bin target/release/westering

cargo run --release --example perf -- generate share_edge 100000 trace.json writes one trace without measuring it.

Terminal demo

A captured session from a fresh build. Every block is the real output of the command above it.

The recording below is rendered by scripts/media/render.sh from scripts/media/demo.sh, and a test replays each command in it against the built binary.

A terminal recording of westering finding a loop in a trace, a tool fixation in a trace and in a Claude Code log, and the ladder clearing a stall at the smaller subtask rung

$ ./target/debug/westering detect --trace examples/looping_trace.json
{
  "detections": [
    {
      "detail": "call pattern of length 1 repeated 4 times with no progress",
      "evidence_span": {
        "end_step": 4,
        "start_step": 1
      },
      "pattern": [
        "grep(pattern=config, path=src)"
      ],
      "shape": "looping",
      "trace_id": "trace-loop-001"
    }
  ],
  "trace_id": "trace-loop-001"
}
$ ./target/debug/westering detect --trace examples/logs/claude_code_session.jsonl --format auto
{
  "detections": [
    {
      "detail": "tool Grep made 4 of 4 calls with no progress while Glob, Read went unused",
      "evidence_span": {
        "end_step": 6,
        "start_step": 3
      },
      "pattern": [
        "Grep"
      ],
      "shape": "tool_fixation",
      "trace_id": "claude_code_session"
    }
  ],
  "trace_id": "claude_code_session"
}
$ ./target/debug/westering intervene --scenario loop-needs-subtask | grep -E '"(at_step|rung|cleared_by|outcome)"'
  "cleared_by": "smaller_subtask",
      "at_step": 2,
      "rung": "nudge"
      "at_step": 5,
      "rung": "sharper_prompt"
      "at_step": 8,
      "rung": "smaller_subtask"
  "outcome": "cleared",
$ sh examples/check.sh
examples/looping_trace.json matches examples/looping_detections.json
examples/fixation_trace.json matches examples/fixation_detections.json
examples/bring_your_own_trace.json matches examples/bring_your_own_detections.json
examples/logs/openai_chat.json matches examples/logs/openai_chat_detections.json
examples/logs/codex_session.jsonl matches examples/logs/codex_session_detections.json
examples/logs/claude_code_session.jsonl matches examples/logs/claude_code_session_detections.json
scenario fixation-clears-on-nudge matches examples/scenarios/fixation-clears-on-nudge.json
scenario loop-clears-on-nudge matches examples/scenarios/loop-clears-on-nudge.json
scenario loop-needs-fork matches examples/scenarios/loop-needs-fork.json
scenario loop-needs-sharper matches examples/scenarios/loop-needs-sharper.json
scenario loop-needs-subtask matches examples/scenarios/loop-needs-subtask.json
scenario loop-never-clears matches examples/scenarios/loop-never-clears.json

An agent uses the skill

This page shows the westering Agent Skill at work inside a real AI client. Claude Code 2.1.326, with the model claude-opus-5-5, ran in print mode in shipyard, a small synthetic project written for this page. The project held the skill at .claude/skills/westering/SKILL.md, a copy of skills/westering/SKILL.md, and a build of westering from this repository was first on the path. Three sessions ran, one prompt each, and every step of each is shown below. The first two reach westering through the skill and the shell, and the third through the MCP server that westering mcp serves.

The first two sessions ran with this command, each with its prompt in place of PROMPT.

claude -p "PROMPT" --output-format stream-json --verbose --setting-sources project --strict-mcp-config --no-session-persistence --max-budget-usd 3 --allowedTools "Read" "Grep" "Glob" "Write" "Skill" "Bash(westering:*)" "Bash(westering *)"

The allowed tools let the agent read and search the project, write a file, load a skill and run westering. The client also ran a few shell commands outside that list without asking, a directory listing in session 1 and a byte count in session 2, and refused the others. Each refusal is shown as the client returned it.

What was changed

The page is rendered from the stream of tool calls and results the client printed. Three kinds of change were made, and no other.

  • A path that names the machine is replaced by a neutral name. The project folder is shown as /work/shipyard, and the scratch folder the client gave the agent is shown as /scratch.
  • A long directory listing names the login that owns each file. That column is shown as owner, in the result of call 2 in session 1.
  • This repository keeps em and en dashes out of its text files. Each one the client or the agent wrote is shown as its JSON escape, \u2014 for an em dash and \u2013 for an en dash, in the result of call 9 in session 1 and in the final answer of session 2.

The trace the first agent wrote is committed as docs/media/agent-session-trace.json. The log the second agent read is committed as docs/media/earlier_session.jsonl, a copy of the synthetic example examples/logs/claude_code_session.jsonl under the name the session saw. A test in tests/launch.rs runs each westering command below that the client did not refuse, over those files, and fails unless it prints exactly the result shown here. It also runs the command that matches each call of the MCP tools in session 3 and fails unless the command prints the same document.

Session 1, the agent checks its own calls

The agent searches the project, then writes its own tool calls as a trace and runs the detectors over it.

Prompt

Find where the retry limit for uploads is configured in this project and what it is set to. When you have searched, use the westering skill to check your own tool calls in this session for a stall before you answer. Write them as a trace, run westering detect on it, and act on what it reports.

Tool calls

Call 1, Grep

{
  "pattern": "(?i)retr(y|ies)",
  "output_mode": "content"
}

It returned this.

No matches found

Call 2, Bash

{
  "command": "ls -la; find . -type f | head -50",
  "description": "List project files"
}

It returned this.

total 8
drwxr-xr-x@  7 owner  wheel  224 Dec  4 17:49 .
drwxr-xr-x@ 14 owner  wheel  448 Dec  4 18:52 ..
drwxr-xr-x@  3 owner  wheel   96 Dec  4 17:48 .claude
-rw-r--r--@  1 owner  wheel  160 Dec  4 17:48 README.md
drwxr-xr-x@  3 owner  wheel   96 Dec  4 17:49 logs
drwxr-xr-x@  3 owner  wheel   96 Dec  4 17:48 src
drwxr-xr-x@  3 owner  wheel   96 Dec  4 17:48 tests
./tests/test_client.py
./.claude/skills/westering/SKILL.md
./README.md
./logs/earlier_session.jsonl
./src/uploader/defaults.json
./src/uploader/client.py
./src/uploader/__init__.py
./src/uploader/settings.py

Call 3, Bash

{
  "command": "for f in README.md src/uploader/*.py src/uploader/defaults.json tests/test_client.py; do echo \"=== $f\"; cat \"$f\"; done",
  "description": "Show project source files"
}

The client refused this call and returned this message.

A variable in this command can't be checked before it runs

Call 4, Read

{
  "file_path": "/work/shipyard/src/uploader/settings.py"
}

It returned this.

1	import json
2	import os
3	
4	DEFAULTS_PATH = os.path.join(os.path.dirname(__file__), "defaults.json")
5	
6	
7	def load_settings():
8	    with open(DEFAULTS_PATH, encoding="utf-8") as handle:
9	        return json.load(handle)
10	

Call 5, Read

{
  "file_path": "/work/shipyard/src/uploader/defaults.json"
}

It returned this.

1	{
2	  "upload": {
3	    "attempts": 5,
4	    "backoff_seconds": 2
5	  }
6	}
7	

Call 6, Read

{
  "file_path": "/work/shipyard/src/uploader/client.py"
}

It returned this.

1	import time
2	
3	from .settings import load_settings
4	
5	
6	def upload(path, bucket):
7	    settings = load_settings()
8	    attempts = settings["upload"]["attempts"]
9	    for attempt in range(attempts):
10	        if _put(path, bucket):
11	            return True
12	        time.sleep(settings["upload"]["backoff_seconds"] * (attempt + 1))
13	    return False
14	
15	
16	def _put(path, bucket):
17	    # Stand in for the storage call in this synthetic project.
18	    return False
19	

Call 7, Read

{
  "file_path": "/work/shipyard/README.md"
}

It returned this.

1	# shipyard
2	
3	A small synthetic service that uploads finished build artifacts to a
4	storage bucket. Written for a westering demo session, with no real
5	data in it.
6	

The agent wrote this between calls.

Found it. Now the westering check.

Call 8, Skill

{
  "skill": "westering"
}

It returned this.

Launching skill: westering

The client then gave the agent a line naming the folder of the skill, Base directory for this skill: /work/shipyard/.claude/skills/westering, and the text of SKILL.md below its frontmatter, which is the same as in skills/westering/SKILL.md in this repository and is not repeated here.

Call 9, Write

{
  "file_path": "/scratch/trace.json",
  "content": "{\n  \"trace_id\": \"upload-retry-search\",\n  \"goal\": \"Find where the upload retry limit is configured and its value\",\n  \"tools_available\": [\"grep\", \"bash\", \"read\", \"skill\"],\n  \"events\": [\n    {\"step\": 0, \"tool\": \"grep\", \"call\": \"grep(pattern=(?i)retr(y|ies))\", \"progress\": false},\n    {\"step\": 1, \"tool\": \"bash\", \"call\": \"bash(ls -la; find . -type f)\", \"progress\": true},\n    {\"step\": 2, \"tool\": \"bash\", \"call\": \"bash(cat project files loop)\", \"progress\": false},\n    {\"step\": 3, \"tool\": \"read\", \"call\": \"read(path=src/uploader/settings.py)\", \"progress\": true},\n    {\"step\": 4, \"tool\": \"read\", \"call\": \"read(path=src/uploader/defaults.json)\", \"progress\": true},\n    {\"step\": 5, \"tool\": \"read\", \"call\": \"read(path=src/uploader/client.py)\", \"progress\": true},\n    {\"step\": 6, \"tool\": \"read\", \"call\": \"read(path=README.md)\", \"progress\": false},\n    {\"step\": 7, \"tool\": \"skill\", \"call\": \"skill(name=westering)\", \"progress\": true}\n  ]\n}\n"
}

It returned this.

File created successfully at: /scratch/trace.json (file state is current in your context \u2014 no need to Read it back)

Call 10, Bash

{
  "command": "westering detect --trace /scratch/trace.json",
  "description": "Run westering stall detection on my trace"
}

It returned this.

{
  "detections": [],
  "trace_id": "upload-retry-search"
}

Call 11, Read

{
  "file_path": "/work/shipyard/tests/test_client.py"
}

It returned this.

1	from uploader import upload
2	
3	
4	def test_upload_gives_up():
5	    assert upload("build.tar", "artifacts") is False
6	

Final answer

The upload retry limit is set in src/uploader/defaults.json:3 as "upload": {"attempts": 5}. A searched for "retry" found nothing because the setting is called attempts, not retry.

How it's used:

  • src/uploader/settings.py:7 loads defaults.json. No environment variable or other file changes the value.
  • src/uploader/client.py:8 reads settings["upload"]["attempts"] and loops for attempt in range(attempts). That means 5 upload tries in total (the first plus 4 retries), not 5 retries.
  • Between tries it waits backoff_seconds (2) × the attempt number: 2, 4, 6, 8 and 10 seconds. It also waits after the last failed try, so a failed upload takes about 30 seconds before it returns False.

Stall check: I wrote my 8 tool calls as a trace and ran westering detect on it. It found no stalls: "detections": []. One step went nowhere: a shell command to print all the files was refused, so I read each file directly instead and didn't repeat it. Since nothing was reported, I didn't need to change approach. I also read tests/test_client.py to confirm it doesn't override the limit. The trace is at /scratch/trace.json.

Session 2, the agent checks an earlier log

The agent runs the detectors over the log of an earlier session in the project and explains the stall they report.

Prompt

logs/earlier_session.jsonl is the transcript of an earlier agent session in this project. Use the westering skill to check it for stalls, and tell me what the agent should have done differently.

Tool calls

Call 1, Skill

{
  "skill": "westering",
  "args": "logs/earlier_session.jsonl"
}

It returned this.

Launching skill: westering

The client then gave the agent a line naming the folder of the skill, Base directory for this skill: /work/shipyard/.claude/skills/westering, and the text of SKILL.md below its frontmatter, which is the same as in skills/westering/SKILL.md in this repository and is not repeated here, followed by the line ARGUMENTS: logs/earlier_session.jsonl.

Call 2, Bash

{
  "command": "westering detect --trace logs/earlier_session.jsonl --format auto; echo \"exit $?\"; westering import --trace logs/earlier_session.jsonl; echo \"exit $?\"",
  "description": "Run stall detection and import on the session log"
}

The client refused this call and returned this message.

This Bash command contains multiple operations. The following part requires approval: echo "exit $?"

Call 3, Bash

{
  "command": "westering detect --trace /work/shipyard/logs/earlier_session.jsonl --format auto",
  "description": "Run stall detection on the session log"
}

It returned this.

{
  "detections": [
    {
      "detail": "tool Grep made 4 of 4 calls with no progress while Glob, Read went unused",
      "evidence_span": {
        "end_step": 6,
        "start_step": 3
      },
      "pattern": [
        "Grep"
      ],
      "shape": "tool_fixation",
      "trace_id": "earlier_session"
    }
  ],
  "trace_id": "earlier_session"
}

Call 4, Bash

{
  "command": "westering import --trace /work/shipyard/logs/earlier_session.jsonl",
  "description": "Show the trace westering builds from the log"
}

It returned this.

{
  "events": [
    {
      "call": "Glob(pattern=\"**/*.toml\")",
      "progress": true,
      "step": 0,
      "tool": "Glob"
    },
    {
      "call": "Read(file_path=\"config/cache.toml\")",
      "progress": true,
      "step": 1,
      "tool": "Read"
    },
    {
      "call": "Grep(path=\"src\", pattern=\"max_entries\")",
      "progress": true,
      "step": 2,
      "tool": "Grep"
    },
    {
      "call": "Grep(path=\"src\", pattern=\"cache_size\")",
      "progress": false,
      "step": 3,
      "tool": "Grep"
    },
    {
      "call": "Grep(path=\"src\", pattern=\"capacity\")",
      "progress": false,
      "step": 4,
      "tool": "Grep"
    },
    {
      "call": "Grep(path=\"src\", pattern=\"CACHE_LIMIT\")",
      "progress": false,
      "step": 5,
      "tool": "Grep"
    },
    {
      "call": "Grep(path=\"src\", pattern=\"lru\")",
      "progress": false,
      "step": 6,
      "tool": "Grep"
    }
  ],
  "goal": "Find where the cache size limit is configured.",
  "tools_available": [
    "Glob",
    "Read",
    "Grep"
  ],
  "trace_id": "earlier_session"
}

Call 5, Bash

{
  "command": "wc -c /work/shipyard/logs/earlier_session.jsonl",
  "description": "Check the log file size"
}

It returned this.

    2311 /work/shipyard/logs/earlier_session.jsonl

Call 6, Read

{
  "file_path": "/work/shipyard/logs/earlier_session.jsonl"
}

It returned this.

1	{"type":"summary","summary":"Find the cache size limit","synthetic":true,"note":"Written by hand for the westering examples. No real session."}
2	{"type":"user","message":{"role":"user","content":"Find where the cache size limit is configured."}}
3	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_01","name":"Glob","input":{"pattern":"**/*.toml"}}]}}
4	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_01","content":"Cargo.toml\nconfig/cache.toml"}]}}
5	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_02","name":"Read","input":{"file_path":"config/cache.toml"}}]}}
6	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_02","content":"1\t[cache]\n2\tbackend = \"memory\"\n3\tttl_seconds = 300"}]}}
7	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_03","name":"Grep","input":{"pattern":"max_entries","path":"src"}}]}}
8	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_03","content":"No matches found"}]}}
9	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_04","name":"Grep","input":{"pattern":"cache_size","path":"src"}}]}}
10	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_04","content":"No matches found"}]}}
11	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_05","name":"Grep","input":{"pattern":"capacity","path":"src"}}]}}
12	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_05","content":"No matches found"}]}}
13	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_06","name":"Grep","input":{"pattern":"CACHE_LIMIT","path":"src"}}]}}
14	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_06","content":"No matches found"}]}}
15	{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"toolu_07","name":"Grep","input":{"pattern":"lru","path":"src"}}]}}
16	{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_07","content":"No matches found"}]}}
17	

Final answer

westering found one stall in logs/earlier_session.jsonl: the agent kept calling Grep instead of changing approach. The file's first line says it was written by hand as a westering example, so this is a sample session rather than a real one.

What the tool reported

  • Type: tool fixation, with Grep as the repeated tool.
  • Where: steps 3\u20136, which is four Grep calls in a row with no progress, while Glob and Read went unused.

What happened The task was "Find where the cache size limit is configured."

  1. Glob **/*.toml found Cargo.toml and config/cache.toml.
  2. Read config/cache.toml showed only backend = "memory" and ttl_seconds = 300. There was no size setting.
  3. Grep in src for max_entries, cache_size, capacity, CACHE_LIMIT and lru returned "No matches found" all five times.

westering counts step 2's max_entries search as progress only because it was the first Grep result. It also found nothing, so in practice the agent was stuck for five calls, not four. The session ends with no answer and no report of what was searched.

What the agent should have done differently

  1. Questioned the search scope after the first or second miss. Every Grep searched path="src". When several unrelated words all return nothing, the problem is probably where it's searching, not which word it picked. It should have searched the whole repo, or used Glob to see which directories and files exist.
  2. Gone back to the config files. The cache config lists backend = "memory", so the next step was to find the code that reads config/cache.toml (for example, a Grep for cache.toml or ttl_seconds). The size limit is probably set there, as a default or a constructor argument, or the memory backend has no limit at all.
  3. Checked Cargo.toml. Glob had already found it. A dependency such as lru, moka or cached would tell it which library's size setting to look for. The agent never opened the file.
  4. Used one search instead of five. Something like max_entries|cache_size|capacity|CACHE_LIMIT|lru, case-insensitive and across the whole repo, does the same work in one call.
  5. Stopped and reported. If none of that turned anything up, "No size limit is configured; config/cache.toml only sets backend and TTL" is a useful answer. Ending on a run of empty searches is not.

In westering's terms the agent never took even the first fix, which is to try a different approach after a couple of failures. Here the different approach was searching wider or reading other files.

Session 3, the agent uses the MCP server

The third session gave the client westering mcp as its one MCP server and allowed the two tools it serves and Read. It ran with this command.

claude -p "PROMPT" --output-format stream-json --verbose --setting-sources project --strict-mcp-config --mcp-config '{"mcpServers":{"westering":{"type":"stdio","command":"westering","args":["mcp"]}}}' --no-session-persistence --max-budget-usd 3 --allowedTools "mcp__westering__detect" "mcp__westering__intervene" "Read"

The client's first line of output reports the server westering as connected, with the tools mcp__westering__detect and mcp__westering__intervene. The client hands the agent the result of each tool call as compact JSON. In call 1 the agent searches for the two tools with the client's ToolSearch tool, which loads them so the agent can call them. The allowed tools do not name ToolSearch, and the client ran it without asking.

Prompt

logs/earlier_session.jsonl is the transcript of an earlier agent session in this project. Use the detect tool of the westering MCP server to check it for stalls, reading it with the format auto. Then use the server's intervene tool to run the scenario the detection suggests, the one whose name matches the stall it found, and tell me which rung cleared it.

Tool calls

Call 1, ToolSearch

{
  "query": "select:mcp__westering__detect,mcp__westering__intervene",
  "max_results": 2
}

It returned this.

[
  {
    "type": "tool_reference",
    "tool_name": "mcp__westering__detect"
  },
  {
    "type": "tool_reference",
    "tool_name": "mcp__westering__intervene"
  }
]

Call 2, mcp__westering__detect

{
  "path": "logs/earlier_session.jsonl",
  "format": "auto"
}

It returned this.

{"detections":[{"detail":"tool Grep made 4 of 4 calls with no progress while Glob, Read went unused","evidence_span":{"end_step":6,"start_step":3},"pattern":["Grep"],"shape":"tool_fixation","trace_id":"earlier_session"}],"trace_id":"earlier_session"}

Call 3, mcp__westering__intervene

{
  "scenario": "fixation-clears-on-nudge"
}

It returned this.

{"cleared_by":"nudge","detections":[{"detail":"tool grep made 4 of 4 calls with no progress while read, edit, test, finish went unused","evidence_span":{"end_step":3,"start_step":0},"pattern":["grep"],"shape":"tool_fixation","trace_id":"sandbox-fixation-clears-on-nudge"}],"events":[{"call":"grep(pattern=config, path=src)","progress":false,"step":0,"tool":"grep"},{"call":"grep(pattern=settings, path=src)","progress":false,"step":1,"tool":"grep"},{"call":"grep(pattern=config, path=docs)","progress":false,"step":2,"tool":"grep"},{"call":"grep(pattern=conf, path=src)","progress":false,"step":3,"tool":"grep"},{"call":"read(path=src/config.py)","progress":true,"step":4,"tool":"read"},{"call":"test(target=config)","progress":true,"step":5,"tool":"test"},{"call":"finish(summary=config located)","progress":true,"step":6,"tool":"finish"}],"goal":"Find the config file and report its path","interventions":[{"at_step":3,"fired_by":{"evidence_span":{"end_step":3,"start_step":0},"pattern":["grep"],"shape":"tool_fixation","trace_id":"sandbox-fixation-clears-on-nudge"},"message":"Stop. Your recent work stalled in the shape tool_fixation. Change approach and work toward the goal. The goal is Find the config file and report its path.","rung":"nudge"}],"outcome":"cleared","session_id":"sandbox-fixation-clears-on-nudge","stall_cleared":true}

Final answer

The first rung, the nudge, cleared it.

What the detection found: I read logs/earlier_session.jsonl with the format set to auto and found one stall, a tool fixation on Grep. From step 3 to step 6, Grep made 4 calls in a row and none of them made progress, while Glob and Read went unused.

The scenario run: fixation-clears-on-nudge is the only scenario named for this kind of stall, so I ran that one. Note that it's a scripted sandbox run, not a replay of your session.

  • The agent made 4 Grep calls in a row that made no progress. The detector flagged it at step 3.
  • At step 3 the ladder fired its nudge: "Stop. Your recent work stalled in the shape tool_fixation. Change approach…"
  • The agent then switched to read, test and finish, and each of those calls made progress.
  • The run ended with the stall marked as cleared and no higher rung needed.

FAQ

Does westering watch a live agent?

No. It reads recorded trace files and runs scripted test agents in a local sandbox. No code path touches a live agent, the network, the clock, or randomness. A test in the suite scans the crate source for the usual ways in, sockets, the system clock, spawned processes, environment reads, sleeps and random number sources, and fails when one appears. It is a scan for those markers, so review still matters for a use it does not name.

Can I run my own scenario through the ladder?

Not yet. intervene takes only the six committed scenario names. The ladder page lists them. detect does take any trace you write, as bring your own trace shows.

Where does the progress flag come from?

In a native trace you set it. Each event carries a progress boolean, and the detectors only look inside runs of calls that made no progress. A tool call log records no progress, so when detect reads one it derives the flag from the recorded results under the rule --progress names, as the importing agent logs page describes.

Why does the ladder stop at fork?

The last rung, kill, belongs to arvin. Westering never builds or calls it.

Does westering call a model?

No. The two judgment points, severity and recovery, read recorded answers from fixture files. See judgment fixtures.

Is the output stable?

Yes. The same input always prints the same bytes, keys are sorted, and examples/check.sh checks the committed outputs against a fresh run.

What do the exit codes mean?

0 for success, 2 for a refusal, 1 for an internal failure, and 120 for a standard output failure at exit. The command line reference has the details.

Reading the contract

CONTRACT.md is the spec of westering. Every obligation in it is stated so that a test can fail on it. This page says how the file is ordered and where each part of it stands.

How the record grows

Each slice of work writes its obligations in a new section at the end of the contract before any code is written, and the code and tests of that slice follow. From the launch polish slice on, no slice changes text an earlier slice merged. Before it, a few early rounds and the launch pass edited earlier text in place, and the git history keeps those edits. The paragraph near the top of the contract that points here is the one text the launch polish slice placed outside its own section. When a later slice changes what an earlier obligation says, it writes an amendment that names the earlier text, and the earlier text stays where it stands, so the file shows both the first reading and every correction to it. A section opens with a preamble that records what was probed or measured before its obligations were written, and each obligation follows as a numbered paragraph.

The stub obligations and the round sections come from the first build of the tool. Rounds 1 to 4 built it in Python, Round 5 ported it to Rust under PR-36 to PR-43, and the later rounds built on the port. The Round 12 section holds its own obligations, PR-73 to PR-76, and also those of every round after it, PR-77 onward. The launch sections come from the work that readied the first release and published the crate. The polish sections come from the work on the released crate.

Finding an obligation

Each obligation starts its paragraph with its identifier, such as PR-37. or PERF-3., so a search for that text finds it.

Sections

The table lists every section of the contract in order, with the identifiers of the obligations it holds and their count. A test derives this table from the contract and fails when the two differ, so the table stays current as sections are added.

SectionObligationsCount
Stub obligationsPR-S1 to PR-S55
Round 1 obligationsPR-1 to PR-1111
Round 1 review amendmentsPR-12 to PR-187
Round 2 obligationsPR-19 to PR-268
Round 3 obligationsPR-27 to PR-293
Round 4 obligationsPR-30 to PR-345
Round 5 obligationsPR-35 to PR-439
Round 6 obligationsPR-44 to PR-507
Round 7 obligationsPR-51 to PR-544
Round 8 obligationsPR-55 to PR-595
Round 9 obligationsPR-60 to PR-645
Round 10 obligationsPR-65 to PR-684
Round 11 obligationsPR-69 to PR-724
Round 12 obligationsPR-73 to PR-456384
Launch slice, public surfacesPUB-1 to PUB-7e12
Launch slice, compact corpusCORPUS-1 to CORPUS-1010
Launch slice, Windows portabilityWIN-1 to WIN-99
Launch slice, Windows portability review amendmentWIN-10 to WIN-123
Launch slice, library APIAPI-1 to API-1010
Launch slice, panic surfacePANIC-1 to PANIC-1010
Launch slice, library API review amendmentAPI-11 to API-122
Launch slice, library API and panic surface second review amendmentAPI-13 to API-15, PANIC-11 to PANIC-136
Launch slice, release plumbingREL-1 to REL-44
Launch slice, release plumbing review amendmentREL-5 to REL-106
Launch slice, performance on large tracesPERF-1 to PERF-77
Launch slice, performance review amendmentPERF-8 to PERF-114
Launch slice, importing agent logsIMPORT-1 to IMPORT-99
Launch slice, MCP serverMCP-1 to MCP-1515
Launch slice, command line wiringCLI-1 to CLI-1414
Launch slice, importer, MCP server and command line review amendmentIMPORT-10 to IMPORT-14, MCP-16 to MCP-18, CLI-15 to CLI-16, API-16 to API-1712
Launch slice, launch polishLAUNCH-1 to LAUNCH-88
Launch slice, first releaseREL-11 to REL-133
Launch slice, first release review amendmentREL-14 to REL-174
Launch slice, published crateCRATE-1 to CRATE-77
Launch slice, published crate review amendmentCRATE-8 to CRATE-125
Polish slice, package contentsPOL-11