Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/hive-runtime
Repository files (latest commit first)
Filename Latest commit message Latest commit date
atlas 8ec51ca774 hive-runtime: retry an ACP session whose first prompt failed on that session
A new session is only recorded once its first prompt is answered, so a
failed first prompt made the next turn run `session/new` again and left the
first session behind in the agent: in the same process, and after a restart.

The new session's id is now kept in `<session file>.pending` until that
prompt is answered. The next turn attaches it (in-process, or through
`session/load` after a restart) and still prepends the system prompt, since
the session has not had an answered prompt yet. Recording the session
removes the pending file, and `archive` drops it.

Raised by argus in the #4812 review.

Refs #4391
2026-09-29 23:20:24 +02:00
..
src hive-runtime: retry an ACP session whose first prompt failed on that session 2026-09-29 23:20:24 +02:00
Cargo.toml hive-runtime: record a new ACP session only once its first prompt is answered 2026-09-29 22:29:36 +02:00
README.md hive-runtime: shared runtime crate with claude and acp backends 2026-09-29 22:29:36 +02:00

hive-runtime

The layer an agent's turns are driven through: one Runtime interface (run, compact, archive) with a backend per runtime.

  • claude — claude --print through the hive-claude crate's InfiniteSession. A pass-through: same spawn, same session handling, same errors.
  • acp — any Agent Client Protocol agent, spawned from a command, args and env handed to it (RuntimeSpec, read from HIVE_RUNTIME / HIVE_ACP_COMMAND / HIVE_ACP_ARGS / HIVE_ACP_ENV). It knows no agent by name; which agent runs, and how it is configured, is decided in nix (services.hyperhive.agent.runtime, services.hyperhive.agent.acp.*).

Both backends report a turn through hive_claude::Sink in claude's stream-json shape. The ACP backend translates session/update notifications into it (text and thought chunks as whole blocks, tool calls as tool_use + tool_result, MCP tools named mcp__<server>__<tool>), so the harness's stream consumers read either backend unchanged. Context usage comes from ACP usage_update.

The crate depends on no hyperhive binary crate, so hive-agent and hive-subagent-mcp can both drive turns through it.

ACP backend: what it needs from the agent

  • mcpCapabilities.http in its initialize response. The hyperhive tools are only served over HTTP, so an agent without it is refused at startup.
  • loadSession, to pick its session back up after a harness restart. Without it every restart starts a new session.

ACP backend: not yet

compact returns Error::Unsupported, there is no cancel, and no idle watchdog (Config::idle_timeout is ignored). An agent that retries a failing provider on its own keeps the turn open until it gives up.