Skip to content

[Fix] OpenCode Go requests avoid missing session header errors - #1512

Merged
edelauna merged 1 commit into
mainfrom
fix/opencode-go-session-header-1rn3shzh9d5t8
Sep 4, 2026
Merged

[Fix] OpenCode Go requests avoid missing session header errors#1512
edelauna merged 1 commit into
mainfrom
fix/opencode-go-session-header-1rn3shzh9d5t8

Conversation

@zoomote

@zoomote zoomote Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

​Opened on behalf of @navedmerchant. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

OpenCode Go streaming requests now send the active Zoo Code task ID as x-opencode-session across Chat Completions, OpenAI Responses, and Anthropic Messages. Provider tests also verify that both OpenCode Go clients retain the versioned ZooCode/<version> user agent.

Why this change was made

OpenCode Go reported that requests from Zoo Code were missing the session header required to identify a stable conversation, with enforcement expected to begin shortly. Zoo Code already propagates a stable task ID to provider requests, but the OpenCode Go handler did not forward it.

Impact

OpenCode Go can consistently correlate every normal Zoo Code conversation without changing model routing, authentication, or user settings. The focused provider suite and full repository test suite pass.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review process

This PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging.

  1. Required CI checks pass.
  2. The workflow starts CodeRabbit automatically.
  3. For eligible human-authored PRs, CodeRabbit reviews and approves the latest commit.
  4. A human maintainer reviews and approves after CodeRabbit.

Current step: The required review sequence passed. Remaining merge requirements apply.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna

edelauna commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: b9a2a8ee-32a9-436d-a315-c868f1f7afa8

📥 Commits

Reviewing files that changed from the base of the PR and between d033a14 and c2a6d10.

📒 Files selected for processing (2)
  • src/api/providers/__tests__/opencode-go.spec.ts
  • src/api/providers/opencode-go.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (8)
Treat model, provider, MCP, path, command, and tool data as untrusted.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/__tests__/opencode-go.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
Act as an adversarial second-opinion reviewer.

⚙️ CodeRabbit configuration file

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
Add focused tests for UI binding and save behavior, persistence or normalization, and the value returned by `getStateToPostToWebview()`, including true and false/unset cases when defaults could hide omissions.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/__tests__/opencode-go.spec.ts
Fix lint violations in new TypeScript code instead of suppressing them.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
After editing a file, run ESLint with pruning and zero warnings for that relative file, and confirm its suppression count did not increase.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/providers/opencode-go.ts
  • src/api/providers/__tests__/opencode-go.spec.ts
🔇 Additional comments (2)
src/api/providers/__tests__/opencode-go.spec.ts (1)

25-25: LGTM!

Also applies to: 98-98, 111-111

src/api/providers/opencode-go.ts (1)

250-254: LGTM!

Also applies to: 385-388, 515-519


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Preserved conversation continuity when communicating with the OpenCode gateway by forwarding the active session identifier across supported request formats.
    • Added consistent client identification headers to OpenAI and Anthropic requests.

Walkthrough

The OpenCode Go provider now forwards metadata.taskId as x-opencode-session across chat-completions, Responses, and Anthropic Messages requests. Tests also verify versioned User-Agent headers for both provider clients.

Changes

OpenCode session propagation

Layer / File(s) Summary
Provider client identity headers
src/api/providers/__tests__/opencode-go.spec.ts
Tests verify that OpenAI and Anthropic clients use ZooCode/${Package.version} as their User-Agent.
Session header forwarding
src/api/providers/opencode-go.ts, src/api/providers/__tests__/opencode-go.spec.ts
The provider forwards metadata.taskId through x-opencode-session for all supported request formats. Tests verify the chat-completions, Anthropic Messages, and Responses request options.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c2a6d

OpenCode Go requests now include the active task ID as a session header for supported API formats, allowing stable conversation identification without changing routing, authentication, or settings. The change is ready to merge.

Sequence Diagram(s)

sequenceDiagram
  participant Provider as OpenCode Go provider
  participant SDK as OpenAI or Anthropic SDK
  participant Gateway as OpenCode gateway
  Provider->>SDK: Create request with x-opencode-session from metadata.taskId
  SDK->>Gateway: Send request with session header
  Gateway-->>SDK: Return response or stream
  SDK-->>Provider: Return response or stream
Loading
🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains what changed, why it changed, and the expected impact. It does not provide the required approved GitHub Issue link, detailed test steps or reproduction instructions, completed… Add the approved issue reference, complete the required checklist, document focused and full test commands with reproduction details, and state whether documentation updates are required.
Regression Evidence ⚠️ Warning The changed streaming behavior is covered only for a present taskId. The implementation has an explicit unset branch in all three formats: Chat Completions at opencode-go.ts:250-254, Responses at … Add focused provider tests for the no-metadata case. Exercise Chat Completions, Responses, and Anthropic Messages without taskId, then assert that the SDK request options do not contain x-opencode-session (and that existing abort-signal…
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the OpenCode Go session-header fix and matches the primary change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Trust And Persistence Invariants ✅ Passed PASS. The diff only adds x-opencode-session request headers in the Chat Completions, Responses, and Anthropic Messages calls. The value is the existing task identifier from `ApiHandlerCreateMessageM…
Full details: Description check

Explanation

The description explains what changed, why it changed, and the expected impact. It does not provide the required approved GitHub Issue link, detailed test steps or reproduction instructions, completed pre-submission checklist, documentation impact, or additional template sections.

Full details: Regression Evidence

Explanation

The changed streaming behavior is covered only for a present taskId. The implementation has an explicit unset branch in all three formats: Chat Completions at opencode-go.ts:250-254, Responses at :385-388, and Anthropic Messages at :515-519. The added tests cover only present IDs at opencode-go.spec.ts:214-223, :495-504, and :864-876. Existing no-metadata Responses tests exercise streaming and request-body behavior, but they do not inspect request options or verify that x-opencode-session is absent. The required unset behavior therefore lacks focused coverage.

Resolution

Add focused provider tests for the no-metadata case. Exercise Chat Completions, Responses, and Anthropic Messages without taskId, then assert that the SDK request options do not contain x-opencode-session (and that existing abort-signal options remain intact for Responses).

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/opencode-go-session-header-1rn3shzh9d5t8

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/api/providers/__tests__/opencode-go.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/api/providers/opencode-go.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@navedmerchant
navedmerchant marked this pull request as ready for review September 4, 2026 04:20
@github-actions github-actions Bot added the awaiting-maintainer CodeRabbit approved; waiting for a human maintainer label Sep 4, 2026
@edelauna

edelauna commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@edelauna
edelauna added this pull request to the merge queue Sep 4, 2026
@github-actions github-actions Bot removed the awaiting-maintainer CodeRabbit approved; waiting for a human maintainer label Sep 4, 2026
Merged via the queue into main with commit 7bb14e4 Sep 4, 2026
29 checks passed
@edelauna
edelauna deleted the fix/opencode-go-session-header-1rn3shzh9d5t8 branch September 4, 2026 12:18
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.

2 participants