turn: spawn claude with cwd = /state

every claude invocation now runs with current_dir set to
/state — relative paths in tool calls (Read notes.md, Bash ls,
Write blob) land in the agent's durable bind-mounted dir
instead of the harness's systemd cwd. /state is RW + survives
destroy/recreate so this matches where the agent is told to
keep notes anyway. dev/test setups without the bind silently
fall back to the parent cwd.
This commit is contained in:
müde 2026-05-16 00:46:19 +02:00
parent 034b4fde10
commit 02139efbb1

View file

@ -241,6 +241,16 @@ async fn run_claude(
)); ));
} }
let mut cmd = Command::new("claude"); let mut cmd = Command::new("claude");
// Spawn inside /state so any path claude resolves relatively (Read
// foo.md, Bash ls, Write notes.md) lands in the agent's durable
// dir instead of wherever the harness systemd unit started. /state
// is bind-mounted RW from the host so survives destroy/recreate.
// Fall back silently if the dir is missing (dev / test setups
// running without the bind mount) — Command picks up the parent's
// cwd in that case.
if std::path::Path::new("/state").is_dir() {
cmd.current_dir("/state");
}
cmd.arg("--print") cmd.arg("--print")
.arg("--verbose") .arg("--verbose")
.arg("--output-format") .arg("--output-format")