feat: add --schema, --max-turns and rpc --ask
- 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>
This commit is contained in:
1 parent
13d914c8c0
commit
dfec176f43
11 files changed
+599
-14
No files matched your search
@@ -0,0 +1,18 @@
|
||||
#!/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"
|
||||
Reference in new issue
Block a user