Skip to content

fix(team): converge run-scoped wakes into a run at the enqueue choke-point#690

Merged
piorpua merged 1 commit into
mainfrom
aionissue/fix-2.1.41-136690585-001
Jul 27, 2026
Merged

fix(team): converge run-scoped wakes into a run at the enqueue choke-point#690
piorpua merged 1 commit into
mainfrom
aionissue/fix-2.1.41-136690585-001

Conversation

@piorpua

@piorpua piorpua commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Sentry ELECTRON-3RC ("团队协作: no active team run", reported on AionUi 2.1.41).

Agent-initiated, run-scoped wakes (team_send_message and the same-source team_shutdown_agent) issued during a run-less window no longer hard-reject with no active team run for run-scoped wake (mapped to RuntimeContextMissing) or silently enqueue run-less. They now converge into an active SystemLifecycle team run at the single enqueue choke-point.

This closes the residual variant left open by #680 (38facd70), which converged system/lifecycle wakes but kept the guard as a probe and did not cover the agent-initiated path.

Root cause

A user message opens a team run and the leader enters a long turn. When every batch of that run is judged terminal, apply_work_summary's no_work branch marks the run Completed, so current_active_run_id() returns None while the leader agent is still inside its turn. In this run-less window:

  • team_send_message (→ send_agent_message_from_agent) was hard-rejected by the service-layer guard require_active_team_run_for_team_work.
  • Even without the guard, the agent→agent binding CausalBinding::InheritRunningBatch resolved to team_run_id: None in coordinator.rs::acquire_enqueue when there was no inheritable active batch, so no new run was opened.
  • The same-source team_shutdown_agent used the same binding but skipped the guard, so it silently ran run-less.

A correct fix therefore had to address both the guard rejection and the binding that failed to open a run.

What changed (5 files, +138 / -35)

Production code:

  • crates/aionui-team/src/work_coordinator/coordinator.rs — in acquire_enqueue, the CausalBinding::InheritRunningBatch branch now falls back to bind_system_enqueue when there is no inheritable active run (attach-or-create semantics, matching the adjacent SystemInitiated branch). Behavior is unchanged when there is an inheritable batch; only this one branch changed.
  • crates/aionui-team/src/service.rs — removed the now-obsolete require_active_team_run_for_team_work guard: both its call in send_agent_message_from_agent and the function definition. With the choke-point guaranteeing a run on enqueue, the guard no longer has meaning.

Tests:

  • crates/aionui-team/src/session.rs — updates confined to mod tests (no production change); two existing unit tests updated to the new invariant and renamed.
  • crates/aionui-team/src/team_run/tests.rs — new unit test plus an updated assertion in mcp_message_inherits_the_callers_running_batch_causality.
  • crates/aionui-team/tests/session_service_integration.rs — the former "requires active team run" send test converted to a GREEN regression (renamed); new same-source shutdown regression test added.

Testing

Run in the AionCore worktree; all green:

  • cargo test -p aionui-team — 410 lib tests + all integration suites pass, 0 failed.
  • cargo clippy -p aionui-team -- -D warnings — clean.
  • cargo fmt --all -- --check — no diff.
  • Full pre-push gate (just push) passed: 7480 tests run, 7480 passed, 18 skipped.

Scope and risk

  • No schema/migration impact: team run state is in-memory only.
  • Scope is intentionally bounded. The underlying run/turn lifetime mismatch (apply_work_summary marking a run Completed while the agent is still in a turn) and the separate team_task_update "Task not found" issue are explicitly out of scope; the latter is tracked separately.
  • Residual risk is narrow: a future tool that mis-tags run-scoped work as Background would not be covered by bind_system_enqueue. This is a single-enum-choice review point rather than scattered guards.
  • Manual verification anchor (not covered by automated tests): a real team session where the leader wakes a teammate after the user run completes.

…point

InheritRunningBatch now falls back to bind_system_enqueue when there is no
inheritable active run, so agent-initiated run-scoped wakes (team_send_message
and team_shutdown_agent) land inside a SystemLifecycle run instead of being
hard-rejected with 'no active team run for run-scoped wake' or silently
enqueued run-less. Removes the now-redundant service-layer guard.

Updates two session unit tests that encoded the prior run-less shutdown
behavior to assert the new invariant (shutdown opens a SystemLifecycle run).
@piorpua
piorpua merged commit c6fdcde into main Jul 27, 2026
6 checks passed
@piorpua
piorpua deleted the aionissue/fix-2.1.41-136690585-001 branch July 27, 2026 09:08
ColeMatthewBienek added a commit to ColeMatthewBienek/AionCore that referenced this pull request Jul 27, 2026
…un completions

Upstream iOfficeAI#690 (c6fdcde) fixed the underlying bug — run-scoped wakes now
converge into a SystemLifecycle run at the enqueue choke-point instead of
rejecting with "no active team run for run-scoped wake" before the mailbox
write, which silently lost 5 of 8 teammate deliverables in a live 7-agent
session diagnosed independently against the same root cause.

This adds the delivery-level coverage iOfficeAI#690 does not have:

- run-less teammate->lead send must be PERSISTED to the mailbox and must
  WAKE the recipient with a run-scoped turn (not just open a run)
- permutation loop: repeated sends across run completions, both
  directions, must deliver 100% (persist + wake per message)
- test-only all_messages() accessor on FullMockTeamRepo

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant