Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/provider/sources/opencode_go_source.py" line_range="89-97" />
<code_context>
+ """
+ model = (model or self.get_model()).removeprefix("opencode-go/")
+ delegate = self.delegate
+ extra_headers = {
+ key: value
+ for key, value in (kwargs.pop("extra_headers", None) or {}).items()
+ if key.lower() not in {"user-agent", "x-opencode-session"}
+ }
+ # Calls without a conversation (such as connection tests) are independent.
+ extra_headers["x-opencode-session"] = hashlib.sha256(
+ (kwargs.pop("conversation_id", None) or uuid4().hex).encode()
+ ).hexdigest()
+ return await delegate.text_chat(
+ prompt=prompt,
</code_context>
<issue_to_address>
**issue (bug_risk):** The required `x-opencode-session` value is not sent as an HTTP header for the Chat Completions and Responses adapters. `extra_headers` is inserted into the payload, then those adapters classify the unknown `extra_headers` key as `extra_body`, so OpenCode Go receives it in the JSON request body instead of the request headers and rejects or misidentifies the request.
**Triggers:** When an OpenCode Go Chat Completions or Responses provider sends a request.
**Suggested fix:** Pass `extra_headers` to the SDK request as a top-level request option, rather than placing it in the payload consumed by `_query`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this adds a third-party provider path that sends prompts, images, tool data, and API-authenticated requests to OpenCode Go while creating provider-side sessions keyed by conversation IDs. If the endpoint, protocol, or session handling is wrong, content could be sent to the wrong external service or mixed into a retained session; reverting stops future calls but cannot retract data already transmitted.
Blocking findings: astrbot/core/provider/sources/opencode_go_source.py:97
|
注意到事实上群聊上下文标注图片任务使用一个非稳定的session,考虑到此为一个独立任务语义上也尚可接受,请确定这是否为预期设计 |
…ovider # Conflicts: # astrbot/core/astr_main_agent.py # tests/test_tool_loop_agent_runner.py
|
|
Context.tool_loop_agent forwards extra kwargs to the runner, but reset() never read conversation_id, so plugin-specified identities were silently replaced with random UUIDs and each call produced a new OpenCode session. Accept conversation_id in reset() with three-tier precedence: request.conversation.cid, then the explicit value, then a random UUID.

新增 OpenCode Go 订阅服务接入。OpenCode Go 要求客户端携带自身标识和稳定的对话会话请求头;仅通过通用服务商配置 API 地址和密钥,无法完整满足这些要求,可能导致 Go 订阅无法正常使用。此次添加专用入口,自动补齐所需请求头,并提供 Chat Completions、Responses 和 Messages 三种协议供用户选择
fixes #10054 #10045 #8158
Modifications / 改动点
新增三个 OpenCode Go 服务商模板,复用现有协议适配器。
使用 AstrBot/{版本} 标识客户端,通过具体对话 UUID 的稳定哈希生成 x-opencode-session 请求头。
主请求、工具重查询、上下文压缩、图片描述和标题生成传递所属对话 ID,确保同一对话使用一致标识。
添加中英文接入文档及测试。
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Integrate OpenCode Go subscriptions with dedicated protocol providers and stable conversation-aware request identification.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: