Skip to content

feat: wait for a terminal result on result - #136

Merged
joshrotenberg merged 2 commits into
mainfrom
feat/result-wait-135
Nov 1, 2026
Merged

joshrotenberg merged 2 commits into
mainfrom
feat/result-wait-135

Conversation

@joshrotenberg

@joshrotenberg joshrotenberg commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #135.

Changes

  • GenAgentServer.result/3 and Invocations.result/3 take wait_ms: (0 to 600_000, default 0); result/2 is unchanged. Non-keyword options or unknown keys return {:error, :invalid_options}; out-of-range or non-integer waits return {:error, :invalid_wait}.
  • Invocations keeps waiters per pending ID (caller plus timer) and answers with {:noreply, ...}, so other calls are served while callers wait. record_completion/2 replies to every waiter for the ID (completed, failed or cancelled) and cancels their timers. On expiry it drains the inbox first, so a turn that finished since the last poll is not reported pending; then it replies {:ok, :pending}.
  • The two-element {:result, id} call is kept, with a comment, because the control extension's tests send it.
  • result operation: optional wait_ms with minimum: 0, maximum: 600_000 in its schema.
  • Shared HTTP MCP listener: result waits are capped at 5000 ms in schema and at runtime, because the listener's request timeout is 10 s. This matches the existing ask cap there.
  • CLI: result ID --wait MS, with usage, invalid-wait and not-found messages. mix gen_agent_server.ops --remote and mix gen_agent_server.remote size the RPC timeout to the wait plus 30 s.
  • README section; tests for each acceptance item, cancellation, expiry draining, option validation, RPC timeouts and the shared MCP cap.

Checks

On the host: warnings-as-errors compile, format, root tests (127, 118 before), examples/ensemble_patterns.exs, mix gen_agent_server ask echo ci, a prod release, and every extension (control 88, mcp 34, patterns 17, peers 19, public_source 7, schedule 5, selection 8).

How it was made

Second run of docs/working-an-issue.md (#134), with one more step given to agents:

Turn Agent Duration Result
Implement Codex, workspace_write 160 s All seven acceptance items
Review Claude, read-only, separate instance 101 s REQUEST CHANGES with five defects
Revise Codex, same session 56 s Five fixes and regression tests

The review defects were the shared MCP listener's 10 s timeout, the missing schema maximum, CLI messages, unvalidated options, and expiry without draining. The operator corrected one review claim (the two-element call is not dead code) and ran the host gates.

GenAgentServer.result/3 takes wait_ms (0 to 600_000, default 0). A
pending invocation keeps the caller as a waiter; record_completion/2
replies with the terminal result, and expiry drains the inbox before
replying pending. Other calls on the instance are served meanwhile.

The result operation publishes wait_ms with its bounds, the shared MCP
listener caps it at 5000 ms to fit its 10 s request timeout, the CLI
takes result ID --wait MS, and the remote ops task and remote CLI size
their RPC timeout to the wait. Closes #135.
@joshrotenberg
joshrotenberg marked this pull request as ready for review November 1, 2026 04:13
@joshrotenberg
joshrotenberg merged commit 9aa287c into main Nov 1, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: wait for a terminal result on result

1 participant