recv: drop wait_seconds from the MCP tool, always an immediate peek
This commit is contained in:
parent
9e7158f593
commit
ceff662d25
6 changed files with 59 additions and 117 deletions
|
|
@ -276,24 +276,21 @@ impl AgentServer {
|
|||
|
||||
#[tool(
|
||||
description = "Pop messages from this agent's inbox. Returns one or more messages, or \
|
||||
an empty marker if nothing is waiting. \n\n\
|
||||
an empty marker if nothing is waiting. Always an immediate 'anything pending?' peek \
|
||||
— never blocks. \n\n\
|
||||
**Single-message default**: with no args (or `max: 1`) you get the next message — \
|
||||
same behaviour the harness uses to drive a turn. Without `wait_seconds` (or with 0) \
|
||||
the call returns immediately — a cheap 'anything pending?' peek. \n\n\
|
||||
**When idle, prefer ending the turn over parking here.** Ending the turn is the \
|
||||
same behaviour the harness uses to drive a turn. \n\n\
|
||||
**When idle, prefer ending the turn over polling here.** Ending the turn is the \
|
||||
ONLY path that observes an in-container todo wake (bash-task completions, matrix \
|
||||
unread, forge activity) — that signal reaches the harness loop between turns, never \
|
||||
a live `recv` call, so parking in `wait_seconds` while a todo lands means sitting \
|
||||
blind until the timeout. Ending the turn also checkpoints your session, and costs no \
|
||||
latency vs. parking for a real inbox message either way — the broker wakes the next \
|
||||
turn just as fast. Reach for a positive `wait_seconds` (capped at 180) only for a \
|
||||
short, deliberate in-turn block — e.g. confirming something you just triggered lands \
|
||||
within seconds — not as the default way to wait for more work. \n\n\
|
||||
a live `recv` call, so looping on `recv` while idle means sitting blind until \
|
||||
something else wakes you. Ending the turn also checkpoints your session, and costs \
|
||||
no latency vs. polling for a real inbox message either way — the broker wakes the \
|
||||
next turn just as fast. \n\n\
|
||||
**Batch drain**: pass `max: N` (capped at 5) to drain up to N messages in one \
|
||||
round-trip. Use this when the wake prompt told you the inbox has more queued, or \
|
||||
any time you expect a burst — one tool call beats N consecutive single recvs. \
|
||||
`wait_seconds` still applies to the FIRST message; once one arrives the call drains \
|
||||
up to `max` in total. Empty result reported the same way regardless of `max`. \n\n\
|
||||
any time you expect a burst — one tool call beats N consecutive single recvs. Empty \
|
||||
result reported the same way regardless of `max`. \n\n\
|
||||
After popping, the result appends a `(N more message(s) pending …)` line whenever the \
|
||||
inbox still has queued messages — so you know whether to drain again (or `ack_until`) \
|
||||
without a separate status check. No line means the inbox is empty."
|
||||
|
|
@ -301,14 +298,13 @@ impl AgentServer {
|
|||
async fn recv(&self, Parameters(args): Parameters<RecvArgs>) -> String {
|
||||
let log = format!("{args:?}");
|
||||
run_tool_envelope("recv", log, async move {
|
||||
let waited = args.wait_seconds.is_some_and(|w| w > 0);
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_core_agent_sock::Request::Recv {
|
||||
wait_seconds: args.wait_seconds,
|
||||
wait_seconds: None,
|
||||
max: args.max,
|
||||
})
|
||||
.await;
|
||||
annotate_retries(format_recv(resp, waited), retries)
|
||||
annotate_retries(format_recv(resp), retries)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue