Skip to content

Add Hermes and OpenCode CLI agent adapters - #321

Open
amr-karam wants to merge 2 commits into
regnull:mainfrom
amr-karam:pr-adapters
Open

amr-karam wants to merge 2 commits into
regnull:mainfrom
amr-karam:pr-adapters

Conversation

@amr-karam

Copy link
Copy Markdown

What

Adds two CLI-agent adapters alongside upstream's Claude Code, so a bot can run its turn
through the Hermes Agent or OpenCode CLI instead of OpenBot's own model loop:

  • hermes chat --format stream-json
  • opencode run --format json

Both mirror the existing CliAdapter contract in base.py, so they register in ADAPTERS
and appear in the bot editor and the providers endpoint exactly like the existing agent.

Details

  • hermes.py / opencode.py — provider/label/binary/path_setting/install dirs, argv
    construction, stream parsing (StreamParser feed/finish/usage), and a conservative
    permission mapping with WHY comments: EDIT maps to a scoped flag per CLI, and READ_ONLY
    never auto-approves a write. session_id_re overridden per adapter so OpenCode's ses_...
    ids are not rejected; status_argv=() and min_version=(0,0,0) for both.
  • base.py — Turn.cwd, adapter.combine(), adapter.turn_env(), with the env merged
    into the child environment.
  • schemas.py — hermes/opencode added to the Provider literal and MODEL_OPTIONAL.
  • config.py — hermes_path / opencode_path, so the executable can be named explicitly
    the way claude_code_path already is.
  • Tests + recorded JSONL fixtures for argv construction and stream parsing (62 tests).
  • conftest.py — pins LOG_FILE=nul before openbot.main is imported. main.py calls
    create_app() at import time, which calls configure_logging(Settings()); where the test
    sandbox cannot create files that crashes the import. It is a setdefault, so it is a no-op
    for anyone who already sets LOG_FILE. Happy to drop this if you consider it out of scope.

Test change this forces

test_providers_lists_the_cli_by_whether_it_is_found_without_running_it asserted
cli_agents == [claude-code], which held while it was the only adapter. With three registered
the providers endpoint lists all three, so the assertion has to cover them. Every adapter's
path is pinned (not just claude_code_path) so found is deterministic rather than depending
on what happens to be installed on the developer's PATH.

Verification

  • ruff check . — clean.
  • tests/test_cli_agents.py — 62 passed.
  • Full suite, -n 4 --dist loadfile, this branch: 4 failed, 886 passed, 7 skipped.
  • Full suite, same command, on main as merged today: 5 failed, 872 passed, 7 skipped.

So this branch's failure set is a subset of main's (one flaky parallel test passed here
that failed there), adding 14 passing tests and no new failures. Three of the remaining
failures are environmental on this machine and reproduce on unmodified main:
test_search_code_..., test_workspace_tools_keep_out_of_the_openbot_state_dir, and
test_versioned_matrix_is_complete_and_honest. CI runs serially and should be unaffected.

Hermes Agent added 2 commits November 24, 2026 17:08
Implement OpenBot runtime CLI agent adapters for Hermes Agent
(hermes chat --format stream-json) and OpenCode
(opencode run --format json), mirroring the existing Claude Code
adapter contract in base.py:

- hermes.py / opencode.py: provider/label/binary/path_setting /
  install_dirs / argv / parser / not_found, StreamParser
  feed/finish/usage_so_far, system prompt threaded via child stdin,
  every output line JSON (non-JSON dropped at debug), CLIs forced
  into JSON output mode.
- session_id_re overridden per adapter (default rejects OpenCode's
  ses_... ids); status_argv=() and min_version=(0,0,0) for both.
- Conservative permission mapping with WHY comments: hermes EDIT ->
  -t file, opencode EDIT -> allow edit; READ_ONLY never auto-approves
  writes.
- Register both adapters in ADAPTERS; add unit tests for argv
  construction and stream parsing (recorded event lines).
- base.py extended with Turn.cwd, adapter.combine(), adapter.turn_env(),
  env merged into child env.
- schemas.py: add hermes/opencode to Provider literal + MODEL_OPTIONAL.
- config.py: add hermes_path / opencode_path settings.
- conftest.py: pin LOG_FILE=nul before openbot.main import so the
  import-time configure_logging does not crash in file-creation-blocked
  sandboxes.

Ruff clean; 59/59 cli_agents tests pass; full suite 840 passed with 7
pre-existing environmental failures (file/SQLite creation blocked),
none in the adapter code.
Upstream's test asserted cli_agents held exactly one entry (claude-code), which
held while it was the only adapter. With Hermes and OpenCode registered, the
providers endpoint lists all three, so the assertion has to cover them.

Pin every adapter's path setting, not just claude_code_path: without that,
ound depends on what happens to be installed on the developer's PATH, and a
machine with hermes or opencode installed would fail a test that passes in CI.
@amr-karam

Copy link
Copy Markdown
Author

This PR is ready for review. The CI workflow run for this branch is in \�ction_required\ state — it needs fork workflow approval from a maintainer to proceed. Local verification: 4 failed / 886 passed on the branch vs 5 failed / 872 passed on bare upstream main — zero new failures introduced.

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