Skip to content

Migrate OpenCode integration to v2 - #69950

Merged
pelikhan merged 2 commits into
mainfrom
pelikhan-opencode-2-integration
Oct 18, 2026
Merged

pelikhan merged 2 commits into
mainfrom
pelikhan-opencode-2-integration

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Why

OpenCode 2 changes its npm package, runtime configuration, and event behavior. Migrate the sample integration using the official v1 migration guide so workflow execution, MCP tools, and session reporting continue to work.

Approach

  • Install @opencode/cli@2.0.26 and use run --standalone to avoid reusing a background server with stale configuration or credentials.
  • Adopt native v2 provider, permission, agent, and MCP configuration while preserving repository JSON/JSONC discovery and direct gateway tools. Map startup/catalog and execution timeouts separately.
  • Parse v2 tool identities and nested exit statuses while retaining v1 artifact compatibility. Recover missing completed-step usage through bounded private session exports without publishing prompts or provider state.
  • Fail explicitly on native step-limit and MCP startup failures, including cases where the CLI exits successfully. Update smoke coverage, documentation, release notes, and generated workflows.

Version and migration notes

2.0.26 was the newest version available from the configured npm registry during validation and is outside the three-day release cooldown. The upstream changelog lists newer releases. V2 does not run LSP servers, and v1 plugins require porting to its new API. Provider restrictions use the experimental.policies location supported by this pin.

Validation

  • make agent-report-progress passed, including impacted Go/JavaScript tests, scoped lint, schema freshness, and workflow drift checks.
  • make fmt, make fmt-cjs, make lint-cjs, make build, and make recompile passed.
  • go test ./pkg/workflow -run '^TestOpenCodeSample' -count=1 passed.
  • Eight targeted JavaScript suites passed with 513 tests, and npm run typecheck passed.
  • ./gh-aw compile smoke-opencode engine-conformance-opencode --strict --no-check-update passed with existing model-alias warnings.
  • Executed the actual pinned CLI against local fixture endpoints for OpenAI/Anthropic routing and usage, shell and direct MCP execution, JSONC preservation, step limits, authentication failure, and MCP startup failure. No GitHub workflow runs were triggered.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 18, 2026 16:48
Copilot AI max review requested due to automatic review settings October 18, 2026 16:48
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · opus55 · 11 AIC · ⌖ 36.2 AIC · ◇ 15.1 AIC · ⊞ 1.9K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · gpt56 · 10.9 AIC · ⌖ 5.46 AIC · ⊞ 14.6K · ◷

Generated by Ponytail Reviewer for #69950

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · sonnet50 · 13.2 AIC · ⌖ 15 AIC · ◇ 6.62 AIC · ⊞ 12.6K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-18T16:51:15Z
review_event: REQUEST_CHANGES
top_themes:
  - over-broad v2 MCP startup failure classification
  - max-turn double counting on replayed step completions
files_reviewed:
  - .github/workflows/shared/opencode.md
  - actions/setup/js/opencode_workflow.test.cjs
  - actions/setup/js/parse_opencode_log.cjs
  - actions/setup/js/parse_opencode_log.test.cjs
  - docs/src/content/docs/reference/engines.md
  - pkg/workflow/opencode_workflow_test.go
comment_count: 2

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 39.8 AIC · ⌖ 6.01 AIC · ⊞ 12.7K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

Requesting changes because this migration still has two correctness regressions that can fail healthy OpenCode runs.

Blocking themes
  • The new v2 MCP startup classifier promotes broad warning matches to hard failures.
  • Live max-turn accounting still keys completed steps by transient part ids, so replayed completions can be double-counted.
  • Static review only: I reviewed the diff and referenced source files, but I did not execute the workflow or tests.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 39.8 AIC · ⌖ 6.01 AIC · ⊞ 12.7K
Comment /review to run again

Comment thread actions/setup/js/parse_opencode_log.cjs Outdated
Comment thread .github/workflows/shared/opencode.md
@pelikhan

Copy link
Copy Markdown
Collaborator Author

@copilot run pr-finisher skill

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /codebase-design (triage fallback heuristic used — pr-triage agent was not invoked; classification derived directly from the diff/meta since this is a focused engine-migration PR). Approving: the migration is solid and well-tested, with only minor robustness/consistency nits left as inline comments.

📋 Key Themes & Highlights

Key Themes

  • Inconsistent null-guarding (opencode.md line 221): unguarded entry.part.state.* access next to a guarded entry.part?.id a few lines later — a malformed/future CLI event could crash the harness with an unhelpful TypeError.
  • Lost error context (opencode.md ~line 260): the session-export execFile failure path discards the original error instead of attaching it via { cause: error }, unlike the pattern used a few lines above for MCP-config parsing.
  • Scattered version-detection heuristic (parse_opencode_log.cjs line 247, repeated at ~74/202/233): v1-vs-v2 format is inferred via typeof part.partID === "string" checks copy-pasted at multiple call sites rather than centralized in one helper.

Positive Highlights

  • ✅ Strong /tdd coverage for the new session-export reconciliation path: valid recovery, malformed exports rejected, and explicit assertions that secrets/prompts/providerState are never leaked via export.
  • ✅ Max-turns detection correctly handles three distinct scenarios (live stream error, live step-count, and reconciled-steps fallback when the CLI omits all step_finish events) — each backed by a dedicated test.
  • ✅ Config schema migration (providers/agents/permissions/mcp.servers/experimental.policies) is applied consistently and documented in engines.md.

None of the findings are blocking; they are robustness/consistency improvements worth a quick follow-up.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 145.2 AIC · ⌖ 15.1 AIC · ⊞ 10.1K
Comment /matt to run again

Comment thread .github/workflows/shared/opencode.md Outdated
Comment thread .github/workflows/shared/opencode.md Outdated
Comment thread actions/setup/js/parse_opencode_log.cjs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The major CLI migration changes runtime contracts and has unresolved correctness issues requiring human review.

5 open issues
What changed in this PR

Migrates gh-aw’s OpenCode sample integration to v2, updating execution, MCP configuration, and session reporting.

Changes:

  • Pins @opencode/cli@2.0.26 and enables standalone execution.
  • Adopts native v2 configuration and event parsing.
  • Adds usage recovery, failure checks, tests, and migration documentation.
File Description
pkg/​workflow/​opencode_workflow_test.go Updates package, version, and execution assertions.
docs/​src/​content/​docs/​reference/​engines.md Documents v2 behavior and limitations.
actions/​setup/​js/​parse_opencode_log.test.cjs Covers v2 events and export projection.
actions/​setup/​js/​parse_opencode_log.cjs Parses v2 identities, failures, and recovered steps.
actions/​setup/​js/​opencode_workflow.test.cjs Tests configuration, reconciliation, and failure handling.
.github/​workflows/​smoke-opencode.md Updates runtime configuration checks.
.github/​workflows/​smoke-opencode.lock.yml Regenerates the smoke workflow for v2.
.github/​workflows/​shared/​opencode.md Implements the v2 engine configuration and harness.
.github/​workflows/​engine-conformance-opencode.lock.yml Regenerates conformance execution for v2.
.github/​workflows/​daily-security-red-team.lock.yml Updates agent and evaluator execution.
.changeset/​patch-opencode-v2.md Adds the migration release note.

Review effort: Max

Comment thread .github/workflows/shared/opencode.md
Comment thread .github/workflows/shared/opencode.md Outdated
Comment thread .github/workflows/shared/opencode.md Outdated
Comment thread actions/setup/js/parse_opencode_log.cjs Outdated
Comment thread actions/setup/js/parse_opencode_log.cjs Outdated
Reconcile assistant replays and compaction usage without duplicate turns, normalize v2 reasoning totals, require explicit MCP failure status, and honor configured working directories. Preserve safe export diagnostics and regenerate runtime harnesses.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original review notification

No separate code change is needed for this status notice. The MCP failure-classification and replay-accounting findings are addressed in their respective inline threads.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original design-gate result

No ADR or code change is requested by this no-action result. I treated it as informational, not as evidence that the remaining review findings were resolved.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original Ponytail result

No code change is needed for this no-action reviewer notice. The actionable findings from the other reviews are handled separately.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original test-quality result

This no-action notice needs no separate code change. Added regressions cover replayed completions, exported usage and compaction accounting, reasoning totals, working-directory handling, and transient versus terminal MCP failures.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original skills-review notification

No separate change is needed for the completion notice. The defensive event guard, safe export-error context, and centralized v2 part detection are addressed in the inline threads.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original comment-memory record

Addressed both recorded themes: explicit terminal MCP failure classification and stable message-based replay accounting. Left the bot-managed memory and metadata unchanged.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Original pr-finisher request

Ran pr-finisher, fixed the actionable review findings, validated locally, and pushed the batch without merging or changing PR readiness. The prior CI snapshot contained no failed checks, only superseded cancellations; CI for the new commit remains unverified.

@pelikhan
pelikhan merged commit 015086c into main Oct 18, 2026
119 checks passed
@pelikhan
pelikhan deleted the pelikhan-opencode-2-integration branch October 18, 2026 17:50

Copilot AI commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Completed the finisher pass and pushed 7db0d01. All ten in-scope review comments have replies, and local validation passed. The provided tools cannot resolve review threads, so the PR remains blocked on thread resolution; CI must also be re-triggered by a maintainer after the push. CodeQL validation timed out.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.92.6

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