8000 Refactor the CLI Base Agents into one runner with per-CLI hooks by veoery · Pull Request #84 · Infini-AI-Lab/hermit · GitHub
[go: up one dir, main page]

Skip to content
< 8000 link crossorigin="anonymous" rel="modulepreload" href="https://github.githubassets.com/assets/p81-3c0583c64e175d89.js" fetchpriority="low" />

Refactor the CLI Base Agents into one runner with per-CLI hooks - #84

Open
veoery wants to merge 3 commits into
Infini-AI-Lab:mainfrom
veoery:refactor/CliAgent
Open

veoery wants to merge 3 commits into
Infini-AI-Lab:mainfrom
veoery:refactor/CliAgent

Conversation

@veoery
@veoery veoery commented Nov 6, 2026
Copy link
Copy Markdown

Change

CliAgent (hermit/agent/base/cli.py) was shared by codex and claude, but every per-CLI difference besides the command was an inline if backend == "codex" check spread over cli.py, records.py, trajectory.py, interface.py, endpoint.py and isolate.py.

Now CliAgent is one shared runner (isolation, home, sign-in, tool server, process, the stream's safety). Each CLI is a subclass whose hooks hold what is its own:

  • its command and default program
  • its home (home_env, prepare_home, user_home)
  • its web search and system instructions
  • how its stream is read (served, notices, last_message, parse, steps, adjust_usage)
  • the isolations it runs under

CLIS lists every CLI. make(), isolate.CLI_HOMES and the chat endpoint use it; trajectory.py has a small reader registry of its own.

Validation

Run on Linux (bubblewrap 0.9.0, Python 3.12, codex-cli 0.166.0, Claude Code 2.1.317). Each tree in its own venv:

Check origin/main (11acf57) This branch
python -m pytest 3 failed, 927 passed, 63 skipped 3 failed, 928 passed, 63 skipped
--integration (test_sandbox.py, test_ahe_hosts.py) 6 passed 6 passed
  • Failures: the same 3 on both, the examples/clbench_database parity tests, which already fail on main.
  • Extra pass: the new guard test, which checks that every CLI in CLIS implements every hook and that make() builds it under each name. It fails for a CLI that leaves a hook out.
  • Before/after comparison: a script (not committed) drove both trees through a fake CLI: 26 sessions, 8 refusals, the helpers, 18 trajectory layouts, the endpoint's system instructions. The output is byte-identical once random ports, tokens and temp names are masked.
  • Not verified: a real provider session, or a Codex container session (no image built here).

Review

  • Tests and documentation cover the affected behavior: existing tests unchanged and passing, one guard test added, docs listed above.
  • Commands, defaults, and public interfaces are consistent (shown by the comparison).
  • Shared logs and examples contain no credentials or private data.
  • Documentation-only: N/A.
  • Core changes: shared Layer 2 code and isolate.py, restructured so a new CLI is one subclass.
  • Failure paths unchanged: unserved/unavailable sessions, refused limits, timeouts and cancel are in the comparison.
  • Test checklist: the new test is in tests/core/test_cli_agent.py, needs no files, network or sign-in, and runs in 0.13 s.
  • Independent review (post-PR audit): pending.

This branch has not been deployed

No deployments
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

0