ask: the wait for an answer is the operator's to set, and a late answer is refused

The 900 s wait was not the defect -- a person reads and thinks. Being hard
coded was: a run with no operator attached (an older protocol client that
does not know SP_EV_ASK, a script) lost the turn for fifteen minutes and
nobody could shorten it. Measured before the change: a client that ignores
the event saw the question and then no turn for 10 s.

sp_ask_wait_s() reads $SPLINTER_ASK_TIMEOUT, then ask_timeout from the
config, then SP_ASK_WAIT_S = 900. No upper bound: how long a turn may wait
is the operator's call. Consumers: engine_ask, tg_ask.

protocol.c also dropped sp_engine_answer's return value, so an answer that
arrived after the question was gone (wait expired, turn cancelled) looked
accepted. It now reports "no question is pending", as steer already did.

Test evidence:
- tests/test_ask_timeout.sh (new, wired into make check): with
  SPLINTER_ASK_TIMEOUT=3 the turn returns in 3 s with the "no answer"
  observation instead of parking. Proven red against the old code (env
  ignored: 5 FAILs, the client got no turn at all) and green on the fix.
- ask_timeout in the config file takes effect too: measured 3.1 s against a
  running --serve, so the docs line is not a claim.
- sp_ask_wait_s() edge cases: unset/0/-5/abc -> 900, 1 -> 1, 42 -> 42,
  999999999999 -> clamped.
- make check green (336 s), make check-asan and check-tsan clean (46
  binaries each).
This commit is contained in:
lotherk committed 2026-11-24 09:00:49 +00:00
1 parent 181b2c0638
commit 6debe213c3
16 files changed
+192 -18

No files matched your search

+1
View File
@@ -256,6 +256,7 @@ The `${NAME}` form inserts an environment variable.
| `theme` | `Xresources` (the default: `*foreground`, `*background`, `*color0..15` from `xrdb`), `light`/`dark` (white or black page, black or white text), or a CDE palette name (`splinter --list-themes`) |
| `locale` | language code (`de`, `en`); catalogues live in `share/locale` |
| `autonomous` | `1` runs mutating/destructive tools without asking |
| `ask_timeout` | seconds an `ask` waits for the operator's answer (default 900); `SPLINTER_ASK_TIMEOUT` overrides it for one run. Shorten it for a run with no operator attached, so a turn does not park for the full wait |
| `steps` | tool rounds per turn (default 150) |
| `max_bytes` | conversation budget in bytes, `0` = no limit |
| `compact_threshold` | context tokens past which the next request is compacted (`0` = off); judged by the prompt size the provider reports, which every streamed turn asks for |