4 Commits
Author SHA1 Message Date
Johannes KresnerandClaude Opus 5.5 db80d15ba2 fix: an hx error asks the user instead of taking the state's first catch
build / version (push) Successful in 12s
build / build (aarch64-apple-darwin) (push) Successful in 5m20s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m45s
build / release (push) Successful in 24s
hx reports its own failures (API, login, ...) as blocked with reason
"error" and no catch. orch then fell back to the state's first catch,
so with code's ToolDenied = "review" a failed agent looked like "review
ready" with no code written. Now the error lands in Needs-you; a reply
runs the step again with the reply as hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:52:40 +01:00
gitea-actions 551e0efd7c ci: bin.json v0.1.8 2026-11-17 14:28:01 +00:00
Johannes KresnerandClaude Opus 5.5 71f58d7b30 fix: interactive sessions run with yolo under the sandbox, auto without
build / version (push) Successful in 12s
build / build (aarch64-apple-darwin) (push) Successful in 5m44s
build / build (x86_64-unknown-linux-musl) (push) Successful in 4m2s
build / release (push) Successful in 23s
orch dropped --yolo for ACP sessions (TUI, orch up), so hx started with a
bare --sandbox and asked for every edit. Interactive sessions now use the
same flags as batch runs: --sandbox --yolo when a sandbox is available,
--auto when not. A sandbox with yolo = false gets --sandbox --auto.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:17:36 +01:00
gitea-actions c768ea79d4 ci: bin.json v0.1.7 2026-11-16 15:09:31 +00:00
6 changed files with 62 additions and 18 deletions

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"version": "0.1.6", "version": "0.1.8",
"sha256": { "sha256": {
"aarch64-apple-darwin": "1a6b4944c20f086015368ae5d43f1ca6f11ea1dffd82c41f12e8ed7891e90555", "aarch64-apple-darwin": "8626de462328921fb6f5e4c24dfb3a4cb768c6164acde484eb3a20f9c631c049",
"x86_64-unknown-linux-musl": "8d85f036b9a0db9306ae421ac7d4ce1fc813daecc901080e80425391da823228" "x86_64-unknown-linux-musl": "271b52fab656e410e0b4e64d3a06439e82bd63cbdcd514ada0511194255cce2c"
} }
} }
+1
View File
@@ -13,6 +13,7 @@ env = ["GITEA_*"] # orch env vars hx may see (default: PATH HOME
# TMPDIR CARGO_* RUST* NIX_*, plus HX_HOME only when `home` is unset) # TMPDIR CARGO_* RUST* NIX_*, plus HX_HOME only when `home` is unset)
sandbox = true # hx --sandbox (bwrap/seatbelt). Default: on when available (macOS, Linux with bwrap), sandbox = true # hx --sandbox (bwrap/seatbelt). Default: on when available (macOS, Linux with bwrap),
# together with --yolo (yolo = false opts out). Unsandboxed hx runs with --auto. # together with --yolo (yolo = false opts out). Unsandboxed hx runs with --auto.
# Interactive sessions (TUI, orch up) with yolo = false get --sandbox --auto.
``` ```
## Allowlist (`allow`) ## Allowlist (`allow`)
+1 -7
View File
@@ -64,13 +64,7 @@ impl Acp {
let mut parts = p.hx.split_whitespace(); let mut parts = p.hx.split_whitespace();
let mut cmd = Command::new(parts.next().context("empty hx command")?); let mut cmd = Command::new(parts.next().context("empty hx command")?);
// sandbox and permission flags are options of the root command, so they go before `serve` // sandbox and permission flags are options of the root command, so they go before `serve`
// the TUI answers permission requests itself, so yolo only when the profile asks for it explicitly cmd.args(parts).args(p.acp_flags());
let flags = p.hx_flags();
cmd.args(parts).args(
flags
.iter()
.filter(|f| **f != "--yolo" || p.yolo == Some(true)),
);
cmd.args(["serve", "--acp", "--cwd"]) cmd.args(["serve", "--acp", "--cwd"])
.arg(worktree) .arg(worktree)
.args(["--session", id]); .args(["--session", id]);
+19
View File
@@ -178,6 +178,16 @@ impl Profile {
f f
} }
/// Flags for an interactive (ACP) session: like `hx_flags` (sandbox brings yolo, no sandbox falls back to
/// `--auto`), but a sandbox with `yolo = false` gets `--auto` too, so not every edit asks.
pub fn acp_flags(&self) -> Vec<&'static str> {
let mut f = self.hx_flags();
if f == ["--sandbox"] {
f.push("--auto");
}
f
}
/// A profile file named by its path (an issue session's profile in its worktree). /// A profile file named by its path (an issue session's profile in its worktree).
pub fn load_path(path: &std::path::Path) -> Result<Self> { pub fn load_path(path: &std::path::Path) -> Result<Self> {
let s = let s =
@@ -277,6 +287,15 @@ mod tests {
assert_eq!(f("sandbox=false"), ["--auto"]); assert_eq!(f("sandbox=false"), ["--auto"]);
} }
#[test]
fn acp_flags_yolo_with_sandbox_else_auto() {
let f = |s| Profile::parse(s).unwrap().acp_flags();
assert_eq!(f("sandbox=true"), ["--sandbox", "--yolo"]);
assert_eq!(f("sandbox=true\nyolo=true"), ["--sandbox", "--yolo"]);
assert_eq!(f("sandbox=true\nyolo=false"), ["--sandbox", "--auto"]);
assert_eq!(f("sandbox=false"), ["--auto"]);
}
#[test] #[test]
fn bwrap_lookup_scans_path() { fn bwrap_lookup_scans_path() {
let dir = std::env::temp_dir().join(format!("orch-bwrap-{}", std::process::id())); let dir = std::env::temp_dir().join(format!("orch-bwrap-{}", std::process::id()));
+36 -6
View File
@@ -774,6 +774,18 @@ fn run_agent(cx: &mut Ctx, st: &State, step: &Step) -> Result<StepRes> {
cx.ctl.stop_for_budget(format!("hx limit: {}", r.summary)); cx.ctl.stop_for_budget(format!("hx limit: {}", r.summary));
Err(Stopped.into()) Err(Stopped.into())
} }
"blocked" if r.catch.is_none() && r.reason.as_deref() == Some("error") => {
// hx itself failed (API, login, ...): no catch fits, so ask instead of guessing one
let payload = json!({
"key": format!("{}/{}/error", st.name, step.name),
"state": st.name, "step": step.name, "title": "agent error",
"detail": format!("hx failed: {}. Fix the cause, then reply to run the step again (abort to give up)", r.summary),
});
let answer = ask(&cx.ctl, &cx.s.id, &st.name, "input", payload, true)?;
let reply = answer.strip_prefix("reply:").unwrap_or(&answer).trim();
hint = (!reply.is_empty()).then(|| reply.to_string());
continue;
}
"blocked" => Ok(StepRes { "blocked" => Ok(StepRes {
ok: false, ok: false,
exit: None, exit: None,
@@ -2178,17 +2190,35 @@ next = "done"
} }
#[test] #[test]
fn hx_blocked_with_another_reason_is_not_a_budget() { fn hx_error_asks_the_user_and_the_reply_retries_the_step() {
let e = env("hx-error"); let e = env("hx-error");
let m = ctl_machine(LIMIT_MACHINE); // the state has a catch: an hx error must not be filed under it
let m = ctl_machine(&LIMIT_MACHINE.replace(
"next = \"done\"",
"next = \"done\"\ncatch = { ToolDenied = \"done\" }",
));
create(&e.db, &e.dir.join("wt"), "t", "", "m").unwrap(); create(&e.db, &e.dir.join("wt"), "t", "", "m").unwrap();
let user = answerer(e.dir.join("orch.db"), &["reply: logged in again"]);
let p = fake("FAKE_MODE=error"); let p = fake("FAKE_MODE=error");
assert_eq!( run_session(&e.db, &m, "s1", &e.repo, "", &p).unwrap();
run_session(&e.db, &m, "s1", &e.repo, "", &p).unwrap(), let seen = user.join().unwrap();
"failed" assert_eq!(seen.len(), 1);
assert_eq!(seen[0].0, "input");
assert!(
seen[0].1["detail"]
.as_str()
.unwrap()
.contains("hit the error")
); );
let ev = e.db.events(Some("s1"), 0).unwrap(); let ev = e.db.events(Some("s1"), 0).unwrap();
assert!(ev.iter().all(|v| v.kind != "budget" && v.kind != "goto")); assert!(
ev.iter()
.all(|v| !matches!(v.kind.as_str(), "budget" | "goto" | "catch"))
);
let ok = ev
.iter()
.filter(|v| v.kind == "step" && v.payload["ok"] == true);
assert_eq!(ok.count(), 1, "the retried step finished");
let _ = std::fs::remove_dir_all(&e.dir); let _ = std::fs::remove_dir_all(&e.dir);
} }
+2 -2
View File
@@ -9,7 +9,7 @@ Behaviour per `hx/step`, chosen with FAKE_MODE (orch passes FAKE_* through the p
slow works until hx/interrupt (records hx/message and hx/compact in messages.txt / compact.txt), then slow works until hx/interrupt (records hx/message and hx/compact in messages.txt / compact.txt), then
answers done; a retried step with context.hint finishes at once answers done; a retried step with context.hint finishes at once
limit step_result blocked, no catch, reason "limit" (hx hit a limit from hx/step) limit step_result blocked, no catch, reason "limit" (hx hit a limit from hx/step)
error step_result blocked, no catch, reason "error" error step_result blocked, no catch, reason "error"; finishes when the retried step has a context.hint
crash exits without a step_result crash exits without a step_result
FAKE_UNDERSCORE=1 sends every custom method as `_hx/...`. FAKE_UNDERSCORE=1 sends every custom method as `_hx/...`.
FAKE_USAGE="ctx_used,ctx_limit,cost" makes every step report that usage first. FAKE_USAGE="ctx_used,ctx_limit,cost" makes every step report that usage first.
@@ -90,7 +90,7 @@ def step(params):
if mode == "needs_input" and not params.get("context", {}).get("hint"): if mode == "needs_input" and not params.get("context", {}).get("hint"):
note("hx/step_result", {"status": "needs_input", "question": "Which provider?"}) note("hx/step_result", {"status": "needs_input", "question": "Which provider?"})
return return
if mode in ("limit", "error"): # blocked without a catch, only the reason differs if mode == "limit" or mode == "error" and not params.get("context", {}).get("hint"): # blocked without a catch, only the reason differs
note("hx/step_result", {"status": "blocked", "reason": mode, "summary": f"hit the {mode}"}) note("hx/step_result", {"status": "blocked", "reason": mode, "summary": f"hit the {mode}"})
return return
blocked = mode == "blocked" blocked = mode == "blocked"