Skip to content

fix: send x-opencode-session header for OpenCode Go gateways - #389

Merged
ModerRAS merged 1 commit into
masterfrom
fix/opencode-session-header
Sep 10, 2026
Merged

fix: send x-opencode-session header for OpenCode Go gateways#389
ModerRAS merged 1 commit into
masterfrom
fix/opencode-session-header

Conversation

@ModerRAS

Copy link
Copy Markdown
Owner

问题

OpenCode Go 现在要求每个请求携带 x-opencode-session 请求头(每个会话稳定的 session ID),否则返回 HTTP 400 MissingSessionID,导致 AI Agent 执行失败:
Error from provider (Console Go): Request is missing x-opencode-session and cannot be routed efficiently.

参考: https://opencode.ai/docs/go/#where-can-i-use-it

修复

  • 新增 OpencodeSessionHeaders.Apply() 共享辅助:仅当 gateway 指向 opencode 时,注入 x-opencode-session(聊天路径使用 tsb-{ChatId} 作为会话内稳定 ID,模型列表/向量等无会话路径使用 tsb-global)以及自识别的 User-Agent: TelegramSearchBot/1.0
  • 覆盖 OpenAIService 与 OpenAIResponsesService 的全部请求创建点:聊天(native/XML/resume)、Responses API、模型发现、向量、图片分析
  • 新增 8 个单元测试覆盖 gateway 匹配、非 opencode 网关不受影响、幂等性

验证

  • TelegramSearchBot.LLM 构建通过(0 错误)
  • TelegramSearchBot.LLM.Test 全部 259 个测试通过

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1635566f-0fbd-48ad-85f4-486df28ce535


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.

OpenCode Go now requires a stable x-opencode-session per conversation
(https://opencode.ai/docs/go/#where-can-i-use-it). Add a shared helper
that applies the header (and a self-identifying User-Agent) whenever the
channel gateway points at opencode, using tsb-{ChatId} as the stable
session id for chat paths and tsb-global for models/embeddings.
@ModerRAS
ModerRAS force-pushed the fix/opencode-session-header branch from d901f11 to 8a81411 Compare September 10, 2026 04:46
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

PR Check Report

Summary

Test Results

Platform Status Details
Ubuntu Passed Tests passed, artifacts uploaded
Windows Passed Tests passed, artifacts uploaded

Code Quality

  • Code formatting check
  • Security vulnerability scan
  • Dependency analysis
  • Code coverage collection

Test Artifacts

  • Test results artifacts count: 2
  • Code coverage uploaded to Codecov

Links


This report is auto-generated by GitHub Actions

@ModerRAS
ModerRAS merged commit df1a354 into master Sep 10, 2026
5 checks passed
@ModerRAS
ModerRAS deleted the fix/opencode-session-header branch September 10, 2026 05:00
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.

1 participant