Repository navigation
Let a bot type into a running program: shell tty and write_stdin - #322
Conversation
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
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
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
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
…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
As Codex's exec_command and write_stdin: shell with tty=true runs the command in a pseudo-terminal and returns what it wrote within yield_time_ms, with a proc handle while it runs. write_stdin types into it (control keys as characters), reads what it wrote since, or kills it. A terminal runs until it exits or is killed, across turns; wait on its handle reports how it ended. Each bot keeps at most 16, pruning the one it used least recently, and terminals end when the daemon stops. A terminal never leaves its bot's sandbox, so a sandboxed bot's input runs without review as its commands do; an unsandboxed bot's write_stdin is gated like shell. write_stdin is a default tool beside shell. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
…te_stdin's Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad265194c5
ℹ️ 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".
A terminal remembers the sandbox it started under; input typed after the bot's sandbox changed ends it instead of running outside the new one. While the command runs, a read holds back trailing carriage returns and any tail that could begin a credential, so a credential split across two reads is redacted whole. Line ends are normalized in one pass, and a terminal belongs to its bot's id rather than its reusable name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 458a0cf6c7
ℹ️ 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".
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e8f60beea
ℹ️ 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".
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013jkdGEJ3nWi13hKbRCL7Hh
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac9d351006
ℹ️ 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".
The last item borrowed from fx, after #299 and #306. George asked for it so bots can work with REPLs.
Until now a bot's shell gave commands no stdin. Anything waiting for typed input, like a REPL (python, node, psql, a debugger) or a
Continue? [y/N]prompt, sat there until it timed out. This follows Codex'sexec_commandpluswrite_stdin, which fx also has.What a bot gets
shellwithtty: trueruns the command in a pseudo-terminal that is its own session. It returns what the command wrote withinyield_time_ms(default 1 s, at most 30 s). While the command runs, the result also carries aproc:Nhandle.write_stdin {handle, chars, yield_time_ms, kill}typescharsinto that handle and returns what the command wrote since the last read. Control keys are sent as characters, for example\^Cfor Ctrl-C. An emptycharsonly reads. It waits 250 ms after typing and 5 s when only reading, which are Codex's defaults.kill: trueends the command's process group.waiton its handle reports how it ended (exit_code, orsignal), along with any output no write read.\r\nbecomes\n, and output is redacted like every other tool result. Commands get the same environment as other shell commands,TERM=dumbincluded, which keeps REPLs on plain prompts. Codex does the same.Checked by hand against real REPLs:
python3 -q(assignments, a multi-linedef, a sleep,exit()→ exit 0) andnode([1,2,3].map(x => x * 2)→[ 2, 4, 6 ]).Bounds and ownership
terminal_not_running.Registry::end_terminalsruns in the shutdown path). Without that, a live terminal held up shutdown by 5 s. The runtime test checks that shutdown stays fast with one running.Approvals and sandbox
ttywithrequire_escalatedis refused.write_stdinis insandbox::confinable, so a sandboxed bot's input runs without review, the same as its commands. For an unsandboxed bot,write_stdinis gated likeshell(it is not inUNGATED), soautojudges what gets typed.--new-session) the command runs in a session of its own, so Ctrl-C typed into the terminal doesn't reach it there.killdoes. On macOS (sandbox-exec) and for unsandboxed bots, Ctrl-C works and is tested.Clients
write_stdinis a default tool, next toshell(client::default_tools). The docs' default lists are updated.Typed into proc:N "..."andKilled proc:N. The clean view hides it like any other ordinary call, so there's nothing new to screenshot.Daemon cost
Nothing runs unless a bot starts a terminal. Each terminal costs one PTY, one reader task and one exit task. There's no new dependency: the PTY uses
libc::openptywithtokio'sAsyncFd. Theshelldescription grew by one sentence; the detail went intowrite_stdin's own description, after a longer version tipped the tight-budgettest_compactionpacing test.Tests
tool_contract::a_terminal_takes_typed_input_and_reports_its_end: argument checks, a prompt that sees a terminal, typing an answer, the exit code on the write and on the handle, other bots refused, Ctrl-C delivering SIGINT, andkillending a command that ignores SIGINT.test_a_terminal_takes_input_across_turns_and_ends_on_its_handle: start in one turn, type in the next,waiton the handle, another bot refused, and a prompt daemon shutdown with a terminal still running.\r\r\n.cargo test, clippy and fmt pass locally, as do the terminal runtime test and all oftest_compactionon release builds. The earlier full runtime run failed onlytest_served's bubblewrap tests, which this container can't run.