A hook that exits without reading all of its stdin closes the pipe while
CommandWithStdin::output_with_stdin is still writing the JSON payload.
The write fails with BrokenPipe, and the error was propagated, so the hook
was reported as "failed to start ...: Broken pipe (os error 32)" even
though it ran and exited normally. A failed PreToolUse hook then denies
the tool call, and a failed PostToolUse hook marks the tool result as an
error.
Any payload larger than the pipe buffer (64 KiB on Linux) triggers it for
a hook that does not read stdin. The payload carries tool_input twice, so
a write_file of about 40 KB is enough.
plugins/src/hooks.rs already tolerates BrokenPipe for the same reason
(ROADMAP #25). Apply the same handling to the runtime hook runner, and
add a regression test.
Adds an optional per-client ExtraHeadersHook. Hosts that need routing, quota or cache-affinity metadata can install it with with_extra_headers_provider on AnthropicClient, OpenAiCompatClient or ProviderClient; headers are applied inside send_raw_request after the JSON body is built.
There is no global state and no behaviour change when no provider is installed. count_tokens does not go through send_raw_request, so it stays unannotated. Transport-owned headers and malformed names/values are dropped, so a broken hook cannot rewrite credentials or fail a call.
Co-authored-by: tree-zby <203675912+tree-zby@users.noreply.github.com>
- Increased timeout from 1_000ms to 30_000ms in executes_simple_command,
disables_sandbox_when_requested, and prevents_stdin_hangs_by_redirecting_to_null
tests to account for git-bash cold start delays on Windows ARM runners
- Added clear error message to executes_simple_command assertion that includes
stderr for better debugging of future timeout failures
- Fixes CI flake: ultraworkers/claw-code ca875261 run 45476362842 and 578e910b run 45815130318
Co-authored-by: Watch <watch@local>
Adds a TrustedRouter section to docs/local-openai-compatible-providers.md: OPENAI_BASE_URL/OPENAI_API_KEY setup, the local/ hatch for vendor-prefixed ids (incl. trustedrouter/auto), the 64k output-token note, and the public /v1/models listing.
read_file and grep_search return a file's lines joined with `\n`, so a
multi-line old_string quoted from a CRLF file never matched and
edit_file failed with "old_string not found in file". On Windows that is
every multi-line edit in a checkout made with Git's default
core.autocrlf=true.
When every line break in the file is `\r\n`, convert old_string and
new_string to CRLF before matching, so the edit applies and inserted
lines keep the file's line endings. LF and mixed files are unchanged.
Adds Gemini API rows and the missing o1-pro, o3-pro, gpt-5.x-pro and
gpt-5.3-codex rows to OPENAI_COMPATIBLE_PRICING, and a per-request
pricing_for_request() that applies the Haiku 5.5 >100K, OpenAI >272K and
Gemini >200K prompt tiers. Usage::estimated_cost_usd uses it, since it
prices one response. pricing_for_model() and aggregated session totals are
unchanged.
grep_search walked and read every file under its root, including .git,
node_modules and target. glob_search already prunes these directories
(#2986), and docs/g002-security-verification-map.md says both search tools
do. In a Rust checkout with a 2.5 GB target/ directory, one grep_search
call took about 2.3 s instead of about 0.13 s, with the same results.
Use the same pruning for grep_search, and never prune the search root
itself, so a search the caller points into node_modules or target still
works for both tools.
* docs: document Standard Compute OpenAI-compatible gateway setup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: align Standard Compute routing sentence with its docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(windows): fix native runtime compatibility and enable workspace tests
Fix shell discovery, hook quoting, native path handling and OAuth
randomness on Windows, make the test fixtures portable, and run the
full workspace test suite in the Windows CI job.
* test(plugins): make lifecycle fixtures Windows-compatible
* fix(windows): address workspace test failures
---------
Co-authored-by: clawdbot <clawdbot@ultraworkers.dev>
Inserted cells were named cell-{len+1}, which is still taken once any
cell but the last has been deleted, so a later edit by the returned id
went to the older cell instead.
* fix(tools): cut RemoteTrigger responses on a char boundary
A response over 8192 bytes with a multi-byte character across byte 8192 panicked on the slice.
* test(tools): add multibyte char boundary truncation test for RemoteTrigger
---------
Co-authored-by: clawdbot <clawdbot@ultraworkers.dev>
Trident stage 1 dropped the assistant message that carried a file tool
use while keeping the tool result that answered it, so the compacted
session ended up with orphaned `tool_result` blocks. Providers reject
such requests with HTTP 400 ("tool_result blocks must be a response to
a preceding tool_use"), which breaks the auto-compact retry path that
runs Trident before resending a request.
Stage 1 also counted a tool result as an independent file operation,
which pushed `last_write` past the write the result belonged to and made
the newest write look obsolete.
Only tool uses count as file operations now, and a tool result is
dropped together with the tool use that produced it.
* Fix issue #3364: web search returns error on non-2xx response and filters search engine self-links
- Add HTTP status code check to execute_web_search: return error if response is not 2xx
instead of proceeding with potentially junk results (e.g., DuckDuckGo challenge pages)
- Filter out links pointing back to the search engine host in extract_search_hits_from_generic_links
to avoid returning search engine self-links when no proper search results are found
- Add regression tests for both scenarios
Refs #3364
* fix: implement registrable domain filtering and error on 202/blocked responses
- Replace exact host matching with registrable domain comparison to properly
filter search engine self-links across subdomains (e.g., html.duckduckgo.com
vs duckduckgo.com)
- Add error handling for 2xx responses with no search results (e.g., 202
challenge pages from blocked search providers)
- Add regression tests for both 202 challenge page and mixed self-link scenarios
- Remove unrelated Cargo.lock version bumps (revert to 0.1.6)
Fixes#3364
* fix(tools): reject DuckDuckGo 202 challenge pages and drop search-engine links
The challenge page arrives as HTTP 202, which is_success() accepts, and its
links point at duckduckgo.com while the request goes to html.duckduckgo.com,
so the previous filter kept them. Only a 200 page is parsed now, and the
generic fallback drops any duckduckgo.com link or link to the configured
search host. Removes the registrable-domain heuristic and the 'no hits is an
error' path (a real query can legitimately return nothing), and replaces
tests that never exercised a self-link with ones that fail on the old code.
Refs #3364
---------
Co-authored-by: clawdbot <clawdbot@ultraworkers.dev>
The environment section rendered "Model family: Claude Opus 4.6" for
every Anthropic model, so claude-opus-5-5, claude-sonnet-4-6, and any
other Claude model told users it was Opus 4.6.
Render a neutral "Claude" family label followed by the resolved model
ID, and rebuild the system prompt on /model so the line follows a
mid-session switch instead of keeping the startup model.
Models from the OpenAI-compatible providers fell back to
default_sonnet_tier ($3/$15 per MTok), so e.g. gpt-5.4-nano was
estimated at 15x its input price and qwen-plus at about 26x.
Add a table of published rates keyed by model id, matching dated
snapshots and -latest aliases:
- OpenAI standard tier for current gpt-6 / gpt-5.x / gpt-4.1 / gpt-4o
and o-series models (Responses-only pro models are omitted).
- xAI grok-4.x and grok-build. Slugs retired on 2026-05-15 (grok-3,
grok-4-0709, grok-4-fast-*, grok-4-1-fast-*) are billed at grok-4.3
rates, and grok-code-fast-* is served as grok-build.
- DashScope qwen-max, qwen-plus, qwen-flash and kimi-k2.5 at China
(Beijing) rates, which is claw's default DashScope endpoint, with
non-thinking output and the 20% implicit-cache hit rate.
Long-context and higher input tiers use the base rate because usage is
aggregated across requests.