The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(scripts): extract prompt-size measurement into shared script
Steven Enamakel53754069819f
diff --git a/scripts/README.md b/scripts/README.mdindex faa3fde894..e1316d9a83 100644--- a/scripts/README.md+++ b/scripts/README.md@@ -40,7 +40,6 @@ comments of the scripts inside them.| `pnpm test:inventory` | `generate-test-inventory.mjs` || `pnpm pr:checklist` | `check-pr-checklist.mjs` || `pnpm prompt:report` | `prompt-report.sh` — every agent's fixed prefix (prompt + tool schemas), largest first; report-only |-| `pnpm prompt:eval` | `prompt-eval.sh` — real-model prompt comprehension scenarios; report-only, never run in CI |See `package.json` for the full list, including `i18n:*`, `tauri:ios:*`,`tauri:android:*`, and the `shortcuts/`/`deep-work`/`agent-batch` commandsdiff --git a/scripts/check-prompt-budget.sh b/scripts/check-prompt-budget.shindex c9523c9820..5ea949cd53 100755--- a/scripts/check-prompt-budget.sh+++ b/scripts/check-prompt-budget.sh@@ -72,25 +72,16 @@ TOOL_ATTENTION_BYTES=1600# any change. A fresh empty workspace is the only reproducible baseline; it also# means `integrations_agent` has no connected toolkit and is skipped, which is# correct — its size is a property of the user's account, not of this repo.-WORKSPACE="$(mktemp -d "${TMPDIR:-/tmp}/openhuman-prompt-budget.XXXXXX")"-cleanup() { rm -rf "$WORKSPACE" "${TOOL_LOOKUP:-}" "${TOOL_OVERSIZE:-}"; }+cleanup() { rm -f "${TOOL_LOOKUP:-}" "${TOOL_OVERSIZE:-}"; }trap cleanup EXIT-TARGET_DIR="${CARGO_TARGET_DIR:-target}"-BIN="$TARGET_DIR/debug/openhuman-core"-echo "[prompt-budget] building openhuman-core …" >&2-cargo build --manifest-path Cargo.toml --bin openhuman-core \- --features "$(bash scripts/ci/product-features.sh)" >&2--echo "[prompt-budget] measuring against hermetic workspace $WORKSPACE" >&2# `--hermetic` isolates config and workspace but not HOME: skill discovery still# scans ~/.openhuman/skills and ~/.agents/skills, so one installed skill added# 515 B of `## Installed Skills` to the orchestrator on a dev machine and a# `--write` there baked it into the limits. An empty HOME matches CI.# OPENHUMAN_HOME is dropped too: the agent-definition loader prefers it# over ~/.openhuman.-mkdir -p "$WORKSPACE/home" "$WORKSPACE/workspace"-if ! measured="$(env -u OPENHUMAN_HOME HOME="$WORKSPACE/home" RUST_LOG=error "$BIN" agent prompt-size --workspace "$WORKSPACE/workspace" --hermetic --json)"; then+if ! measured="$(bash scripts/prompt-size-measure.sh)"; thenecho "::error::prompt-size failed to measure" >&2exit 1fidiff --git a/scripts/prompt-report.sh b/scripts/prompt-report.shindex cb3332b3c5..bb05886c9d 100755--- a/scripts/prompt-report.sh+++ b/scripts/prompt-report.sh@@ -4,8 +4,8 @@# not a cost: each prefix is paid only on the turns that agent runs).## Report-only: nothing here fails on a number. The ratchet that does is-# `scripts/check-prompt-budget.sh`, which measures through the same CLI, so the-# two never disagree about a byte.+# `scripts/check-prompt-budget.sh`; both consume the JSON from+# `scripts/prompt-size-measure.sh`, so their setup cannot drift.## Usage: scripts/prompt-report.sh [--workspace <dir>]#@@ -32,13 +32,6 @@ while (( $# )); doesacdone-# Always build: cargo is a no-op when the binary is current, and it is the only-# thing that notices a binary built from older source or a different feature-# set. A default-feature build silently drops `presentation_agent`.-BIN="${CARGO_TARGET_DIR:-target}/debug/openhuman-core"-cargo build --quiet --manifest-path Cargo.toml --bin openhuman-core \- --features "$(bash scripts/ci/product-features.sh)" >&2-# The divisor is read from the Rust constant so the two cannot drift.TOK="$(grep -oE 'EST_BYTES_PER_TOKEN: usize = [0-9]+' \crates/openhuman-core/src/agent/debug/prompt_size.rs | grep -oE '[0-9]+$')" \@@ -46,18 +39,9 @@ TOK="$(grep -oE 'EST_BYTES_PER_TOKEN: usize = [0-9]+' \if [[ -n "$REAL_WORKSPACE" ]]; thenecho "[prompt-report] measuring signed-in workspace $REAL_WORKSPACE" >&2- measured="$(RUST_LOG=error "$BIN" agent prompt-size --workspace "$REAL_WORKSPACE" --json)"+ measured="$(bash scripts/prompt-size-measure.sh --workspace "$REAL_WORKSPACE")"else- # `--hermetic` puts config.toml beside the workspace dir (its parent), so the- # workspace must be a child of the temp dir — see check-prompt-budget.sh.- # HOME is emptied and OPENHUMAN_HOME dropped for the same reason as there:- # `--hermetic` does not stop skill and agent-definition discovery reading- # the user's ~/.openhuman (or $OPENHUMAN_HOME).- TMP="$(mktemp -d "${TMPDIR:-/tmp}/openhuman-prompt-report.XXXXXX")"- trap 'rm -rf "$TMP"' EXIT- mkdir -p "$TMP/home" "$TMP/workspace"- echo "[prompt-report] measuring against hermetic workspace $TMP" >&2- measured="$(env -u OPENHUMAN_HOME HOME="$TMP/home" RUST_LOG=error "$BIN" agent prompt-size --workspace "$TMP/workspace" --hermetic --json)"+ measured="$(bash scripts/prompt-size-measure.sh)"fiTOK="$TOK" python3 - "$measured" <<'PY'diff --git a/scripts/prompt-size-measure.sh b/scripts/prompt-size-measure.shnew file mode 100755index 0000000000..d9bd6f8ade--- /dev/null+++ b/scripts/prompt-size-measure.sh@@ -0,0 +1,25 @@+#!/usr/bin/env bash+# Build the product binary and emit the canonical prompt-size JSON.+set -euo pipefail+cd "$(dirname "${BASH_SOURCE[0]}")/.."+WORKSPACE_ARG=""+while (( $# )); do+ case "$1" in+ --workspace) WORKSPACE_ARG="${2:?--workspace needs a directory}"; shift 2 ;;+ *) echo "unknown flag: $1" >&2; exit 64 ;;+ esac+done+TARGET_DIR="${CARGO_TARGET_DIR:-target}"+BIN="$TARGET_DIR/debug/openhuman-core"+echo "[prompt-size] building openhuman-core …" >&2+cargo build --quiet --manifest-path Cargo.toml --bin openhuman-core \+ --features "$(bash scripts/ci/product-features.sh)" >&2+if [[ -n "$WORKSPACE_ARG" ]]; then+ RUST_LOG=error "$BIN" agent prompt-size --workspace "$WORKSPACE_ARG" --json+else+ TMP="$(mktemp -d "${TMPDIR:-/tmp}/openhuman-prompt-size.XXXXXX")"+ trap 'rm -rf "$TMP"' EXIT+ mkdir -p "$TMP/home" "$TMP/workspace"+ env -u OPENHUMAN_HOME HOME="$TMP/home" RUST_LOG=error \+ "$BIN" agent prompt-size --workspace "$TMP/workspace" --hermetic --json+fi