Skip to content

fix(ai): send OpenCode session and client headers - #10894

Closed
PurpleMyst wants to merge 1 commit into
marimo-team:mainfrom
PurpleMyst:fix/opencode-session-headers
Closed

PurpleMyst wants to merge 1 commit into
marimo-team:mainfrom
PurpleMyst:fix/opencode-session-headers

Conversation

@PurpleMyst

Copy link
Copy Markdown

📝 Summary

Closes #10882

Send an x-opencode-session header using the conversation ID (or the notebook session ID for one-shot endpoints) and identify marimo with its own user agent.

Identification is based on what pi sends as that's a verified client™️.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions; see OpenCode Go session header is not correctly set #10882.
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

OpenCode rejects requests that omit `x-opencode-session` with a
`MissingSessionID` 400, and asks clients to identify themselves. Send
`marimo/<version>` plus `x-opencode-client`, and the conversation's chat ID
as the session.

This covers both the configured `opencode-go` provider and
`mo.ai.llm.openai` pointed at an `opencode.ai` base URL; one-shot completion
requests use the notebook session ID. Because the gateway rejects requests
without a session, a missing or unusable session ID raises rather than being
silently dropped, and a malformed conversation ID is rejected at the API
boundary. User-configured `extra_headers` still take precedence.
@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
marimo-docs Ready Ready Preview Sep 18, 2026 4:03am UTC

Request Review

@PurpleMyst

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@github-actions github-actions Bot added documentation Improvements or additions to documentation bash-focus Area to focus on during release bug bash labels Sep 18, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Light2Dark

Copy link
Copy Markdown
Member

Thanks @PurpleMyst , I've made a more targeted fix based on this PR in #10895. Let us know if anything is missing from that. But thanks for this!

@PurpleMyst

Copy link
Copy Markdown
Author

LGTM :)

@PurpleMyst PurpleMyst closed this Sep 18, 2026
Light2Dark added a commit that referenced this pull request Sep 18, 2026
Recognize the contribution from PR #10894 to the OpenCode Go session and client header integration.

Co-authored-by: PurpleMyst <PurpleMyst@users.noreply.github.com>
Light2Dark added a commit that referenced this pull request Sep 18, 2026
**This pull request was authored by a coding agent.**

## 📝 Summary

Closes #10882. Related: #10894.

OpenCode Go rejects marimo's AI requests because they omit
`x-opencode-session`. Forward the existing AI SDK conversation ID for
chat and cell editing, with notebook-scoped fallback IDs for older
clients and autocomplete. Identify marimo with its user agent and client
header, and allow configured header overrides regardless of
capitalization.

Automatically generated session headers use a SHA-256 digest of the ID,
keeping header values stable, bounded, and safe for HTTP. Explicit
header overrides remain unchanged.

This keeps conversation identity stable across turns without introducing
another session lifecycle or provider-specific validation helpers. Other
providers are unaffected.

## 📋 Pre-Review Checklist

- [x] The bug is tracked in #10882; no public Python API changes.
- [ ] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [ ] Video or media evidence is provided for any visual changes
(optional; no visual changes).

## ✅ Merge Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [x] API schemas and generated TypeScript types have been updated.
- [x] Tests have been added for the changes made.

> Written by GPT-6 on Codex

This branch was successfully deployed

1 active deployment
Preview 7934fc5b Deployed Sep 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode Go session header is not correctly set

2 participants