Repository navigation
fix(opencode-agents): own the HTTP client - #194
Conversation
Callers pass base_url for a running opencode serve. The handler opens its own client, so a caller cannot pass an httpx client or transport. Co-authored-by: alexis <alexis@launchdarkly.com>
|
The cancelled-read ordering test lost its assert and now passes with the |
The loopback fake cannot see that ordering. Record when _next_line finishes and require that before GET /event closes. Poll the loopback server every 0.01s. Co-authored-by: alexis <alexis@launchdarkly.com>
|
The cancelled-read check is on the client now. A patched I took
|
jeffdupont
left a comment
There was a problem hiding this comment.
Thanks, the cancelled-read test now fails with the fix removed, and the suite is back to about 1s. LGTM.
TL;DR: I keep catching my agent trying to shove handler concerns into Vega.
Decision
A caller passes
base_urlfor a runningopencode serve. The handler owns every HTTP call.create_opencode_handlerdoes not accept an httpx client or transport.Boundary
The caller may start
opencode serve, write its runtime config, prepare the workspace and skills, and passbase_url. The handler owns the OpenCode protocol. That covers the HTTP client,GET /eventand its SSE reads,POST /session,POST /session/{id}/messagewith the evaluated model, abort, event reduction, filtering to this session's id, racing a failed message POST, and opening a separate session for each judge. A caller that passes onlybase_urlgets all of it.Vega is audited against this boundary in observability #2547 and the two PRs on top of it.
turnkey.pyhas no httpx, no transport, no placeholder host, no OpenCode routes, no event handling, and noskip_judgesworkaround.test_turnkey.pykeeps a loopback fake ofopencode servethat answers/event,/session, and/message. It plays the server, not the client.Why
Vega was opening its own
httpx.AsyncClientand a custom transport so it could startopencode serveon the first request. That made Vega a special caller. A customer starts the server and passesbase_url. Vega should do the same, and it should not manage httpx.What this PR does not do
opencode serve.How did you test this change?
uv run ruff check,uv run ruff format --check,uv run mypy packages/opencode-agents/src, anduv run pytest packages/opencode-agents/tests(45 passed). The tests talk to a loopback server throughbase_urland the handler's own client.