Repository navigation
mini-swe-agent: a Base Agent, an acting agent and a deployment host - #49
Merged
haizhongzheng merged 2 commits intoNov 9, 2026
Merged
Conversation
Michael-Jiahao-Zhang
force-pushed
the
feat/mini-swe-agent
branch
from
November 8, 2026 22:07
63367dd to
b5047fc
Compare
Michael-Jiahao-Zhang
force-pushed
the
feat/mini-swe-agent
branch
from
November 9, 2026 01:30
769203a to
b42cff9
Compare
- `mini-swe-agent` is a CLI Base Agent beside Codex, Claude Code and Pi (`MiniSweAgent` in CLIS): one call runs one task through mini-swe-agent's Python API in a process of its own (hermit/agent/base/mini_swe_agent_run.py), which writes the session as JSON events, the stream CliAgent keeps and reads into the reply, the trajectory steps and the usage. Isolation, the home, the tool server, the clock and the retries of a provider that could not serve are CliAgent's. The call's tools are one bash command, `hermit-tool`, answered through the tool server's JSON entrance; the model's key goes with each request, the commands get only `env`, and on Linux the process is non-dumpable. A setting that fails every task (a config that names the model, a wrong key or model id found by the first call) starts no session; at the timeout the running command is killed too. - `agent.name: mini-swe-agent` (or `agent.base: mini-swe-agent`) is the workspace Acting Agent with that backend, its model bound as the other CLIs' are; a reference takes the litellm model classes only. - `hermit deploy --host mini-swe-agent` deploys as every host does (the copy under hermit/<id>/, what mini-swe-agent cannot load named in the context) and writes `mini-swe-agent.yaml`, whose system template gives `mini` the system message the Base Agent sends. - The `mini-swe-agent` extra (installed by CI), a tutorial and an example, and the agent and host in the reference tables.
Michael-Jiahao-Zhang
force-pushed
the
feat/mini-swe-agent
branch
from
November 9, 2026 01:43
b42cff9 to
7cebb3c
Compare
…n sandbox, core-only test collection) - after a format error mini's own message told the model to end with the bare COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT, an empty submission: Hermit's format_error_template ends with `... && cat answer.txt` - model_class is litellm or litellm_textbased in every case: the *_response classes' messages and the openrouter / portkey classes' errors are not litellm's (usage uncounted, a rate limit not retried) - under isolation: sandbox the home names no host path, as Pi's: the config is read into the settings, the system instructions go on the command (past ARG_MAX in a file, Claude Code's _prompt_file, now CliAgent's) - a thinking model's reasoning_content is a reasoning step of the trajectory - tests/core collects without mini-swe-agent (jinja2 imported only when present) - docs: the tutorial's time-limit sentence; agent.base / agent.<base> rows in config-fields Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
haizhongzheng
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR. We reviewed it in seven rounds (our own read plus an independent Codex review each round) and pushed the fixes as one commit, 844897b, on this branch. Every fix has a test that fails without it.
Three-layer abstraction
It follows docs/framework/agent-layers.md:
- Layer 2. mini-swe-agent is a Base Agent. It is a
CliAgentsubclass inCLIS, with its stream reader intrajectory.py. - Layer 1. Its model binding is in
backends.py. - Layer 3. The workspace Acting Agent is reused.
- Imports and the shared runner. Imports go one way only.
MiniSweAgentuses only hooks that already exist and does not change the shared runner.
One small leak stays as it is, by our decision: _deploy in acting/workspace.py branches on backend == "mini-swe-agent" to choose who serves the tools.
What we patched (844897b)
| Before | After | |
|---|---|---|
| Test collection | tests/core/test_mini_swe_agent.py imported jinja2 at the top. With only pip install -e '.[test]' (AGENTS.md's setup), collection of tests/core stopped with an error. |
jinja2 is imported only when present, and the module is skipped without mini-swe-agent. |
| Empty submission | After a format error, mini's inherited model.format_error_template told the model to end with a bare echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT. That gives an empty submission, which is likely the failure seen in the e2e run. |
mini_swe_agent.yaml overrides it for mini, ending with `echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT && cat answer.txt`. render_config puts it in the model section. |
| Model classes | Without a binding, any class was accepted. The *_response classes return Responses-API messages, so their usage was not counted and their steps were empty. The openrouter, portkey and requesty classes raise their own errors, so a rate limit was not retried and a wrong key was not a setup error. |
model_class must be litellm or litellm_textbased in every case. Another provider's model goes through litellm (openrouter/<model>). |
isolation: sandbox |
The home's mini-swe-agent.json held host paths: the config file's path and the system text. The sandbox translates only the command, the environment and the prompt, so the session never started. |
The home names no host path, as for Pi. The config is read into the settings. The system instructions go on the command as --system, or --system-file past ARG_MAX, using Claude Code's _prompt_file, moved unchanged into CliAgent. An end-to-end bubblewrap test covers short and long instructions. |
| Reasoning | reasoning_content was dropped, so the trajectory had no reasoning steps, unlike Codex, Claude Code and Pi. |
It is kept in the events and read as Step("reasoning"). |
| Docs | The tutorial said a time-limit stop returns the last assistant message; the reply is empty. config-fields.md omitted mini-swe-agent. |
Both corrected. |
Tests: test_mini_swe_agent, test_layers, test_context_tool, test_base_agents, test_pi_agent and test_cli_agent give 148 passed and 2 skipped, with mini-swe-agent 2.4.6. In a core-only environment the mini-swe-agent tests are skipped.
Left for follow-ups (not blocking)
- Retry accounting. A run the provider could not serve is retried, but only the last attempt's usage is kept. This is the shared Layer 3 retry loop for every CLI. mini meets it more often, since it retries after billed replies.
- Background processes. A command's background child (
server &) is not stopped at the end, timeout or cancel underisolation: none. Upstream's_runbehaves the same, and a sandbox ends it. - Long system file. Past
ARG_MAX, the system-instructions file keeps host paths: its contents are not translated. Claude Code's_prompt_filehas the same behaviour. deploy --python. It is not the interpreter the adapter's tools run in, because mini runs them in its own process. The deployment's launch command already uses that interpreter, butcommands.mdcould say so.
Minor, recorded only:
${VAR}inagent.params.configis not expanded.- The example judge accepts
195.0as195. - An empty submission falls back to the last assistant message.
- Outputs of commands that run before a submission in the same response are not in the trajectory.
- mini's
MSWEA_GLOBAL_*limits can raise before a response's usage is recorded. - The JSON tool entrance is not passed through
Tool.render. Adapter tools render identically. - Host paths inside a user config are not translated under the Layer 2 sandbox.
iamziyuzhao
added a commit
that referenced
this pull request
Nov 10, 2026
Conflicts: main's new Base Agent (mini-swe-agent) and this branch's (dsh) are both kept, mini-swe-agent's first as main has it, in every list of CLIs, bases, hosts, stream readers, bindings and settings sections (cli.py's CLIS, records.parse_log, trajectory's STREAM_HOSTS and READERS, backends' NEEDS, CLI_AGENTS and CLI_KINDS, config's FREE, BASES and CLI_BASES, defaults.yaml, the acting agent's names and checks, isolate.validate's login check, `hermit deploy --host`, the context-tool test's hosts). parse_log keeps main's Pi reader. The acting package's table of agents, which now lists mini-swe-agent, lists dsh too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iamziyuzhao
added a commit
that referenced
this pull request
Nov 10, 2026
…eview round 10) - cacb4ae read an outage from the final event's code only, which narrowed a43698d's rule: a provider overloaded inside a 200 stream (the Messages API's `overloaded_error` event, a chat server's error chunk) has no status, and dsh ends the run with pi-ai's unclassified PI_AI_ERROR, which it does not retry; the task was then not run again. Such an end is now read by its words (UNAVAILABLE, as Pi's are), and only dsh's own end is read so, never a tool's stderr. Recorded through the Base Agent: overloaded.jsonl. - A test docstring described parse_log as main had it before #49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 of 12 tasks
veoery
added a commit
to veoery/hermit
that referenced
this pull request
Nov 10, 2026
origin/main adds mini-swe-agent as a CLI Base Agent (Infini-AI-Lab#49), ASPIRE (Infini-AI-Lab#74), the macOS process stop (Infini-AI-Lab#88) and the wire meter stop (Infini-AI-Lab#87). Every conflict was both sides adding a fifth CLI to the same lists and docs: both are kept (mini-swe-agent, then opencode). The "takes no login" checks read one list, login.NO_LOGIN = ("pi", "mini-swe-agent", "opencode"), where main had ("pi", "mini-swe-agent") inline. The docs lists that name the CLI agents and deployment hosts now name both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 of 11 tasks
iamziyuzhao
added a commit
that referenced
this pull request
Nov 10, 2026
main's #49 already reads a Pi stream in parse_log (beside mini-swe-agent's), so its line is kept and this branch no longer changes records.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 of 10 tasks
6 of 7 tasks
haizhongzheng
pushed a commit
that referenced
this pull request
Nov 11, 2026
…Evolver) (#90) * Add DeepSeek Harness (dsh) as a CLI Base Agent (acting agent and dsh Evolver) DeepSeek Harness (`dsh`, npm @deepseek-ai/dsh 0.2.2-rc.1) beside codex, claude and pi, in the same three layers as Pi (#89), on the runner's outcome() of #77. - Layer 1: a <backend>/<model> reference becomes a route of dsh's pi-ai adapter (Binding.dsh_provider): the backend's URL in the first dialect it serves, the key by its variable's name (apiKeyEnv), the context window. dsh reports no cost: the backend's price applies. - Layer 2: Dsh(CliAgent) runs `dsh --profile headless --json` in a private DSH_HOME, HOME and DSH_AGENTS_HOME, telemetry off, the caller's own DSH_* variables dropped. The session's settings are a patch layer of dsh's own rows (--patch): the bound model as the default model (effort as its reasoningEffort, image_input as Pi's), the call's tools as an MCP server offered directly (1800 s per call), web search and fetch off unless asked for, no title request, session log, plugin list, sub-agents or workflows. A server that needs no key gets the placeholder key through HERMIT_DSH_NO_KEY (a route that names none is refused by dsh). Approvals are never asked (--approval-policy never); permission_mode picks dsh's own sandbox. Resume by --session-id when the home keeps the session; the workspace's .dsh/skills are also the session's own (dsh reads project skills only at the nearest folder with a .git). outcome(): a run without a completed `final` has failed, whatever dsh's exit code (SIGTERM exits 0). Usage from step_end events; the trajectory from the stream, a command's exit code from dsh's end markers (a timeout or a stop: unknown; "(no output)": empty); every unfinished end is an error step. dsh's outage codes (RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, EMPTY_RESPONSE, STREAM_CLOSED) join UNAVAILABLE. Roles, a login and container isolation are refused. - Layer 3: hermit/hosts/dsh.py (`hermit deploy --host dsh`): AGENTS.md, .dsh/skills and the adapter's tool server (120 s per call) as an insert row of .dsh/hermit.patch.yml, which the acting agent passes with --patch. The AgentEvolver, the loader and the config accept dsh; methods/dsh/ is the new Evolver (dsh's own sandbox off in the evolver sandbox, as Codex's is). - Tests: tests/core/test_dsh_agent.py over streams recorded from dsh 0.2.2-rc.1 (tests/fixtures/dsh) and, marked integration, the installed dsh: a session unsandboxed and in bubblewrap, the acting agent inside a git repository (the deployed skill offered, the adapter's own tool server answering), a keyless server, and --dump-config holding every row the session patches; the deploy host; selection entries. Checked against dsh's source at the tag dsh-v0.2.2-rc.1 and with the installed dsh. First built on #89's earlier head; rebuilt on main after #89 merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 1 (two independent reviewers on 03fafff) Each fix was checked against dsh's source at dsh-v0.2.2-rc.1 and, where it shows, against the installed dsh (new recorded streams in tests/fixtures/dsh); each has a test that fails without it. - Stream reading: a bash result dsh's --json cut at 8 KiB (`truncated`) lost its exit marker and read as exit 0; now unknown, and the text says it was cut. A command started in the background has no status yet (unknown). The end markers are anchored at the very end (\Z), as dsh's JavaScript reads them, so a command that printed a marker of its own and exited 0 is a clean exit. - Usage: a step that answered counts as a call even when the provider reported no usage (dsh reports zeros), and so does a step dsh reports no usage for (an attempt without any); what dsh never reports (compaction, a step's partial usage) is documented. parse_log reads Pi's and dsh's streams with their own readers. - outcome(): a session whose tools did not start (dsh writes the MCP row's error on stderr and runs on without them) has failed. A run that wrote only an `error` event (a usage error) or nothing (a working directory's .env that sets PATH, PYTHONPATH, ...) started no session, so the acting agent reports it instead of recording each task as a wrong answer: outcome() may now say `started` (shared runner; absent, as before). - The workspace is the project wherever it lies: the session's layer sets the skill-filesystem row to the workspace's .dsh/skills alone and the agent-instructions row to the deployment's marker (.hermit-deploy.json) as the project root, so a workspace inside a git repository gets its own skills and none of the repository's skills or AGENTS.md (they outranked the adapter's). This replaces copying the skills to the home. - `--add-dir` takes the real path of an existing directory, as dsh requires (a link failed every command and write); an effort without a model is refused; user_home() follows DSH_HOME. - The acting agent passes agent.dsh.permission_mode on (it was dropped) and refuses a mode dsh has not. - hermit deploy --host dsh: the patch layer also names the workspace's .dsh/skills (a workspace below a repository's root kept none), and a context past the 65,536 bytes dsh reads of a project's instructions is refused. - The AHE template has a `dsh` wire (as Pi's: hooks run by hand hand the memory over); mwm and RRSI refuse a backend other than Codex or Claude Code at setup (pi and dsh were accepted and ran without their model). - Docstrings say what dsh reads (.env files, the instruction chain) and sends (its own provider's ids). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 2 (two independent reviewers on 7a076fb) Each fix was checked against dsh's source at dsh-v0.2.2-rc.1 and, where it shows, against the installed dsh; each has a test that fails without it. - A task's data is bound in the workspace, not linked (binds_mounts, as for Claude Code): dsh's glob and grep run ripgrep without --follow, so a linked folder was never listed or matched. dsh's own sandbox still runs nested in that mount namespace (integration test). - Web search with a model of another backend: dsh's search is DeepSeek's own service (its Messages API on DEEPSEEK_API_KEY), so the session searched on a provider and key the run did not bind, outside its usage. Such a session gets web fetch only, as Codex's hosted search is off for a backend other than OpenAI's; a DeepSeek model or dsh's own provider keeps search. - Usage: a step dsh reports no usage for counts as a call only if it produced something (a step whose requests all failed is none), and price_usage leaves calls of which no token was reported unpriced: their cost is unknown, not $0.00 (shared: a usage with calls and no tokens is no longer priced at 0 for any CLI). - The instructions' project root: no root marker, so it is the working directory, the workspace. The deployment marker (.hermit-deploy.json, which every host's deployment writes) made a session without a deployment take a deployed folder above it for its root, and read its AGENTS.md. - hermit deploy --host dsh: the tool server's row fails at a session's start when dsh cannot start it (failOnStartupError, as Codex's `required`), which the acting agent reads as a failed session; it was retried in the background while the session ran without the adapter's tools. The 65,536-byte check counts dsh's frame around AGENTS.md (304 bytes, a </system-reminder> one byte more): an AGENTS.md just under the cap was deployed and cut. Docstring: the command names its profile; the skills row replaces a skill-filesystem config of the user's own. - dsh's effort levels and permission modes are checked as the run config loads (an unknown one failed every session, one task at a time), and an effort level dsh has not is refused in the session. - The AHE learners' texts name a Pi or dsh acting agent's stream (agent-pi.jsonl, agent-dsh.jsonl) instead of agent-codex.jsonl (Pi's entry was missing on main too). - Tests: a recorded stream of a session stopped by SIGTERM (stopped.jsonl: exit 0, no `final`, an `error` event) replaces a cut success stream, and is run through the acting agent and an AgentEvolver step; the deploy refuses at the exact limit and an MCP server name dsh refuses. Correction to round 1's message: on 03fafff a dsh usage error was already an error record per task (failed), not a wrong answer; `started` now makes the acting agent stop the run and say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 3 (two independent reviewers on 9d87553) Each fix was checked against dsh's source at dsh-v0.2.2-rc.1 and, where it shows, against the installed dsh; each has a test that fails without it. - Usage: round 2's shared rule (a usage with calls and no tokens is not priced) is gone. It made Claude Code's results of refused requests (a 529, a 401: one turn, no tokens) cost unknown instead of $0.00, and the AHE and RRSI evolvers' merged usage then dropped the step's known spend from the budget. Usage gains `unreported_calls`, the calls whose tokens a CLI did not report; only dsh's reader sets it (a step that produced something without usage: the provider reported none, or dsh retried the step and so left its usage out), and price_usage leaves such a usage's cost unknown rather than pricing the part reported, which under rate limits may be far less. - dsh's transcripts are plain JSON lines (the session layer sets session-persistence-jsonl to compression none, its root as dsh's own `!!js dshHomePath('sessions')`): they were zstd, which hermit.redact cannot scrub a key from. A scrubbed transcript still resumes. - The dsh Evolver's sessions take no instruction file (instruction_files false: the agent-instructions budget 0): dsh adds a folder's AGENTS.md when its file tools touch it, so the learner was given the adapter's AGENTS.md, the acting agent's policy, as instructions. Codex's learner is given none. - dsh's settings are checked as the run loads for the dsh Evolver too (an effort it has not failed every learner step, after its rollouts); evolver.dsh.permission_mode is refused (the Evolver runs dsh's own sandbox off), and YAML's bare `off`, a boolean, is `off`. - Web search is kept only for a model reached at api.deepseek.com on DEEPSEEK_API_KEY, where dsh's search goes (a `deepseek` backend moved by DEEPSEEK_BASE_URL searched elsewhere). - A run that ends CONTEXT_WINDOW_EXCEEDED with a backend that declares no context_window says to declare it (recorded: context_window.jsonl, vLLM's refusal of dsh's 128,000 output tokens; with the window declared dsh sizes the request and completes). - A unit test with the fake dsh for the task data's binding, which CI runs where bubblewrap can bind (the only test needed the dsh CLI). - Wording: the deployed tool server's row makes dsh report a server it cannot start and the acting agent fail the session (dsh itself goes on); a run dsh never started is each task's error record, not a stopped run (round 2's message said so); the deploy's size check is exact for a session at the workspace's root; the linked-data warning names dsh's glob and grep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 4 (two independent reviewers on 2021944) Each fix was checked against dsh's source at dsh-v0.2.2-rc.1 and against the installed dsh; each has a test that fails without it. - A step dsh retried after the provider refused a request lost its cache counts: the refused attempt reports zeros, pi-ai reports a count of 0 as none, and dsh sums a count into the step's only when every attempt reported it, while the step's totalTokens still holds them. The reader counts what the total holds beyond the counts reported as input, and the call as unreported (its cost unknown: those tokens were read from the cache or written to it, which are priced apart). Recorded: retried.jsonl (a 503, then 1000 prompt tokens, 900 cached: dsh reports inputTokens 100, totalTokens 1010). Round 3 said such a step's usage is left out; dsh does that only for an attempt that reports no usage at all (a stream that ended before its last event, an attempt a stop cut short). - The dsh Evolver's settings are checked from its params as the Trainer has them (its method's own under the run's, the model bound), in login.evolver_problems, which train runs before its first step and hermit check now reports for an Evolver without a login. Round 3's check, as the run loaded, missed the dsh method named with its params (`backend: dsh` comes from the method's manifest) and refused an effort given with the run's own model. The acting agent's are still checked as the run loads; one function (cli.dsh_problems) holds both, and isolate.py's change is that call. - dsh's own provider (a model of no binding, DeepSeek's API) takes the efforts off, low, high and max; another level failed every session (UNSUPPORTED_REASONING_EFFORT). - evolver.dsh.instruction_files is refused, as evolver.dsh.permission_mode is: the Evolver dropped it. - The caller's DEEPSEEK_SEARCH_BASE_URL is dropped with its DSH_* variables: without the sandbox it moved dsh's web search off DeepSeek's API. - The context_window hint follows dsh's error whole (once), not its first 300 characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 5 (two independent reviewers on f4b7b09) Each fix was checked against dsh's source at dsh-v0.2.2-rc.1 and against the installed dsh; each has a test that fails without it. - A step dsh retried after a refused request is priced again, its dropped cache tokens counted as input. Round 4 made such a session's cost unknown, and a USD budget then counted none of its spend (rollouts and learner steps add no dollars for an unknown cost), under the very load that causes retries. Its tokens are known, and hermit prices a cache write as input: the price is the step's with the counts reported, or more if those tokens were read from the cache, never less. A call stays unreported, and its session's cost unknown, only when dsh reported none of its tokens. - The caller's DEEPSEEK_BASE_URL is dropped as DEEPSEEK_SEARCH_BASE_URL is: without the sandbox it sent the requests of dsh's own provider, with DEEPSEEK_API_KEY, elsewhere. A variable the session is given (`env`) still passes. - dsh's settings check takes what each agent uses: the Evolver's danger-full-access and instruction_files false are accepted (round 4 refused them); the acting agent's instruction_files false is refused (it was dropped; it would cut the adapter's context, which reaches dsh as its AGENTS.md). - Tests pin the session's tool row (failOnStartupError, the 30-minute call timeout), every row DSH_OFF turns off, all six outage codes, and dsh's own provider's levels for the Evolver; the outage test is named for what it checks. - Wording: effort off asks a bound model for no reasoning level, which leaves its server's default (dsh's own provider turns thinking off); the context-window hint keeps dsh's error line as far as it fits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: fixes from review round 6 (two independent reviewers on f1a92ea) Each finding was checked against dsh's source at dsh-v0.2.2-rc.1 and the installed dsh; each test added fails without what it checks. No behaviour changes: the fixes are tests and claims. - Tests: a session's own `env` reaches dsh while the caller's DEEPSEEK_BASE_URL is dropped; the integration test of dsh's own sandbox shows a command's write outside the workspace refused (it passed with the sandbox off); a bash call that failed to run (a result dsh marks `error`) has no exit code; a linked session folder, or a session in a linked folder, is not resumed; a stopped session's usage is pinned (none). - The reader's account: the last step of a session a stop cut short is not counted (dsh writes a step's usage at its end, after its tool calls ran, and a stopped session writes nothing more); the docstring said such a step was a call of unknown tokens. dsh's own adapter, not pi-ai, drops a cache count of 0. A retried step's price is never less than with its counts for a price whose cached input is no dearer than its input; on the Responses API the total is the server's own `total_tokens`, taken as given. - dropped_env says why a sandbox's grant of DEEPSEEK_BASE_URL does not reach dsh (hermit's own is its deepseek backend's chat completions root, which dsh reads as its own provider's Messages root) and that `env` gives dsh its own; the Settings paragraph says so too. - A stale test docstring: the Evolver's own permission mode and instruction_files are taken. Not changed, disclosed: the acting agent's re-run after an outage keeps only its last attempt's usage, for every CLI (shared code, a separate change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: leave the Pi fixes to their own PRs The Pi fixes this branch carried change Pi's behaviour on main, not dsh's: parse_log's Pi reader, the AHE Evolver's texts for a Pi acting agent's stream, and mwm and RRSI refusing a Pi learner. They go to their own PRs (fix/pi-stream-readers, fix/mwm-rrsi-backend-check). This branch keeps dsh's entries only: parse_log reads a dsh stream as dsh's, the AHE texts name a dsh acting agent's stream, and mwm and RRSI refuse dsh (the other PR's general check covers it too, whichever merges first). The integration test of dsh's own sandbox keeps the session's home under ~/.cache/hermit-tests, as the test checklist asks of a check under bubblewrap (it was under /var/tmp). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: test which steps of dsh's stream count as calls Review round 7 (five reviewers on 37aee8c, one lens each, every finding then reproduced by a separate agent told to refute it) found 34 issues, all confirmed: one of medium severity, the rest low. The medium one: no test guarded the reader's three rules for a step whose tokens dsh did not report (a step that only called a tool is a call, so is one that only thought, and what a step produced does not carry over to the next); each, undone, left every test passing while it misstated a session's cost. The new test fails under each. The low ones are listed in the PR description, not changed. Also: a round-6 test docstring rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: test a command dsh moves to the background at its timeout In a hermit dsh session a command still running at its timeout (dsh's default is 60 s) is moved to a background job, unless dsh's job limit is reached: the session's layer leaves tool-bash's promoteOnTimeout at its default, true. Its result ends `[still running after <ms>ms; moved to background job <id>]` with no exit marker, and only the DSH_BACKGROUND check keeps it from reading as exit 0. No test held that case: bash.jsonl was recorded with promotion off. Review round 7 found this (rated medium by its reviewer, low by the agent that reproduced it, as the code was right); the author asked for it fixed. promoted.jsonl is recorded through make("dsh").run, as the other Base Agent streams are, and the test now reads it, and also a command stopped from outside the call (`[stopped: <reason>]`, which no headless session writes, so written as dsh's tool-bash renders it), with and without a marker after it. Each check undone (the background check, the `stopped:` alternative, the markers after a stop) fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: read a timeout marker at any timeout dsh prints (review round 8) Review round 8 (two reviewers on f4792e0, one on the test and its fixture, one on the claims, each finding then reproduced by a separate agent told to refute it) found: - dsh prints a command's timeout as the model gave it, a JavaScript number (`1000.5`, `0.5`), and both timeout markers were matched only at a whole number of milliseconds: a command still running at such a timeout, moved to a background job, read as exit 0, and one killed at it that trapped the signal read as its trapped exit (rated medium). Both markers now match any number dsh prints. Recorded: promoted.jsonl's third call (1000.5 ms, moved to the background) and bash.jsonl's ninth (1000.5 ms, killed, exit 0 trapped). - The test of a promoted command held only one with output before its marker; the marker alone, what a command that printed nothing yet gets, rests on DSH_BACKGROUND matching without a newline before it, which nothing held (rated medium). promoted.jsonl's second call is `sleep 5`. - Wording (low, in f4792e0's own docstring): the stop marker comes before the signal or exit marker, not before every other marker (a sandbox denial's come first). Each fix undone fails its test: the marker with a newline required before it, and either marker at whole milliseconds only. bash.jsonl is recorded again by the same script, its first eight results unchanged; its steps' count in the usage test follows (10). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: wording from review round 9 Review round 9 (two reviewers on d25958a, one on the code and its tests, one on the claims, each finding then reproduced by a separate agent told to refute it) found 6 issues (4 distinct), all low. Three are wording this change's own text got wrong, corrected here (comments, a docstring and the fixture README; no code or test changes): - dsh prints the timeout it applied, not always the model's: its default (60 s) when the model gives none, and at most its cap (600 s). - DSH_NO_OUTPUT's comment said `(no output)` comes before the marker of a command that printed nothing, which a command moved to the background does not get (its marker stands alone). The fourth, the exponent form both timeout patterns match (`1e-7`, a timeout under 0.000001 ms) held by no test, is listed in the PR description, not changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: an outage only by the run's own end; the web-search test on the built-ins alone (post-PR audit) - Dsh.outcome read `unavailable` from every line of the stream that is no event, and dsh starts a deployed stdio tool server on its own stderr, which the stream keeps: outside the task sandbox, a tool's line with an outage's words (`Service Unavailable`) made a session that failed for another reason (`max-tokens`) an outage, run `retries` times and then an error of unknown cost. It is now read from the `final` event's error code (DSH_OUTAGES, Dsh.outage), and UNAVAILABLE is main's again. - test_dsh_refuses_roles_and_a_container_and_searches_only_on_deepseeks_own_provider bound its DeepSeek models through the developer's own backends (HA_BACKENDS or ~/.config/hermit/backends.yaml, DEEPSEEK_BASE_URL, DS_BASE_URL), so it failed wherever those move `deepseek`: it binds them on the built-ins alone. - The fixture README: tools_down.jsonl's port is one Node's fetch refuses, and the Base Agent's stream has that run's stderr lines first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: an overload dsh leaves unclassified is an outage by its words (review round 10) - cacb4ae read an outage from the final event's code only, which narrowed a43698d's rule: a provider overloaded inside a 200 stream (the Messages API's `overloaded_error` event, a chat server's error chunk) has no status, and dsh ends the run with pi-ai's unclassified PI_AI_ERROR, which it does not retry; the task was then not run again. Such an end is now read by its words (UNAVAILABLE, as Pi's are), and only dsh's own end is read so, never a tool's stderr. Recorded through the Base Agent: overloaded.jsonl. - A test docstring described parse_log as main had it before #49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: guards and wording from review round 11 (post-PR audit of ace8fab) - A kept home's patch layer is written as a file of its own, never through a link or into a pipe the last session left (the dsh Evolver's agent_home): the guard had no test. - An end dsh leaves unclassified (PI_AI_ERROR) that is no outage, with a tool's outage words on dsh's stderr, runs once: ace8fab's new path had no test that its words come from the end alone. - PI_AI_ERROR is the code of dsh's pi-ai adapter, not pi-ai's; outcome() and errors() no longer say the end's code alone tells an outage. - test_deploy.py: the dsh test is named for what it holds, and its comments say what dsh does (a server that does not start is reported; the dsh acting agent fails the session; a project's root may be the working directory itself), as hermit/hosts/dsh.py now does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: documentation (the pages, the changelog, the AHE template's notes) DeepSeek Harness joins the pages that name the CLI Base Agents, their settings, deployment, models and installation, in the wording of Pi's and mini-swe-agent's entries; what is its own: its inner sandbox (permission_mode, and what it does to environment.write and /tmp), its web search, its patch layer and how a session loads it, a tool server that does not start, and the usage it leaves out. No code changed. convert's lists are untouched: dsh has no plugin format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: documentation, review round 13's corrections Round 13 read f0d2091: 16 findings, all low. dsh's commands each have a /tmp of their own and its default sandbox refuses a declared writable path (the sandbox guide); how to write a provider of one's own (model-backends); what a web fetch reaches; which price the cost follows; what Landlock, a patch layer and the request left out of the usage are. No code changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: documentation, two corrections from the read-back The sandbox guide's two ways to reach a path under /tmp are for reading it (a mount is read-only); the requests that summarize a session's history are uncounted each time, not once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dsh: deploy retires stale skills as every host does since #97 hermit deploy --host dsh now calls check_skills before it writes anything (a redeployment refuses to replace a skill folder no deployment wrote, or to write through a linked skills folder) and retire_skills after it copies the skills (a skill the last deployment exported and this one does not moves to .retired-skills/). dsh copies its skills before it writes its patch layer, whose skill-filesystem row names them, so retire_skills follows copy_skills there. #97's redeployment test gains the dsh case, which fails without the retire_skills call; no test covers the check_skills call, as on main for every host but Codex. #97's CHANGELOG entry names .dsh/skills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Merged
10 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Adds mini-swe-agent (2.4.6) to Hermit on the agent layers. It is one of the further agent integrations of #37 §3, discussed with the maintainers beforehand.
The PR was rebuilt twice:
Layer 2: the
mini-swe-agentBase Agent.MiniSweAgentis aCliAgentsubclass inCLIS(hermit/agent/base/cli.py), beside Codex, Claude Code and Pi.Process. One
runis one task. It runs through mini-swe-agent's Python API, the way its batch runner runs one, in a process of its own:python -P -m hermit.agent.base.mini_swe_agent_run(-Pkeeps the workspace off its import path). That process writes the session as JSON events on stdout. CliAgent keeps them as the stream (agent-mini-swe-agent.jsonl) and reads them into the reply, the steps (mini_swe_agent_stepsintrajectory.py) and the usage (parse_mini_swe_agentinrecords.py).What it reuses from CliAgent. Isolation (
noneor the run'ssandbox; not a container, as for Pi), the home (MSWEA_GLOBAL_CONFIG_DIR), the tool server, the clock and the retries of a provider that could not serve. Its hooks are the command, the home's settings file,served,errors,outcome,last_message,parseandsteps.Messages.
mini_swe_agent.yaml) go over mini-swe-agent's ownmini/mini_textbasedconfig, then aconfigfile's settings.adapter_block): the deployment's context (hermit.contextin the workspace'smini-swe-agent.yaml), the call's tools and the call's system instructions.echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT && cat answer.txt); the reply is the submission, else the last assistant message.Tools. The call's tools are one bash command,
hermit-tool <name> '<JSON arguments>'. The process's environment (mini_swe_agent_env.py) answers it through the tool server's JSON entrance (HERMIT_TOOLS_URL).The model's key.
env).envand a few basic variables only./proc..envis the sign-in file (home_files), asauth.jsonis Codex's and Pi's.Failures (
outcome, the contract Pi follows):ValueError)configthat names the model or the environment class, or a first model call refused for the settings (401, 404, or the 400 DeepSeek returns for a wrong key)exitmessage (killed)failed: no answer is judged and the task is an error record (session_failed), as Pi's failed request is; its tokens countunavailable, not served: the task runs again (retries)Refused. These are refused with
Unsupported:roles;session(mini-swe-agent cannot resume);login;web_search: true;litellm/litellm_textbased, since another class would send the binding's key and URL to its own service.Layer 3.
agent.name: mini-swe-agentis the workspace Acting Agent (hermit/agent/acting/workspace.py) with backendmini-swe-agent, soprompt,files,mounts,prepare,answer,collect,context_queryandretrieswork as for the other CLIs._checkrefuses a login and a container for it in the branch it now shares with Pi. The layered form isagent.base: mini-swe-agentwith anagent.mini-swe-agentsection.bind_agent_paramskindmini-swe-agent, listed inCLI_KINDS, withNEEDSset to chat completions.Deploy.
hermit deploy --host mini-swe-agent(hermit/hosts/mini_swe_agent.py) follows the shared layout.hermit/<id>/, and the context names what mini-swe-agent cannot load (skills, roles, hooks, other files) throughhermit.hosts.inputs.resources.mini-swe-agent.yaml. It holds Hermit's prompts over mini-swe-agent'sminiconfig, with the adapter's block in the system template as literal text. The block is a Jinja raw block, with every spelling ofendrawescaped.AdapterEnvironment(a Session in mini-swe-agent's process) as the environment class, plus an audit log.mini -c mini-swe-agent.yamlgets the system message the Base Agent sends (a test asserts it). The acting agent's ownmodel_class/configare not deployed (documented).Dependency. A
mini-swe-agentoptional extra (pip install "hermit-harness[mini-swe-agent]"). It is not a dependency group, because the groups are the methods' (METHOD_REQUIREMENTS). CI installs it so the tests run rather than skip.render_configlocates the package rather than importing it, so a deploy or the Trainer never gets mini-swe-agent's import side effects.Docs.
docs/_examples/mini_swe_agent/: nine CSV questions, an exact-format judge, GEPA as the learner, DeepSeek.Core changes. These are shared layers that every method group runs on. They extend existing tables and branches; no new mechanism.
hermit/agent/base/cli.py: the subclass inCLIS.trajectory.py: the reader inREADERS/STREAM_HOSTS/MARKS; it keys onsession.started, which no other CLI emits.records.py: the usage parser.parse_lognow also dispatches Pi, which before fell through to Claude Code's reader.acting/workspace.py,acting/agent.py: the backend, the deploy branch, the settings the Base Agent takes, and Pi's_checkbranch shared.config.py,defaults.yaml: theagent.basevalue and its section.model/backends.py:CLI_AGENTS,CLI_KINDS,NEEDS, the binding kind.hermit/isolate.py: the config check that refuses a login for Pi now refuses it for mini-swe-agent too, with the agent's name. This is configuration validation only; what the sandbox shows or allows is unchanged..github/workflows/tests.yml: the extra.Validation
Tests.
tests/core/test_mini_swe_agent.py, 24 tests. The stand-in is the model: an OpenAI-compatible server with the API's payload shape. mini-swe-agent's loop, its environment and litellm run unchanged. Run time is about 70 s; the longest test is the 9 s timeout test, whose delay is what it holds.What the 24 tests cover
env, no key in any file, steps, tokens and cost.yaml.pythat does not shadow the runner's imports./proc/$PPID/environ(Linux, non-root).workspace._checkandisolate's config check, including a badconfigraising rather than scoring.endrawspellings;hermit-toolthrough mini-swe-agent's ownget_environment; roles named; local environment without tools; redeploy; the other-host refusal; the CLI.mini.yamlin the working directory.The regression tests for the review findings fail without their fixes (checked by reverting each fix).
test_context_tool.pyadds the host to the not-portable refusal.test_layers,test_selectionandtest_packagingpass.Test runs at this head, with litellm 1.108.3 and openai 3.46.0, the versions CI resolves with the other groups:
pytest tests/core(before the last audit's small fixes)mainon this machine:test_backends::test_check_reports_models_and_train_refuses_a_missing_dialect,test_cli_agent::test_a_stream_replaced_by_a_link_is_not_read_as_the_sessions, twotest_harbor_runner,test_isolate::test_a_worker_whose_log_cannot_be_opened_leaves_no_descriptor_open,test_lean_swarm_launch,test_session_sandbox::test_a_server_that_cannot_start_is_reportedtest_mini_swe_agent.py,test_pi_agent.py,test_layers.pyandtest_selection.pypass (2 Linux-only skips)test_mini_swe_agent.py: 23 passed, 1 skipped (bubblewrap); at b42cff9 alsotest_pi_agent.pyandtest_cli_agent.py(92 passed, skips for bubblewrap and the pi CLI)tests/corebwrap: loopback: Failed RTM_NEWADDR), plus the onetest_backendsfailure abovetest_mini_swe_agent.py: 23 passed, the sandboxed rollout among them. The/proctest is skipped there, since root reads any process's environmentbash docs/build.sh(warnings as errors) passes.End to end with DeepSeek (
deepseek/deepseek-flash), the example as shipped.eval --adapter nonetraineval --adapter finalsandbox.enforce=required(every task in the task sandbox, the learner in its own), this headsandbox.enabled=false(bubblewrap cannot run there), before the #89 rebasehermit checkwith a wrongDEEPSEEK_API_KEYreports[PROBLEM] agent probe ... exited 2 before starting a session: ... Authentication Failsin about 5 s.mini -c mini-swe-agent.yaml -m deepseek/deepseek-flash -y --exit-immediately -t "..."answered{"answer": 448}(correct) in 3 calls.deepseek-flashis in the built-in backend, so costs are unknown.One rollout's sandbox record (
runs/mini-swe-agent/sandbox/rollout-1.json, privileged container, abridged){"role": "rollout", "program": "/opt/venv/bin/python3", "enforced": true, "network": "isolated", "read_only": ["/opt/venv/...", "/work/hermit", "/work/.demo/m/environment", "/work/.demo/m/runs/mini-swe-agent/rollout_adapter"], "read_write": [".../.logs/rollout/<task>", ".../.logs/rollout/<task>/home"], "allow": ["api.deepseek.com"], "probe": {"passed": true, "outside": {"1.1.1.1:443": "blocked (OSError)", "8.8.8.8:53": "blocked (OSError)"}, "denied": {"/root/.bashrc": "absent", "/work/.demo/m/tasks.jsonl": "absent", "/work/.demo/m/train.txt": "absent", "/work/.demo/m/val.txt": "absent", "/work/.demo/m/test.txt": "absent", "/work/.demo/m/judge.py": "absent"}}, "environment": ["DEEPSEEK_API_KEY", "HOME", "HTTPS_PROXY", "MSWEA_GLOBAL_CONFIG_DIR", "PATH", "PYTHONPATH", "..."]}Not verified:
isolation: sandboxfor mini-swe-agent: the acting agent reaches the sandbox through the task sandbox, where the inner isolation isnone.ps ewwshows a process's environment to the same user (documented).Review
--host mini-swe-agent,agent.name/agent.base: mini-swe-agentandagent.mini-swe-agent.*are listed where the other CLIs are.agent.*→bind_agent_params→base_agent()settings → the home's JSON → the process. Errors, timeouts, retries and failed sessions are covered above, with tests.load_agent,Config.loadand the Base Agent'srun, the real mini-swe-agent and litellm, the deploy host and mini-swe-agent's ownget_environment. The e2e runs go throughhermit check/eval/train/deployand theminiCLI.tests/core/, which--changedruns for these shared paths.tmp_pathand use no network beyond loopback.hermit/isolate.pyis the config check's message (see Core changes). The sandbox itself is unchanged.configfile must be declared inenvironment.read(documented).post-pr-audit(at b5047fc, and at b42cff9 after the Add Pi as a CLI Base Agent (acting agent and pi Evolver) #89 rebase). Findings and fixes, with regression tests where testable:-P.render_configwithout importing mini-swe-agent;MSWEA_GLOBAL_CONFIG_DIRhonoured; refusal messages naming the agent; docs listing Pi and mini-swe-agent alike; the task-sandbox note forconfig; tests for the merged refusals.answerreads.