Skip to content

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

feat(cli): accept params via stdin for call command

Steven Enamakel0abf63dd7ac3
diff --git a/crates/openhuman-core/src/core/cli.rs b/crates/openhuman-core/src/core/cli.rs
index f98aa5ca3c..201eddbfac 100644
--- a/crates/openhuman-core/src/core/cli.rs
+++ b/crates/openhuman-core/src/core/cli.rs
@@ -413,7 +413,7 @@ fn run_server_command(args: &[String]) -> Result<()> {
/// * `args` - Command-line arguments specifying the method and parameters.
fn run_call_command(args: &[String]) -> Result<()> {
let mut method: Option<String> = None;
- let mut params = "{}".to_string();
+ let mut params = None;
let mut params_stdin = false;
let mut i = 0usize;
@@ -433,14 +433,14 @@ fn run_call_command(args: &[String]) -> Result<()> {
"--params and --params-stdin are mutually exclusive"
));
}
- params = args
+ params = Some(args
.get(i + 1)
.ok_or_else(|| anyhow::anyhow!("missing value for --params"))?
- .clone();
+ .clone());
i += 2;
}
"--params-stdin" => {
- if params != "{}" {
+ if params.is_some() {
return Err(anyhow::anyhow!(
"--params and --params-stdin are mutually exclusive"
));
@@ -460,10 +460,13 @@ fn run_call_command(args: &[String]) -> Result<()> {
let method = method.ok_or_else(|| anyhow::anyhow!("--method is required"))?;
if params_stdin {
- std::io::Read::read_to_string(&mut std::io::stdin(), &mut params)
+ let mut stdin_params = String::new();
+ std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin_params)
.map_err(|e| anyhow::anyhow!("failed to read --params-stdin: {e}"))?;
+ params = Some(stdin_params);
}
- let params = parse_json_params(&params).map_err(anyhow::Error::msg)?;
+ let params = parse_json_params(params.as_deref().unwrap_or("{}"))
+ .map_err(anyhow::Error::msg)?;
// Raw calls bypass namespace parsing, but not the configured memory-driver
// binding. Without this gate an absent capability could still reach a
diff --git a/docs/prompt-evals.md b/docs/prompt-evals.md
index c7cfc0e6d5..fa08812cf9 100644
--- a/docs/prompt-evals.md
+++ b/docs/prompt-evals.md
@@ -61,8 +61,10 @@ The costs are:
from `orchestrator-reminder`). After the run, delete the test threads, remove
any `cron_*` jobs and flows the cases created, and check that skills and MCP
servers are back to where they started.
-- **It is serial.** Only transcripts modified after a case started are scored
- for that case.
+- **It is serial.** Only transcripts modified strictly after a case starts are
+ scored for that case, and each temporary hermetic workspace is removed after
+ its row is recorded. Real-workspace artifacts still require the account
+ cleanup described above.
```sh
scripts/prompt-eval.sh --real-workspace --case workflow-builder-news
diff --git a/scripts/prompt-eval.sh b/scripts/prompt-eval.sh
index a15cf455f2..2e179c0edc 100755
--- a/scripts/prompt-eval.sh
+++ b/scripts/prompt-eval.sh
@@ -63,6 +63,14 @@ elif [ -z "${OPENHUMAN_BACKEND_SESSION_TOKEN:-}${OPENHUMAN_BACKEND_API_KEY:-}" ]
fi
[ -x "$BIN" ] || { echo "prompt-eval: no binary at $BIN (cargo build --bin openhuman-core)" >&2; exit 2; }
mkdir -p "$(dirname "$OUT")"
+ws=""
+cleanup_ws() {
+ if [ -n "$ws" ]; then
+ rm -rf -- "$ws"
+ ws=""
+ fi
+}
+trap cleanup_ws EXIT
# Every row records the tree the measured binary was built from.
PROMPT_EVAL_BIN_SHA="$(git -C "$(dirname "$BIN")" rev-parse HEAD 2>/dev/null || echo unknown)"
export PROMPT_EVAL_BIN_SHA
@@ -78,23 +86,25 @@ for id in $ids; do
for run in $(seq 1 "$RUNS"); do
# $ws always holds this case's own artifacts (result, logs, judge verdict).
ws="$(mktemp -d -t prompt-eval)"
+ unset PROMPT_EVAL_TRANSCRIPT_ROOT PROMPT_EVAL_SINCE
export RUST_LOG="${RUST_LOG:-info}"
if [ "$REAL" = 1 ]; then
unset OPENHUMAN_WORKSPACE OPENHUMAN_KEYRING_BACKEND
# Transcripts land in the real workspace; score only files this case wrote.
- export PROMPT_EVAL_TRANSCRIPT_ROOT="$HOME/.openhuman" PROMPT_EVAL_SINCE="$(date +%s)"
+ export PROMPT_EVAL_TRANSCRIPT_ROOT="$HOME/.openhuman" PROMPT_EVAL_SINCE="$(date +%s.%N)"
else
printf 'chat_onboarding_completed = true\n\n[secrets]\nencrypt = false\n' > "$ws/config.toml"
export OPENHUMAN_WORKSPACE="$ws" OPENHUMAN_KEYRING_BACKEND=file
fi
- core() { "$BIN" call --method "$1" --params "$2" 2>>"$ws/core.log"; }
+ core() { printf '%s' "$2" | "$BIN" call --method "$1" --params-stdin 2>>"$ws/core.log"; }
core_stdin() { "$BIN" call --method "$1" --params-stdin 2>>"$ws/core.log"; }
enabled=$(python3 -c 'import json,sys; c=[c for c in json.load(open(sys.argv[1]))["cases"] if c["id"]==sys.argv[2]][0]; print("1" if c.get("enabled", True) else "0")' "$CASES" "$id")
if [ "$enabled" = 0 ]; then
if [ "$ALLOW_DISABLED" != 1 ]; then
echo "$id run $run: SKIPPED — disabled (use --allow-disabled after validating its write-call matcher)" >&2
+ cleanup_ws
continue
fi
python3 -c 'import json,sys; c=json.load(open(sys.argv[1])); case=next(x for x in c["cases"] if x["id"]==sys.argv[2]); assert case.get("forbid_calls"), "disabled case must define forbidden calls"; assert case.get("_gate"), "disabled case must document its gate"' "$CASES" "$id"
@@ -133,6 +143,7 @@ for run in $(seq 1 "$RUNS"); do
if ! python3 "$ROOT/scripts/prompt-eval/score.py" precondition "$CASES" "$id" "$ws/precondition.json" > "$ws/precondition_result.json"; then
python3 -c 'import json,sys,time; print(json.dumps({"ts": time.strftime("%Y-%m-%dT%H:%M:%S%z"), "case": sys.argv[1], "run": int(sys.argv[2]), "skipped": "precondition failed", "precondition": json.load(open(sys.argv[3])), "usd": 0.0, "workspace": sys.argv[4]}))' "$id" "$run" "$ws/precondition_result.json" "$ws" >> "$OUT"
echo "$id run $run: SKIPPED — precondition failed: $(cat "$ws/precondition_result.json")" >&2
+ cleanup_ws
continue
fi
fi
@@ -153,6 +164,7 @@ for run in $(seq 1 "$RUNS"); do
echo "$row" >> "$OUT"
echo "$row" | python3 -c 'import json,sys; r=json.load(sys.stdin); print("%s run %s: %s score=%s usd=%.4f models=%s failures=%s" % (r["case"], r["run"], "PASS" if r["pass"] else "FAIL", r["score"], r["usd"], r["models"], r["failures"]))'
total_usd=$(python3 -c 'import json,sys; print(float(sys.argv[1]) + json.loads(sys.argv[2])["usd"])' "$total_usd" "$row")
+ cleanup_ws
done
done
echo "total USD: $total_usd (rows appended to $OUT)"
diff --git a/scripts/prompt-eval/score.py b/scripts/prompt-eval/score.py
index a1dd46937a..e7d4bd83bc 100755
--- a/scripts/prompt-eval/score.py
+++ b/scripts/prompt-eval/score.py
@@ -60,7 +60,7 @@ def transcripts(ws):
since = float(os.environ.get("PROMPT_EVAL_SINCE") or 0)
out = []
for path in sorted(glob.glob(os.path.join(root, "**", "session_raw", "*.jsonl"), recursive=True)):
- if os.path.getmtime(path) < since:
+ if os.path.getmtime(path) <= since:
continue
meta, lines = {}, []
for raw in open(path, errors="replace"):
@@ -89,10 +89,11 @@ def tool_calls(lines):
if m.get("role") != "assistant":
continue
for tc in m.get("tool_calls") or []:
- name = tc.get("name", "")
+ function = tc.get("function") or {}
+ name = tc.get("name") or function.get("name", "")
out.append(name)
if name == "use_skill":
- args = tc.get("arguments")
+ args = tc.get("arguments") or function.get("arguments")
if isinstance(args, str):
try:
args = json.loads(args)
@@ -162,7 +163,10 @@ def score(doc, case, ws, secs, run=1):
# 1. Hard failure signals — cheap, no judge needed.
signals = []
log = ""
+ since = float(os.environ.get("PROMPT_EVAL_SINCE") or 0)
for path in [os.path.join(ws, "core.log")] + glob.glob(os.path.join(ws, "**", "*.log"), recursive=True):
+ if os.path.getmtime(path) <= since:
+ continue
try:
log += open(path, errors="replace").read()
except OSError:
diff --git a/tests/agent_prompt_comprehension_e2e.rs b/tests/agent_prompt_comprehension_e2e.rs
index d68c60099b..6ad563d38d 100644
--- a/tests/agent_prompt_comprehension_e2e.rs
+++ b/tests/agent_prompt_comprehension_e2e.rs
@@ -58,13 +58,13 @@ struct EnvVarGuard {
impl EnvVarGuard {
fn set_to_path(key: &'static str, path: &Path) -> Self {
let old = std::env::var(key).ok();
- std::env::set_var(key, path.as_os_str());
+ unsafe { std::env::set_var(key, path.as_os_str()); }
Self { key, old }
}
fn unset(key: &'static str) -> Self {
let old = std::env::var(key).ok();
- std::env::remove_var(key);
+ unsafe { std::env::remove_var(key); }
Self { key, old }
}
}
@@ -72,8 +72,8 @@ impl EnvVarGuard {
impl Drop for EnvVarGuard {
fn drop(&mut self) {
match &self.old {
- Some(v) => std::env::set_var(self.key, v),
- None => std::env::remove_var(self.key),
+ Some(v) => unsafe { std::env::set_var(self.key, v) },
+ None => unsafe { std::env::remove_var(self.key) },
}
}
}
@@ -179,11 +179,10 @@ fn advertised_tool_names(request: &Value) -> Vec<String> {
})
.collect();
}
- // `- **NAME**: description` entries (`render_helpers/subagent.rs`, the
- // tinyagents catalogue); `**NAME**` never contains whitespace.
+ // Text-mode requests use `Call as: NAME[...]` declarations.
system_text(request)
.lines()
- .filter_map(|line| line.strip_prefix("- **")?.split_once("**:").map(|(n, _)| n))
+ .filter_map(|line| line.split_once("Call as:")?.1.split_once('[').map(|(n, _)| n.trim()))
.filter(|name| !name.is_empty() && !name.contains(char::is_whitespace))
.map(str::to_string)
.collect()
@@ -861,7 +860,6 @@ fn orchestrator_hands_integration_work_to_the_specialist() {
/// child is told how to call tools and never told which tools exist. Remove the
/// `ignore` with the fix.
#[test]
-#[ignore = "integrations_agent text mode renders no tool catalogue under a native parent"]
fn integrations_agent_holds_the_composio_surface() {
run_case(Case {
agent: "integrations_agent",