Skip to content

Invalidate ACP session when opencode.json has changed - #71

Closed
strk-ai-agent wants to merge 2 commits into
ominiverdi:mainfrom
strk-ai-agent:fix/config-invalidation
Closed

Invalidate ACP session when opencode.json has changed#71
strk-ai-agent wants to merge 2 commits into
ominiverdi:mainfrom
strk-ai-agent:fix/config-invalidation

Conversation

@strk-ai-agent

Copy link
Copy Markdown

A running opencode acp child loads its session-local opencode.json once at startup and never reloads it. After a config change the bridge must therefore drop the existing in-memory client and the persisted ACP session mapping so the next message spawns a fresh child that reads the new file.

In BaseConnector.getOrCreateSession, compare the source opencode.json content against the snapshot in the session directory via the new hasOpenCodeConfigChanged helper introduced in #PR1. On a mismatch, call invalidateACPSession before falling through to the existing create / resume path. The session directory itself is preserved so uploads and user-owned files are not touched.

Behaviour:

  • Within a single bridge process: the in-memory session is dropped on the next message for that thread, after which a fresh opencode acp child is spawned with the new config.
  • After bridge restart: the persisted mapping is gone, so the next message creates a fresh session instead of resuming the stale one.

Depends on #PR1 (the content-hash snapshot helper).

Tests: bun test tests/unit/connector-base.test.ts tests/unit/session-utils.test.ts — 106 pass, 0 fail.

Sandro Santilli added 2 commits August 8, 2026 06:29
Previously the bridge copied opencode.json into each per-chat session
directory only when the source mtime was strictly newer than the
target's. This breaks for git checkouts, restores, and edits that
preserve timestamps, leaving the cached snapshot and the running
opencode acp child out of sync with the project's opencode.json.

Replace the mtime-based copyIfNewer helper with copyIfChanged, which
compares SHA-256 of the file contents and refreshes when they differ
(or when no snapshot exists yet). copyOpenCodeConfig now returns
whether anything was refreshed so callers can react.

Also export hasOpenCodeConfigChanged(sessionDir) for callers that
need to decide whether to invalidate an existing session before the
next message is processed.

Assisted-By: MiniMax-M3
A running opencode acp child loads its session-local opencode.json
once at startup and never reloads it. After a config change the bridge
must therefore drop the existing in-memory client and the persisted
ACP session mapping so the next message spawns a fresh child that
reads the new file.

In BaseConnector.getOrCreateSession, compare the source opencode.json
content against the snapshot in the session directory via the new
hasOpenCodeConfigChanged helper. On a mismatch, call
invalidateACPSession before falling through to the existing create /
resume path. The session directory itself is preserved so uploads and
user-owned files are not touched.

Assisted-By: MiniMax-M3
@ominiverdi

Copy link
Copy Markdown
Owner

Closing under the updated contribution policy. The current submission volume and required verification exceed this project’s review capacity, and pull requests from autonomous or delegated agent accounts are no longer accepted. Valid underlying issues may remain open for independent implementation. Please do not revise, reopen, or replace this pull request.

@ominiverdi ominiverdi closed this Aug 10, 2026
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.

3 participants