Skip to content

[bugfix] agent: fix stalled Default replies and scope tool guidance - #275

Merged
FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
wuzhf9:dev
Nov 10, 2026
Merged

FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
wuzhf9:dev

Conversation

@wuzhf9

@wuzhf9 wuzhf9 commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Default Agent 的模型网关原先依靠关闭连接表示 HTTP 响应结束。内置 OpenCode 1.19.5 / Bun 1.4.4 在收到全部字节后仍无法结束 body reader,导致对话卡住,约 300 秒后重试相同上下文。

  • 网关改用 HTTP chunked 编码并保持增量转发;仅在上游正常结束后发送终止块。异常断流、取消和正常完成分别处理,保留错误状态及已有内容,记录传输结束、取消和字节数。
  • 加固思考内容的轨迹解析,避免异常元数据影响正文转发;连接清理错误不覆盖原始失败或取消。
  • 将交付总结要求移入共享系统提示,不再附加到用户消息;仅在任务需要项目能力时执行 CLI 发现。提示词调整覆盖各运行器,网关修复仅影响 Default。
  • 增加网关和中英文请求回归,强化真实 bundled OpenCode 的工具回执、请求次数、资产身份及会话续接验证,并加入独立 CI 步骤。更新验证说明和开发经验。

Linked issue

Fixes #274

  • 已关联对应 Bug Issue,合并后关闭。

Labels

  • type:bug、area:agent、area:harness、area:ci。

Test plan

Local:相关测试共 69 项通过。

检查 结果
pytest tests/test_model_gateway.py tests/test_model_reasoning_trace.py tests/test_assistant_conversations.py tests/test_native_runtime.py -q -ra 57 passed;3 项真实 CLI 用例默认跳过,已在下一行单独启用并验证
OPENDIRECTOR_REAL_CLI=1 pytest tests/test_native_runtime.py -k real_opencode -q -ra 3 passed;实际 bundled OpenCode + 模拟模型,包含工具结果续接、资产落盘、会话恢复和超时进程清理
pytest tests/test_deepseek_runtime.py tests/test_deepseek_engine.py tests/test_jiuwenswarm_engine.py -q -ra 9 passed,3 skipped;缺少真实 dsh、Windows ACL SDK、JiuwenSwarm 引擎
npm run check:i18n 通过
lint-imports --no-cache 4 项分层契约通过
python scripts/generate_contracts.py --check 通过
git diff --check 通过

本地测试显式加载开发工作树的源码;模型服务使用替身,真实 bundled OpenCode 测试使用隔离目录。网关测试覆盖增量输出、UTF-8 内容、错误响应、上游超时/断流、取消、连接清理异常和空响应。请求测试覆盖六种运行器的中英文输入,不把模型替身测试当作模型自主行为的证明。

Left to CI:完整 Release checks、全量 Python/前端测试、构建及浏览器检查;新增 Bundled OpenCode model gateway regression 步骤显式设置 OPENDIRECTOR_REAL_CLI=1,不会仅依赖默认跳过真实 CLI 的测试套件。本 PR 创建时尚未宣称远端 CI 已通过。

Evidence that it works

  • 原始问题的无密钥 Node/Bun 对照、阻塞定位和复现脚本见 [bug] Default Agent:模型网关断连式响应在内嵌 Bun 中无法结束,聊天卡住并在 300 秒后重试 #274。
  • 实际 bundled OpenCode 配合模拟模型,已验证工具结果进入下一次请求,最终正文完整返回;回执中的资产 ID 与项目最终保存的唯一资产一致,请求数量符合预期。
  • 用户已确认真实环境人工复测通过。 该反馈与上述模拟模型验证分别记录。
  • 本 PR 尚未附截图或录屏;不将用户的人工复测反馈描述为已上传的媒体证据。

Provider verification

  • 本地自动化使用模型替身,不调用付费模型;真实环境验证通过来自用户人工反馈,未由本轮 PR 创建流程再次调用真实提供商。

Bilingual UI

  • 没有新增或修改界面词条;保留 Agent 跟随用户语言回复的指导,补充六种运行器的中英文请求保真测试,check:i18n 通过。

@wuzhf9 wuzhf9 added type:bug Something is broken area:agent Agent runtime, assistant chat and tools area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) area:ci Continuous integration and checks labels Nov 10, 2026
@github-actions
github-actions Bot requested a review from FayeSpica November 10, 2026 12:43

@FayeSpica FayeSpica left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please check the voice library CI timeout and add a regression test for the Default greeting that stalled in #274.

Comment thread tests/test_native_runtime.py Resolved
## summary

- Frame loopback model responses with HTTP chunked encoding so the
  bundled runtime can finish reading each response.
- Keep interrupted streams and cancellation distinct from completion,
  preserve local error statuses, and record transport outcomes.
- Run bundled OpenCode gateway regressions in CI and cover streaming,
  cancellation, tool-result continuation and persisted asset identity.
- Keep delivery guidance in shared system instructions and allow
  replies without unnecessary project-tool discovery.

Fixes: ThinkFlowLab#274
@wuzhf9

wuzhf9 commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Investigated the voice-library timeout. The failed run showed eight consecutive open-canvas responses with HTTP 409 after reloading the Chinese scenario. A reload creates a new editing session while the old page releases its lease asynchronously; when that release misses the approximately 2.8-second opening retry budget, initialization fails and the test subsequently times out waiting for the saved indicator.

The full bilingual workflow passed locally. Delaying the old lease release by 4.5 seconds reproduced the eight storage_busy responses and the stuck opening state. This is a separate reload/lease issue in code unchanged by this PR; that workflow does not use the Default model gateway. The original CI log cannot distinguish a delayed release from a lost release request.

The latest Release checks run is passing. We will address lease handoff/recovery and clearer test diagnostics separately; a passing rerun does not mean the race itself is fixed.

@FayeSpica FayeSpica left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@FayeSpica
FayeSpica merged commit 6c7f33d into ThinkFlowLab:main Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools area:ci Continuous integration and checks area:harness Harness and skill integration (Default, OpenCode, Codex, Claude Code, Jiuwen, DSH) type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Default Agent:模型网关断连式响应在内嵌 Bun 中无法结束,聊天卡住并在 300 秒后重试

2 participants