Skip to content

feat: AsyncHttpRunner — kickoff (202) + poll-until-terminal#5

Merged
Velascat merged 2 commits intomainfrom
feat/async-http-runner
May 7, 2026
Merged

feat: AsyncHttpRunner — kickoff (202) + poll-until-terminal#5
Velascat merged 2 commits intomainfrom
feat/async-http-runner

Conversation

@Velascat
Copy link
Copy Markdown
Owner

@Velascat Velascat commented May 7, 2026

Summary

  • New `AsyncHttpRunner` for async-shaped HTTP APIs: POST kickoff returns 202 + run_id, runner polls a status URL until terminal status. Sync from caller's POV (`run()` blocks until done).
  • Wire shape extends existing `http.*` metadata with `http.poll_url_template`, `http.poll_run_id_path`, `http.poll_status_path`, `http.poll_terminal_states`, `http.poll_success_states`, `http.poll_interval_seconds` — strings only, matches RxP metadata typing.
  • Pairs with `runtime_kind="http_async"` from RxP PR #2. This PR depends on that one being merged first so the new literal exists in the published RxP package.
  • Sleep is injectable for deterministic testing; httpx.Client construction matches HttpRunner's posture (short-lived, no global state).

Why

HttpRunner's docstring already explicitly says it's sync-only and tells callers to use `ManualRunner` with a backend dispatcher for async APIs. That workaround is what archon does today — per-call ManualRunner closures synthesizing RuntimeResults. This PR replaces the workaround with a proper async-shaped runner so archon (and anything else with a 202+poll API) can drop the closure dance.

This is the runner part of the AsyncHttpRunner work. Switching archon's invoker to use it is a follow-up PR in OperationsCenter — gated on the archon real-workflow integration design doc that's still pending.

Test plan

  • 18 new tests covering happy paths (kickoff+poll, alternate JSON paths, sync 200 fast path), 5 missing-metadata rejection paths, 3 kickoff error paths (non-202, timeout, run_id extraction), 3 poll error paths (non-200, timeout, status extraction), 2 poll-loop wiring tests (sleep called, zero interval)
  • 56 ER tests pass (was 38; +18 new)
  • Ruff clean

🤖 Generated with Claude Code

Velascat and others added 2 commits May 7, 2026 18:12
Closes the async-shaped HTTP gap that HttpRunner explicitly punted on. Pairs with the new RuntimeKind 'http_async' (RxP PR #2).

Behavior:
- POST kickoff at http.url; expects 202 + JSON body with run_id at configurable dotted path. 200 also accepted (sync result treated as immediately-terminal).
- Substitutes {run_id} in http.poll_url_template, then polls that URL until status (at configurable dotted path) is in terminal_states. Success/failure determined by terminal status membership in success_states.
- Sleep between polls is injectable; defaults to time.sleep. Tests use a no-op or a counter to drive the loop deterministically.
- Sync from caller's POV — run() blocks until terminal or invocation timeout. No global state; each call uses a short-lived httpx.Client.
- Network errors, kickoff non-202/200, run_id extraction failure, poll non-200, status extraction failure, and timeouts each map to distinct error_summary messages.

Wire shape lives in RuntimeInvocation.metadata — strings only, matching RxP metadata typing. Comma-separated lists for terminal/success states keep the schema flat.

18 new unit tests covering happy paths (kickoff+poll, alternate JSON paths, sync 200 fast path), validation/rejection (5 missing-metadata cases), kickoff errors (non-202, timeout, run_id extraction), poll errors (non-200, timeout, status extraction), and poll-loop wiring (sleep called between polls, zero interval). 56 ER tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Velascat Velascat merged commit 1dee1ea into main May 7, 2026
6 checks passed
@Velascat Velascat deleted the feat/async-http-runner branch May 7, 2026 22:15
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.

1 participant