Config: { } blocks (core, telegram, provider, pool, exit) translated to the flat
reader with source line numbers; flat form still loads; delegate/plugin limits
raised. Pools: failover/balance, used by delegation (tag-safe), by -m and for
the conversation when its provider hits a limit. -m SEL picks a pool, provider,
provider/model or model name; --model-list lists them with served models.
Usage limits: the agent finds the reset and waits (UI: Ctrl-C stops, /resume
goes on; on_limit=fail turns it off).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
50 lines
2.0 KiB
Bash
50 lines
2.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# splinter -- a usage limit is waited out, not reported as a failure.
|
|
#
|
|
# The fake model refuses the first request with 429 and Retry-After: 2. The
|
|
# run must say when it goes on, ask again and print the answer; with
|
|
# on_limit = fail it must fail instead.
|
|
set -u
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-lw-XXXXXX") || exit 1
|
|
P=$((20000 + $$ % 30000))
|
|
trap 'kill $F 2>/dev/null; rm -rf "$D"' EXIT
|
|
fails=0
|
|
check() { d=$1; shift; if "$@"; then :; else echo "FAIL $d"; fails=$((fails + 1)); fi; }
|
|
|
|
mkdir -p "$D/home"
|
|
python3 -I tests/fake_openai_limit.py "$P" "$D/req.log" &
|
|
F=$!
|
|
for i in $(seq 1 50); do
|
|
curl -s -o /dev/null "http://127.0.0.1:$P/x" && break
|
|
sleep 0.2
|
|
done
|
|
|
|
HOME="$D/home" SPLINTER_USAGE_DIR="$D/usage" SPLINTER_COOLDOWN_DIR="$D/cd" \
|
|
./splinter --no-config --no-stream --endpoint "http://127.0.0.1:$P/v1/chat/completions" \
|
|
--model m -p "hallo" </dev/null > "$D/out.txt" 2> "$D/err.txt"
|
|
check "the answer arrives after the wait" grep -q 'weiter gemacht' "$D/out.txt"
|
|
check "it said when it goes on" grep -q 'usage limit reached' "$D/err.txt"
|
|
check "the request was repeated" test "$(grep -c '^request' "$D/req.log")" -ge 2
|
|
|
|
# with on_limit = fail the first refusal ends the run
|
|
rm -f "$D/req.log" "$D/cd"/*
|
|
kill $F 2>/dev/null; wait $F 2>/dev/null
|
|
python3 -I tests/fake_openai_limit.py "$P" "$D/req.log" &
|
|
F=$!
|
|
for i in $(seq 1 50); do
|
|
curl -s -o /dev/null "http://127.0.0.1:$P/x" && break
|
|
sleep 0.2
|
|
done
|
|
printf 'endpoint = http://127.0.0.1:%s/v1/chat/completions\nmodel = m\non_limit = fail\n' "$P" > "$D/home/splinter.conf"
|
|
HOME="$D/home" SPLINTER_USAGE_DIR="$D/usage" SPLINTER_COOLDOWN_DIR="$D/cd" \
|
|
./splinter --config "$D/home/splinter.conf" --no-stream -p "hallo" \
|
|
</dev/null > "$D/out2.txt" 2> "$D/err2.txt"
|
|
check "on_limit = fail does not wait" test ! -s "$D/out2.txt"
|
|
check "on_limit = fail says why" grep -q 'status 429' "$D/err2.txt"
|
|
|
|
if [ "$fails" -eq 0 ]; then echo "test_limit_wait: ok"; exit 0; fi
|
|
cat "$D/err.txt" "$D/err2.txt"
|
|
exit 1
|