Skip to content

zarvis: codex-style minimal tool surface (shell + edit_file + write_stdin)#329

Merged
edwin-zvs merged 1 commit into
mainfrom
zarvis-codex-tools
Jun 2, 2026
Merged

zarvis: codex-style minimal tool surface (shell + edit_file + write_stdin)#329
edwin-zvs merged 1 commit into
mainfrom
zarvis-codex-tools

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

What

Replaces zarvis's granular filesystem tools with a codex-style minimal coding
surface — three tools — keeping all agentd-control, subagent, and browser tools.

  • Before (fs/shell coding tools): shell, read_file, write_file, edit_file, list_dir, find_files
  • After: shell, edit_file, write_stdin

Why

Benchmark analysis (DeepSWE, gpt-5.5, same Codex-OAuth backend, only the harness
differs) showed zarvis issuing ~1.2× codex's tool calls but ~1.9× the model
round-trips. A big driver is the tool surface: codex exposes essentially a
shell (exec_command) + a multi-hunk patch editor (apply_patch), so the same
work maps to fewer, denser calls. zarvis's granular read/edit/list tools fan out
into many small serial calls — on one task, 62 single-hunk edits + 38 re-reads
of 5 files
vs codex's 17 multi-hunk patches. This change aligns zarvis with
codex's surface.

Changes

  • edit_file → multi-hunk + create. Pass edits: [{find, replace, path?}]
    applied in order (each find matches the file as modified by earlier hunks),
    validated up-front and applied atomically — a single failed match writes
    nothing. An empty find on a non-existent path creates the file,
    absorbing write_file. The single {path, find, replace} form still works.
  • Persistent process subsystem (tools/proc.rs) + write_stdin. shell
    gains interactive: true: instead of killing a process at the timeout it keeps
    it alive and returns a session_id after a brief wait. The new write_stdin
    tool writes to that process's stdin (optional eof) and drains incremental
    output. A ProcRegistry is shared across the session's ToolCtxs; children
    are killed when the session ends (kill_on_drop).
  • Reads/search/list via shell. Removed read_file, write_file,
    list_dir, find_files; the model uses cat/sed -n/rg/ls. Both system
    prompts updated to steer toward batched reads and multi-hunk edits.
  • Kept: agentd-control (agentd_*), subagent (agentd_subagent_*), browser.

Notes / decisions

  • find_files wasn't in the explicit remove list but is dropped here for
    true 3-tool parity (a search convenience now covered by rg/find in
    shell). Trivial to restore if you'd rather keep it.
  • write_stdin uses pipes, not a PTY. Line-oriented programs and prompts
    work; full-screen / TTY-detecting programs may behave differently. PTY
    allocation is a possible follow-up.
  • Atomicity is guaranteed at the match-validation stage (no partial application
    on a bad find); cross-file write failures are I/O-only and reported.

Tests

144 pass (8 new): proc sessions (echo / exit / unknown id), multi-hunk
apply-in-order, atomic-on-failure, empty-find create, single edit, and an
interactive shell + write_stdin round-trip. Updated the auto-approve test
(write_fileedit_file) and the skills prose test.

Relevant binary: agentd-adapter-zarvis — this PR only touches
crates/adapter-zarvis; agent / agentd / agentd-mcp build unchanged.

🤖 Generated with Claude Code

…tdin)

Replace the granular filesystem tools (read_file/write_file/list_dir/
find_files) with a codex-style minimal coding surface, leaving the
agentd-control, subagent, and browser tools untouched.

- edit_file: now multi-hunk / multi-file. Pass an `edits` array applied
  in order (each find matches against the file as modified by earlier
  edits); validated up-front and applied atomically (a single failed
  match writes nothing). Creates files when `find` is empty on a
  non-existent path, absorbing write_file.
- tools/proc.rs: persistent process sessions. `shell interactive:true`
  keeps a process alive and returns a session_id instead of killing it
  at the timeout; the new write_stdin tool feeds its stdin and drains
  incremental output. Children are killed when the session ends.
- Reading / searching / listing now go through `shell` (cat/sed/rg/ls),
  matching codex. System prompts updated to steer toward batched reads
  and multi-hunk edits.

144 tests pass (8 new: proc sessions, multi-hunk/atomic/create edits,
interactive shell + write_stdin round-trip).
@edwin-zvs
edwin-zvs merged commit 002e8c5 into main Jun 2, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the zarvis-codex-tools branch June 2, 2026 05:15
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.

1 participant