-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
status:todoPlanned but not startedPlanned but not started
Description
🔍 发现的问题 / 原始需求描述
当前 opencode-a2a 没有给 A2A 客户端一个显式的“发起子 agent 编排 / 并行 subtask”契约。即使上游 opencode 本体已经支持 subtask part 和 task tool,这些能力目前仍然主要停留在 OpenCode 自身 prompt/runtime 里,A2A 消费方无法稳定、机器可发现地声明“请用某个 subagent 执行一个子任务”或“一次提交多个并行 subtasks”。这会限制更高阶的 agent orchestration 场景。
🛠️ 详细实施方案 (必须包含涉及的文件路径和核心逻辑/伪代码)
- 设计显式 invocation contract,而不是依赖隐式 prompt engineering。
涉及文件:
src/opencode_a2a/contracts/extensions.pysrc/opencode_a2a/server/agent_card.pydocs/guide.md
建议评估两种方案并选一条作为正式契约:
- 方案 A:新增 provider-private JSON-RPC 方法,例如
opencode.subtasks.run - 方案 B:在主聊天请求中引入显式
metadata.shared.orchestration或 provider-private part 映射
- 为单个 subtask 定义稳定输入模型。
涉及文件:
src/opencode_a2a/jsonrpc/params.pysrc/opencode_a2a/jsonrpc/dispatch.pysrc/opencode_a2a/jsonrpc/handlers/subtask_invocation.py(new)src/opencode_a2a/opencode_upstream_client.py
建议输入字段:
agentpromptdescriptioncommand(optional)model(optional)parallel_group(optional)metadata.opencode.directory/ futureworkspacebinding
伪代码:
validate params
resolve owner + directory/workspace boundary
convert request -> upstream subtask part or task tool input
submit to upstream session
return task/message handle + execution metadata
- 显式支持“并行 subtask”批量提交,但要定义上限和结果模型。
涉及文件:
src/opencode_a2a/contracts/extensions.pysrc/opencode_a2a/jsonrpc/handlers/subtask_invocation.py(new)docs/guide.md
建议:
- 支持
items[]批量提交 - 在 contract 中声明
max_parallel_subtasks - 返回结果中显式区分 accepted / rejected / failed 子项
伪代码:
for subtask in items:
validate each item
submit in one upstream session or coordinated session set
collect accepted handles
return {
items: [{client_id, status, handle, error?}],
parallel: true
}
- 明确与
a2a_call、普通message/send、opencode.sessions.command的边界。
涉及文件:
docs/guide.mdsrc/opencode_a2a/contracts/extensions.py
需要明确:
a2a_call是跨 agent / 跨服务调用,不等同于本地 subagent orchestration- 普通主聊天可以“自然触发” subtask,但不是稳定客户端 API
- 新契约面向“客户端显式请求编排”,应有单独的错误码、能力声明和安全限制
🧪 回归测试建议
- 为单 subtask / 批量并行 subtask 增加参数校验、目录边界、owner guard、上游失败映射测试。
- 为 Agent Card / extension params 增加契约测试,验证 invocation model、批量语义和限制声明。
- 增加端到端测试,验证客户端可显式触发一个 subagent 任务,并观察到稳定结果或流式状态。
- 运行
./scripts/doctor.sh。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status:todoPlanned but not startedPlanned but not started