claude: static role/tools moved to --system-prompt-file

This commit is contained in:
müde 2026-05-15 17:44:15 +02:00
parent 37c6504462
commit 68fe66c0ef
5 changed files with 98 additions and 80 deletions

View file

@ -128,6 +128,7 @@ async fn serve(
let _ = state; // reserved for future state transitions (turn-loop -> needs-login)
let mcp_config = turn::write_mcp_config(socket).await?;
let label = std::env::var("HIVE_LABEL").unwrap_or_else(|_| "hive-ag3nt".into());
let system_prompt = turn::write_system_prompt(socket, &label, mcp::Flavor::Agent).await?;
loop {
let recv: Result<AgentResponse> = client::request(socket, &AgentRequest::Recv).await;
match recv {
@ -137,9 +138,15 @@ async fn serve(
from: from.clone(),
body: body.clone(),
});
let prompt = format_wake_prompt(&label, &from, &body);
let outcome =
turn::drive_turn(&prompt, &mcp_config, &bus, mcp::Flavor::Agent).await;
let prompt = format_wake_prompt(&from, &body);
let outcome = turn::drive_turn(
&prompt,
&mcp_config,
&system_prompt,
&bus,
mcp::Flavor::Agent,
)
.await;
turn::emit_turn_end(&bus, &outcome);
}
Ok(AgentResponse::Empty) => {}
@ -157,38 +164,11 @@ async fn serve(
}
}
/// System prompt handed to claude on each turn. The harness has already
/// popped one message off the inbox (the wake signal); claude is told
/// about it and the MCP tools, and is expected to drive any further
/// recv/send itself.
fn format_wake_prompt(label: &str, from: &str, body: &str) -> String {
// Manager broker name. Lifecycle calls it `hm1nd` (container), broker
// calls it `manager`. Sub-agents address the manager via `manager`.
let manager = hive_sh4re::MANAGER_AGENT;
format!(
"You are hyperhive agent `{label}` in a multi-agent system.\n\
\n\
Incoming message from `{from}`:\n\
---\n\
{body}\n\
---\n\
\n\
Tools:\n\
- `mcp__hyperhive__recv()` drain one more message from your inbox \
(returns `(empty)` if nothing pending).\n\
- `mcp__hyperhive__send(to, body)` message a peer (by their name) \
or the operator (recipient `operator`, surfaces in the dashboard).\n\
\n\
Need new packages, env vars, or other NixOS config for yourself? \
You can't edit your own config directly message the manager \
(recipient `{manager}`) describing what you need. The manager \
edits `/agents/{label}/config/agent.nix` on your behalf, commits, \
and submits an approval that the operator can accept on the \
dashboard; on approve hive-c0re rebuilds your container with the \
new config.\n\
\n\
Handle the inbox, then stop. Don't narrate intent act."
)
/// Per-turn user prompt. The role/tools/etc. is in the system prompt
/// (`prompts/agent.md` → `claude --system-prompt-file`); this is just the
/// wake signal claude reacts to.
fn format_wake_prompt(from: &str, body: &str) -> String {
format!("Incoming message from `{from}`:\n---\n{body}\n---")
}
fn render(resp: &AgentResponse) -> Result<()> {