Skip to content

Add web_fetch for every provider, and AI_AGENT for every command - #306

Merged
lydakis merged 7 commits into
mainfrom
claude/project-thread-obvuqb
Oct 29, 2026
Merged

lydakis merged 7 commits into
mainfrom
claude/project-thread-obvuqb

Conversation

@lydakis

@lydakis lydakis commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The second set of items borrowed from fx (vercel-labs/fx at 30b6bac), after #299.

web_fetch

web_search only exists where a bot's provider offers it. That left Claude on Bedrock with no way to read a web page, and ChatGPT-login bots and other gateways with only what their search returns. web_fetch is a daemon tool, so it works on every provider. fx and Claude Code both have one.

  • It takes {"url"}, http or https only. Redirects are followed up to ten times, the request times out after 30 s, and at most 4 MiB of body is read. A type that isn't text is refused with web_fetch_not_text.
  • An HTML page comes back as Markdown, with its title and with links and images made absolute. Other text comes back as it is. src/tools/fetch.rs is a small converter with no new dependency, using the reqwest the daemon already has.
  • Text past 64 KiB is shown as its start and end, and the whole text (up to 1 MiB) is kept as the call's text artifact, which read pages, the same way shell streams work. A status outside 2xx marks the result failed.
  • Clients add it to every new bot unless web_search = "disabled", the setting that already turns web access off.
  • Unlike search, it is not in UNGATED or AUTO_UNGATED: it is gated like any other tool, and auto judges it, because the URL it is given leaves the machine.
  • Docs updated: docs/RUST_PROTOTYPE.md (tools and web), docs/CLI.md, README.md.

AI_AGENT

Shell commands now get AI_AGENT=agent beside TERM=dumb and the pagers. fx sets the same variable so that tools can tell an agent is running them. As with the other variables, a value the caller or bot sets still wins.

Daemon cost

Nothing changes on a turn's path. The fetch runs only when a bot calls it, uses one lazily built HTTP client shared by all bots, holds no process slot, and adds no store job. Its result is stored like any other tool result.

Tests

  • Unit tests in fetch.rs: HTML to Markdown (headings, links, lists, code, tables, entities, hidden elements, comments, broken markup) and URL checks.
  • tool_contract: a local HTTP server serves an HTML page, a long page (artifact kept, start and end shown), a 404 (failed result) and a PNG (web_fetch_not_text). It also checks the AI_AGENT value in the shell environment.
  • agent-client: default tools now include web_fetch, and leave it out when web search is disabled.
  • cargo test, clippy and fmt pass locally. The full runtime suite passes locally except test_served's two task tests, which need bubblewrap and this container doesn't have it.

A bot whose context left turns out could only read them by number, so it
had to guess where something was said. `history` now takes `query`
(and `before` to continue): it walks the lineage newest first, leaves out
the turn the search runs in, and lists up to 20 matches with their turn,
item type and the text around each, ignoring ASCII case. It stops at a
turn boundary after 20 matches or 64 MiB of items and names that turn as
`next_before`. The context note now mentions the search. Borrowed from
fx, whose compacted turns are searchable by text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
A multiline item reads with its whitespace compacted, so a query copied
from a history page may not occur in the item as stored. The raw-item
prefilter now passes multiline items through to the view check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
Search is what a bot's provider offers, so Claude on Bedrock and other
gateways had no way to read a web page. `web_fetch` reads one http or
https URL from the daemon: up to ten redirects within 30 seconds, at most
4 MiB of body, text only. HTML comes back as Markdown with its title and
links made absolute; past 64 KiB the result shows the start and end and
keeps the whole as the call's `text` artifact for `read`. A status outside
2xx marks the result failed. Clients give it to every new bot unless
`web_search = "disabled"`. It is gated like any other tool, and `auto`
judges it, since its URL leaves the machine.

Commands now also get AI_AGENT=agent, the variable fx sets so tools can
tell an agent runs them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
@lydakis lydakis self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:52:10.873286Z 47945cb New commits
🔒 Security Review ✅ Completed 2026-10-29T00:54:31.943451Z 47945cb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13cf4f70f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Codex's review of #306: skipping hidden elements copied the rest of the
page each time, so many of them made conversion quadratic, and it ran on
the daemon's one runtime thread; deep lists indented without bound; code
blocks lost blank lines; a literal < swallowed text up to the next >;
and Latin-1 pages were misread as UTF-8.

Conversion now runs on a blocking thread, finds a hidden element's close
tag without copying, indents at most 8 levels and cuts Markdown at 8 MiB.
Code blocks keep their lines as they are, a < that opens no tag is text,
and Latin-1 reads as windows-1252, as browsers read it; other charsets
are refused with web_fetch_charset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7dd4b0fe11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools/fetch.rs Resolved
Codex's second review of #306: charset= anywhere in a page's first KiB
picked its decoder, so text that named one could; a base element was
ignored, sending relative links to the wrong place; and unclosed links
kept piling up resolved targets. Now only a meta tag declares a charset,
base moves where relative links lead, and an opening link ends the one
still open, as HTML has it, so at most one is pending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbfd5cf7ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools/fetch.rs Resolved
Comment thread src/tools.rs Resolved
Comment thread src/tools/fetch.rs Resolved
…and read attributes whole

Codex's third review of #306: decoding a large body still ran on the
runtime thread; a page past 1 MiB was kept as its head and tail with
nothing marking the gap, as a shell stream marks it; and an attribute
name inside another attribute's quoted value was taken for the real one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47945cbad0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tools.rs Resolved
@lydakis
lydakis merged commit 02f7a1c into main Oct 29, 2026
4 checks passed
lydakis pushed a commit that referenced this pull request Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants