recv: None = peek, positive value = opt-in long-poll

old behavior: omitted wait_seconds fell through to the 30s
RECV_LONG_POLL_DEFAULT — claude calling 'is there anything in
my inbox right now?' between actions blocked the turn for half
a minute. flip the semantics: None (or 0) returns immediately,
positive value parks up to MAX (180s, unchanged). cleaner
'peek vs wait' distinction; tool descriptions + agent/manager
prompts updated to point at the new shape.

harness's own serve loops in hive-ag3nt + hive-m1nd relied on
the old default for their inbox poll. they now explicitly pass
wait_seconds: Some(180) to opt into the full park — same
effective behavior as before, just spelled out.

retires the matching TODO under Turn loop.
This commit is contained in:
müde 2026-05-16 03:22:42 +02:00
parent 90df2106bf
commit 06af23c8a4
9 changed files with 53 additions and 45 deletions

View file

@ -205,11 +205,13 @@ impl AgentServer {
#[tool(
description = "Pop one message from this agent's inbox. Returns the sender and body, \
or an empty marker if nothing is waiting. Optional `wait_seconds` long-polls \
for that many seconds (capped at 180) before returning empty default 30. \
Use a long wait_seconds (e.g. 120 or 180) when you have nothing else to do \
it parks the turn until either a message arrives or the timeout fires, which \
is strictly better than a fixed sleep because incoming work wakes you instantly."
or an empty marker if nothing is waiting. Without `wait_seconds` (or with 0) the \
call returns immediately a cheap 'anything pending?' peek. Pass a positive \
`wait_seconds` (capped at 180) to park the turn waiting for new work incoming \
messages wake you instantly, otherwise the call returns empty at the timeout. \
That's strictly better than a fixed shell `sleep`. Typical pattern: when you have \
nothing else useful to do, call `recv(wait_seconds: 180)` to park until \
something arrives."
)]
async fn recv(&self, Parameters(args): Parameters<RecvArgs>) -> String {
let log = format!("{args:?}");
@ -363,10 +365,10 @@ impl ManagerServer {
#[tool(
description = "Pop one message from the manager inbox. Returns sender + body, or \
empty. Optional `wait_seconds` long-polls (capped at 180, default 30) so the \
manager can sit on Recv when there's nothing to do without burning turns \
prefer a long wait (120 or 180) over ending a turn early; you'll wake \
instantly when work arrives."
empty. Without `wait_seconds` (or 0) returns immediately a cheap inbox peek. \
Pass a positive value (capped at 180) to park until either a message arrives \
or the timeout fires; prefer a long wait (120 or 180) over ending a turn \
early when you have nothing else to do."
)]
async fn recv(&self, Parameters(args): Parameters<RecvArgs>) -> String {
let log = format!("{args:?}");