You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 89e70b8
Browse filesBrowse the repository at this point in the historyBrowse files
fix: keep OpenCode turns alive after rejected tools (#15)
Two failures when the model reaches for OpenCode's own tools, both on
OpenCode 1.18.32.
**500 on structured output.** A turn with several assistant messages was
re-read through `GET /session/:id/message`. That listing also returns
the user message, and OpenCode fails to encode a stored output format on
it (HTTP 400, anomalyco/opencode#26929 and #40169), so any `json_schema`
request where the model tried a tool became a 500. The earlier assistant
messages are now fetched one by one with `GET
/session/:id/message/:messageID`. If that still fails, the gateway
answers from the final message instead of failing the request. The
listing is kept only for the case where the event stream is down and the
message ids are unknown, and the same fallback applies there.
**Empty replies.** A plain permission rejection ends an OpenCode turn,
and rejecting one request also rejects the rest of the session's pending
requests. A model that called several tools at once could therefore stop
before writing anything, and the follow-up replies for those siblings
got 404. The managed backend now sets
`experimental.continue_loop_on_deny`, so each rejection is handed back
to the model. A 404 from a permission or question reply is logged at
debug level as already answered.
Attached servers keep their own config, so they need
`continue_loop_on_deny` set themselves to get the second fix.
## Testing
- `npm run lint`, `npm test` (332 pass). A new integration test drives a
multi-message `json_schema` turn through a fake backend whose listing
returns 400 when a stored message has a format, as OpenCode does. It
fails on `main` and passes here.
- `npm run test:live` against a managed OpenCode 1.18.32 backend: all
checks pass.
- Six tool-baiting prompts (read a file, list files, run `ls`, ask a
question, "fix the bug", web search), each as text and as `json_schema`,
on `big-pickle`:
- `main`: four 500s, one empty reply.
- This branch: 12 of 12 non-empty 200s, with valid JSON for every
structured request.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,7 +229,7 @@ Set values as environment variables or in the config file (same names; see [`con
229
229
|`ALLOW_INSECURE_BACKEND_HTTP`|`false`| Allow a non-loopback `http://` server URL. |
230
230
|`CONFIG_FILE`| see [First start](#first-start)| Where the config file lives (environment variable only). |
231
231
232
-
**Attach mode.**`OPENCODE_SERVER_URL` uses a server you run yourself. The gateway can only reject tool calls that server *asks* permission for; that happens in its own sessions and their subagents. It trusts the server's own permission config, plugins and MCP servers. If that config allows tools without asking, they will run. Use it only with a server configured like the managed one (every permission set to `"ask"`). The managed default is safer. Remote servers must use `https://` unless you set `ALLOW_INSECURE_BACKEND_HTTP`.
232
+
**Attach mode.**`OPENCODE_SERVER_URL` uses a server you run yourself. The gateway can only reject tool calls that server *asks* permission for; that happens in its own sessions and their subagents. It trusts the server's own permission config, plugins and MCP servers. If that config allows tools without asking, they will run. Use it only with a server configured like the managed one: every permission set to `"ask"`, and `experimental.continue_loop_on_deny` set to `true` so a rejected tool does not end the turn with an empty reply. The managed default is safer. Remote servers must use `https://` unless you set `ALLOW_INSECURE_BACKEND_HTTP`.
0 commit comments