Skip to content

fix(subagent): 兼容 OpenCode 原生 background 参数 - #12

Merged
Hotakus merged 1 commit into
Hotakus:masterfrom
MAakber:fix/issue-11-background-flag
Jul 16, 2026
Merged

fix(subagent): 兼容 OpenCode 原生 background 参数#12
Hotakus merged 1 commit into
Hotakus:masterfrom
MAakber:fix/issue-11-background-flag

Conversation

@MAakber

@MAakber MAakber commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

修改说明

OMOS 2.2.1 使用 OpenCode 原生的
task(..., background: true) 启动后台子代理。

task 工具启动子 session 后会先返回 completed。这时子 session
通常还在运行,所以 SubAgent Magazine 需要继续把条目保持为
running

目前代码只识别旧参数 run_in_background: true,没有处理
background: true。这会导致 OMOS 启动的任务被提前显示为
done

本次修改在两个状态处理位置同时兼容这两个参数:

  • 实时 tool part 更新
  • 历史消息扫描恢复

原有的 session_id / sessionId 检查保持不变。只有确认子 session
已经创建,条目才会继续保持 running,因此启动失败的任务不会一直
卡住。

验证

  • npm run typecheck
  • npm run build
  • 使用 OMOS 2.2.1 启动真实后台任务
  • 任务运行期间保持 running
  • 子 session 进入 idle 后正常变成 done
  • 原有 run_in_background 行为不变

Closes #11

Copilot AI review requested due to automatic review settings July 16, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates SubAgent Magazine’s task-status handling to support OpenCode native background subagents (task(..., background: true)), ensuring tasks are not marked done immediately when the tool call completes but the child session is still running.

Changes:

  • Treat input.background === true the same as legacy input.run_in_background === true when translating tool state completed → done.
  • Apply the compatibility update in both real-time tool-part updates and history-scan recovery logic.
  • Preserve the existing safety guard: only keep running when metadata.session_id / metadata.sessionId confirms a child session was actually spawned.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Hotakus

Hotakus commented Jul 16, 2026

Copy link
Copy Markdown
Owner

感谢你针对该问题的修复,合并pr后,我会尽快推送新版本,感谢你的支持。

@Hotakus Hotakus added the bug Something isn't working label Jul 16, 2026
@Hotakus Hotakus self-assigned this Jul 16, 2026
@Hotakus
Hotakus merged commit eea1346 into Hotakus:master Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] OMOS 的后台任务会被提前标记为完成

3 participants