Repository navigation
fix: restart a wedged OpenCode, guard migrate bootstrap, deprecate in-memory MCP add - #2
Draft
andokivilaid wants to merge 4 commits into
Draft
andokivilaid wants to merge 4 commits into
andokivilaid wants to merge 4 commits into
Conversation
The liveness hysteresis gated an HTTP-unresponsive opencode off (state
`starting`, proxy 503) but never replaced it. Respawn ran only on process
exit, so a child that stayed alive but stopped answering stayed wedged until
a manual /kortix/refresh or a box stop.
- nextWedgeAction (pure): kill when the /session probe AND the
Instance-independent /kortix-liveness-probe both fail continuously for
>= 60 s over >= 3 probes, with a 5 min cooldown between kills. A probe gap
over 30 s (snapshot restore) restarts the run.
- The readiness loop SIGKILLs the child's process group on a kill decision
and logs `[opencode] wedge-kill`. The existing exit handler respawns it and
runs onUnplannedRespawn to finalize the orphaned turn.
- Only a supervised child that has already been heard from is watched;
verification candidates are never watched.
- KORTIX_OPENCODE_WEDGE_KILL=0|false disables it;
KORTIX_OPENCODE_WEDGE_KILL_AFTER_MS overrides the threshold.
- /kortix/diag reports opencode.wedge_kill {kills, lastKillAt,
unresponsiveMs, enabled}.
- Tests: decision-function unit tests, and a process test that SIGSTOPs a
real child and asserts kill, respawn, and the finalize hook.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`local-up` and `preview-up` already refuse the wrong host, but `bootstrap` installed the non-kortix prerequisites (credit RPCs, an auth.users trigger, a basejump stub) into any DATABASE_URL it was given. - assertBootstrapTarget allows loopback and `supabase-db` only; any other host fails before a connection unless `--allow-remote` is passed. - The self-host compose one-shot and the CI schema-bootstrap check use `supabase-db` and are unaffected. - The prod us-east-2 runbook's fresh-project bootstrap now shows the explicit `--allow-remote` command. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`useAddMcpServer` calls OpenCode `POST /mcp`, which keeps the server in
process memory only. The registration is lost on the next OpenCode or
sandbox restart. It is public API, so it stays exported (surface snapshots
unchanged); its JSDoc now carries `@deprecated` and points to the persistent
replacement: `createConnector(projectId, { provider: 'mcp', ... })` /
`kortix.project(id).connectors.create`, with `discoverConnectorAuth` for
OAuth detection.
A source test pins the tag, the reason, and that both named replacements
are real root exports.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The hook posted to OpenCode `POST /mcp`, which keeps the server in process memory only, so a server added through it was lost on the next OpenCode or sandbox restart. Nothing in apps/mobile imports it or AddMcpServerParams. Persistent MCP servers are project connectors (`createConnector` with `provider: 'mcp'` in @kortix/sdk). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the parts of fork work (itsablabla/garza-suna, kageprime/dosco-suna) that apply to the current architecture, rewritten for our code.
Changes
apps/kortix-sandbox-agent-server/src/harness/open-code/lifecycle.ts).startingafter 3 failures, and the proxy served 503. Nothing killed a wedged child (process alive, HTTP unresponsive). The session stayed broken until a manual refresh.nextWedgeActionsends SIGKILL to the process group when both/sessionand/kortix-liveness-probefail for ≥60 s (≥3 probes), with a 5 min cooldown. The existing exit handler respawns the child and finalizes orphaned turns.KORTIX_OPENCODE_WEDGE_KILL=0; thresholdKORTIX_OPENCODE_WEDGE_KILL_AFTER_MS. Counters inGET /kortix/diag→opencode.wedge_kill.migrate bootstraprefuses non-local hosts unless--allow-remoteis passed (packages/db/scripts/migration-target.ts,migrate.ts). Allowed:127.0.0.1,localhost,[::1],supabase-db. Runbook updated.useAddMcpServeris marked@deprecated. It uses OpenCodePOST /mcp, which is in memory only. The replacement iscreateConnector({ provider: 'mcp' }). JSDoc only; the public surface is unchanged.useAddMcpServer.Not ported (with reasons)
lock_timeout, and prod connects directly.Verification
apps/kortix-sandbox-agent-server:bun test src→ 1284 pass / 1 fail.verified-reload-process.e2e.test.ts: 5/15 fails on this branch vs 4/15 with themainlifecycle.opencode-wedge-kill.test.ts(10 unit tests), andopencode-wedge-kill-process.e2e.test.ts(2 tests; sends SIGSTOP to a real child, asserts kill → new pid → stateok; switch off → no kill).packages/db:migration-target.test.ts9/9 pass. A real run against a remote host exits 1 with the refusal message.smoke:installpassed.Not verified
kill -STOP <opencode_pid>from a provider exec, then expect a[opencode] wedge-killlog line within ~70 s andopencode.wedge_kill.kills == 1in/kortix/diag.pnpm test.🤖 Generated with Claude Code