- hx -p --schema <file> validates the final answer against a JSON schema, with one retry that includes the validation errors - max_turns config key and --max-turns cap the main agent's model calls - hx --mode rpc --ask sends permission requests to the client instead of auto-allowing bash/write/edit calls Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
19 lines
985 B
Bash
19 lines
985 B
Bash
#!/bin/sh
|
|
set -eu
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
tmp=$(mktemp -d)
|
|
trap 'kill $srv 2>/dev/null; rm -rf "$tmp"' EXIT
|
|
port=$((20000 + ($$ + 7) % 20000))
|
|
echo '[[["text","no json here"]],[["text","```json\n{\"name\":\"Ann\"}\n```"]]]' > "$tmp/turns.json"
|
|
python3 "$root/tests/fake_anthropic.py" $port "$tmp/turns.json" & srv=$!
|
|
mkdir -p "$tmp/home/.hx" "$tmp/repo"
|
|
echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json"
|
|
echo '{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}' > "$tmp/schema.json"
|
|
sleep 0.5
|
|
cd "$tmp/repo"
|
|
export HOME="$tmp/home" HX_BASE_URL="http://127.0.0.1:$port"
|
|
out=$("$root/target/debug/hx" -p "who" --schema "$tmp/schema.json" 2> "$tmp/err")
|
|
[ "$out" = '{"name":"Ann"}' ] || { echo "FAIL: schema output: $out"; cat "$tmp/err"; exit 1; }
|
|
curl -s "http://127.0.0.1:$port/" | grep -q 'does not match the schema' || { echo "FAIL: no retry prompt"; exit 1; }
|
|
echo "schema e2e ok"
|