Skip to content

send_and_wait resolves on a sub-agent's session.idle / session.error #2750

Description

@Lukaze

Repo/version: github/copilot-sdk, tag rust/v1.0.14 (e60d903); CLI runtime 1.0.84-5.

Behaviour: A parent turn's send_and_wait returns early, with the wrong result, when a spawned sub-agent fails or goes idle.

Cause: handle_notification (rust/src/session.rs:2256; the waiter arm :2282-2304) takes the send_and_wait waiter on every session.idle / session.error and records every assistant.message as the wait's last message, with no agent_id check. The CLI's subagent bridge re-emits child events on the parent stream carrying the child's agent_id (the CLI runtime re-emits sub-agent events on the parent stream tagged with the child agent_id; session.error is among the re-emitted types), so a child's model-call failure resolves the parent's wait.

Fix shape: Only events with no agent_id (or equal to the root session's) may resolve the waiter or set its last message. Child-tagged idle/error/message events are ignored by the waiter (they still reach on_event).

Regression test: parent wait in flight; inject session.error with a child agent_id → wait NOT resolved; inject root session.idle → resolved.

Downstream: a consumer of this crate carries a local patch for this and cannot drop it until it is fixed upstream.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions