Repository navigation
Commit 914b86d
committed
fix(agents): talk to opencode over the v1 session endpoints
opencode 1.18.x serve drops provider auth (auth.json keys) from LLM
requests made on behalf of sessions created through the v2 API
(/api/session/*): the turn 401s at the provider, the assistant message
lands with finish:"error", and no error event reaches the event stream,
so SDK clients stall until timeout (anomalyco/opencode#47888, reported
here as Waishnav#302).
The v1 endpoints (/session/*) do not have this problem: the same serve
instance, providers, and auth complete turns normally. Switch the
opencode runtime to the v1 client while keeping the shared server
launcher:
- create session via POST /session?directory=<root>
- send prompt via POST /session/{id}/message with parts + agent +
inline model (model refs use modelID instead of id; variant/effort
still rides along and is accepted by 1.18.x)
- read messages via GET /session/{id}/message (full history, no cursor
pagination; reversed to chronological order)
- the v1 prompt blocks until the turn completes, so the wait loop now
only confirms a terminal assistant message
- health probe uses the cheap session list (v1 has no /health)
- permission config trimmed to the fields the v1 agent schema accepts
(edit/bash/webfetch/external_directory)
Verified end to end against a real opencode 1.18.29 serve instance with
a zhipuai-coding-plan (auth.json) provider: agent run completes with a
correct final response where the v2 path 401'd.1 parent c34de7e commit 914b86d
5 files changed
Lines changed: 412 additions & 279 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments