Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(rpc): skip storage for built-in cli commands that only print help

Steven Enamakel59f753176f8d
diff --git a/crates/openhuman-rpc/src/host.rs b/crates/openhuman-rpc/src/host.rs
index f7bcfe3c14..b707b80fd7 100644
--- a/crates/openhuman-rpc/src/host.rs
+++ b/crates/openhuman-rpc/src/host.rs
@@ -131,18 +131,26 @@ fn cli_command_uses_storage(args: &[String], has_cli_handler: impl Fn(&str) -> b
if is_help(command) {
return false;
}
+ let tail: Vec<&str> = rest.collect();
+ // A `-h` / `--help` flag anywhere in the tail asks for help; the word
+ // `help` only does in the function slot (or as the command), never as an
+ // option value.
+ if tail.iter().any(|arg| matches!(*arg, "-h" | "--help")) {
+ return false;
+ }
match command {
"run" | "serve" | "tui" | "chat" | "sentry-test" => false,
- "mcp" | "mcp-server" | "call" | "agent" => true,
- namespace => {
- let tail: Vec<&str> = rest.collect();
- match tail.as_slice() {
- [] => has_cli_handler(namespace),
- [function, ..] if is_help(function) => false,
- [_, flag, ..] if is_help(flag) => false,
- _ => true,
- }
- }
+ // Built-in commands print help when given none.
+ "mcp" | "mcp-server" | "call" | "agent" => match tail.first() {
+ None => false,
+ Some(function) => !is_help(function),
+ },
+ namespace => match tail.as_slice() {
+ [] => has_cli_handler(namespace),
+ [function, ..] if is_help(function) => false,
+ [_, slot, ..] if is_help(slot) => false,
+ _ => true,
+ },
}
}
diff --git a/crates/openhuman-rpc/src/host_tests.rs b/crates/openhuman-rpc/src/host_tests.rs
index d2f6ec3c03..5bbb37bb08 100644
--- a/crates/openhuman-rpc/src/host_tests.rs
+++ b/crates/openhuman-rpc/src/host_tests.rs
@@ -117,6 +117,13 @@ fn cli_storage_is_opened_for_one_shot_commands_only() {
assert!(!uses(&["cron", "help"]));
assert!(!uses(&["cron", "list", "-h"]));
assert!(!uses(&["cron", "list", "--help"]));
+ assert!(!uses(&["agent"]));
+ assert!(!uses(&["agent", "--help"]));
+ assert!(!uses(&["agent", "help"]));
+ assert!(!uses(&["call", "--help"]));
+ assert!(!uses(&["mcp", "-h"]));
+ assert!(uses(&["agent", "chat"]));
+ assert!(!uses(&["cron", "list", "--format", "json", "--help"]));
// `help` as an option value is not a help request.
assert!(uses(&["cron", "add", "--name", "help"]));
assert!(uses(&["--model", "help", "cron", "list"]));
diff --git a/tests/cli_storage_url_e2e.rs b/tests/cli_storage_url_e2e.rs
index 6a272f9c6f..060ac088b2 100644
--- a/tests/cli_storage_url_e2e.rs
+++ b/tests/cli_storage_url_e2e.rs
@@ -70,6 +70,7 @@ fn a_second_process_reads_what_a_one_shot_wrote_to_the_backend() {
cfg!(feature = "storage-file"),
),
];
+ let mut tested = 0;
for (url, driver_built) in &candidates {
if !driver_built {
continue;
@@ -110,7 +111,9 @@ fn a_second_process_reads_what_a_one_shot_wrote_to_the_backend() {
!String::from_utf8_lossy(&classic.stdout).contains("storage-probe"),
"the job lives in the backend, not in files"
);
- return;
+ tested += 1;
+ }
+ if tested == 0 {
+ eprintln!("skipped: no storage driver compiled in (enable storage-sqlite or storage-file)");
}
- eprintln!("skipped: no storage driver compiled in (enable storage-sqlite or storage-file)");
}