The `ask` tool asks and the answer -- or "nobody answered" -- becomes the observation. Read class: it changes nothing on the machine, and the authority is the operator, not a gate. Front ends: the chat draws a dialog (options to pick, typed words still count), the protocol carries it as an `ask` event and an `answer` command, MCP returns it from splinter_say and resumes with splinter_answer, the Telegram gateway sends it as a message and takes the next message from an allowed user. What the review of the WIP found, and what this fixes: - -p hung for the full 900 s ask wait: sp_engine_prompt installed engine_ask, but nobody polls events on the synchronous path. cfg.ask now stays NULL there, so the tool answers at once with "nobody can be asked here". Measured: 3 s instead of 900 s (was rc=124 after 20 s). - splinter_say over MCP hung the same way, because tool_say only looked at st.waiting. It now looks at st.asking and returns the question; the client timed out at 15 s before, and the turn was lost. - protocol.c read the question buffer uninitialized when sp_engine_ask returned 0. - turn_ask answered nothing when the window could not be opened, which parked the turn for the full wait. - pick_run computed the list height without the question's rows, so the highlighted row scrolled out of the window (reproduced: after nine Downs no ">" row was on the screen). pick_draw and pick_run now share pick_listtop(). - the Telegram gateway was dead for this tool: it runs its turns on a copy of e->base, where ask was never set, so the model was told "nobody can be asked" while the operator sat in the chat. New tg_ask, verified against a running daemon and covered in test_gateway.sh. - tests/test_ask_ui.sh was untracked and not in make check, so it never ran. A2A keeps no ask channel on purpose: there an approval pauses the task into INPUT_REQUIRED, and the ask signature cannot express a pause -- saying "nobody can be asked" is the honest answer there. Tests: make check green (327 s), including the new test_ask_mcp.sh and test_ask_ui.sh, both wired into make check. test_ask_mcp.sh was verified to fail against the unfixed code (client times out, no result written). make check-asan: 46 binaries clean. make check-tsan: 46 binaries, no races.
68 lines
2.8 KiB
Bash
68 lines
2.8 KiB
Bash
#!/bin/sh
|
|
#
|
|
# splinter -- pools, -m and --model-list.
|
|
#
|
|
# Two fake providers in a failover pool: the first refuses everything with 429,
|
|
# the second answers. The run must end up on the second without waiting.
|
|
set -u
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
. "$(dirname "$0")/sh/port.sh"
|
|
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-pool-XXXXXX") || exit 1
|
|
# Two fakes: one call, both bound before either is released (see free_ports).
|
|
set -- $(free_ports 2)
|
|
PA=$1
|
|
PB=$2
|
|
trap 'kill $FA $FB 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 "$PA" "$D/a.log" always &
|
|
FA=$!
|
|
python3 -I tests/fake_openai_limit.py "$PB" "$D/b.log" &
|
|
FB=$!
|
|
# B refuses its first request too: make it answer at once by priming it
|
|
if ! wait_listen "$PA" "$FA"; then echo "FAIL the first fake never listened"; exit 1; fi
|
|
if ! wait_listen "$PB" "$FB"; then echo "FAIL the second fake never listened"; exit 1; fi
|
|
curl -s -o /dev/null -X POST -d '{}' "http://127.0.0.1:$PB/prime"
|
|
|
|
cat > "$D/home/splinter.conf" <<CONF
|
|
core { default = duo }
|
|
provider first {
|
|
endpoint = http://127.0.0.1:$PA/v1/chat/completions
|
|
model = ma
|
|
tags = [t]
|
|
}
|
|
provider second {
|
|
endpoint = http://127.0.0.1:$PB/v1/chat/completions
|
|
model = mb
|
|
tags = [t]
|
|
}
|
|
pool duo { members = [first, second] strategy = failover }
|
|
CONF
|
|
export HOME="$D/home" SPLINTER_USAGE_DIR="$D/usage" SPLINTER_COOLDOWN_DIR="$D/cd"
|
|
|
|
# the model list names pools and providers
|
|
./splinter --config "$D/home/splinter.conf" --model-list --no-probe </dev/null > "$D/list.txt" 2>&1
|
|
check "the list names the pool" grep -q '^duo .*pool, failover: first second' "$D/list.txt"
|
|
check "the list names a provider" grep -q '^second ' "$D/list.txt"
|
|
check "the list names the default" grep -q '^# default: duo' "$D/list.txt"
|
|
|
|
# -m picks a provider, provider/model overrides the model, unknown is refused
|
|
./splinter --config "$D/home/splinter.conf" -m second --no-stream -p hallo </dev/null > "$D/o1.txt" 2>&1
|
|
check "-m second reaches second" grep -q 'weiter gemacht' "$D/o1.txt"
|
|
check "-m second did not touch first" test ! -s "$D/a.log"
|
|
./splinter --config "$D/home/splinter.conf" -m nope -p x </dev/null > "$D/o2.txt" 2>&1
|
|
check "-m with an unknown name is refused" grep -q "no provider, pool or model 'nope'" "$D/o2.txt"
|
|
|
|
# the pool's first member is at its limit: the run moves on to the second
|
|
rm -f "$D/b.log"; rm -rf "$D/cd" "$D/usage"
|
|
./splinter --config "$D/home/splinter.conf" --no-stream -p hallo </dev/null > "$D/o3.txt" 2>&1
|
|
check "the pool run ends on the second provider" grep -q 'weiter gemacht' "$D/o3.txt"
|
|
check "the first provider was asked" test -s "$D/a.log"
|
|
check "the second provider was asked" test -s "$D/b.log"
|
|
|
|
if [ "$fails" -eq 0 ]; then echo "test_pools: ok"; exit 0; fi
|
|
cat "$D/o1.txt" "$D/o3.txt"
|
|
exit 1
|