shareAI-lab / shareAI-lab/learn-claude-code

plan_approval_response 不会唤醒 idle teammate

Open Beginner friendly
#455 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
77.2k
Forks
12.4k
Avg merge
2d 5h
Merged PRs (30d)
6

Description

问题

s16_team_protocols/code.py 中,teammate 的 run()进入 idle loop 后,如果收到 plan_approval_response,只会把审批结果追加到 messages,但不会跳出 idle loop。

结果是:Lead 调用 review_plan() 批准或拒绝计划后,teammate 不会立刻继续执行。它会继续等待下一条消息,除非Lead 额外发送一条普通 message

复现流程

  1. Lead spawn 一个 teammate。
  2. teammate 调用 submit_plan
  3. Lead 调用 review_plan(request_id, approve=True)
  4. teammate 收到 plan_approval_response
  5. teammate 将 [Plan approved] Proceed with the task.
    写入 messages
  6. teammate 继续停留在 idle loop,不会重新调用 LLM。

原因

idle loop 中只有两种情况会跳出:

if shutdown_requested:
    break

if non_protocol:
    ...
    break

但 plan_approval_response 属于 protocol message:

if msg.get("type") in ("shutdown_request",
"plan_approval_response"):
    should_stop = handle_inbox_message(name, msg, messages)

handle_inbox_message() 处理 plan_approval_response 后返回False,因此:

shutdown_requested == False
non_protocol == []

最终不会触发 break。

影响

plan_approval_response 被记录到了上下文,但没有唤醒teammate。

这会导致 plan approval 协议流卡住:

submit_plan
-> Lead review_plan approve
-> teammate receives approval
-> teammate remains idle

期望行为

收到 plan_approval_response 后,teammate 应该跳出 idle loop,回到外层 while,重新调用 LLM,让模型基于批准或拒绝结果继续行动。

可能修复

让 handle_inbox_message() 对 plan_approval_response 返回一个“需要继续执行”的信号,或者在 idle loop 中单独处理:

if msg.get("type") == "plan_approval_response":
    handle_inbox_message(name, msg, messages)
    should_resume = True

然后:

if should_resume:
    break

同时建议避免 idle loop 跳出后继续追加空的 tool_resultuser message。当前代码在非 tool_use 响应后仍可能执行到:

messages.append({"role": "user", "content": results})

其中 results 可能是空列表。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the idle loop and handle_inbox_message() in s16_team_protocols/code.py, then reproduce the submit_plan and review_plan flow described in the issue. Done means a plan_approval_response wakes the teammate, returns to the outer loop, and lets it call the LLM again without adding an empty tool-result message.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai, backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.