Skip to content

perf(team): lazy warm — only start agent processes on first message#282

Merged
tcp404 merged 3 commits into
mainfrom
investigate/team-warm-mechanism
May 16, 2026
Merged

perf(team): lazy warm — only start agent processes on first message#282
tcp404 merged 3 commits into
mainfrom
investigate/team-warm-mechanism

Conversation

@zhuqingyv

Copy link
Copy Markdown
Contributor

Summary

  • Remove eager restore_all_sessions at app startup that blocked startup for 12-30s (N agents × 4-6s serial warm)
  • Add ensure_session calls in send_message / send_message_to_agent so team sessions are created on-demand when user actually sends a message
  • App startup now takes ~20ms instead of 12-30s

How it works

Before: app start → restore_all_sessions() → serial warm all teams' all agents → ready
After: app start → ready (no team activity). First message → ensure_session (idempotent, mutex-guarded) → warm agents → deliver message

Frontend follow-up needed

Frontend still calls POST /api/conversations/{id}/warmup when entering a team page, which pre-warms agents unnecessarily. This should be removed separately (mnemo keyword: 前端 team 页面进入即预热).

Safety

  • ensure_session is idempotent (contains_key + Mutex prevents concurrent re-entry)
  • event_loop.rs:execute_turn has fallback warmup if agent was killed by idle scanner
  • No message loss: agents can't communicate without session; once session exists, mailbox + event loop are fully wired

Test plan

  • cargo clippy -p aionui-app -p aionui-team -- -D warnings passes
  • cargo build --release succeeds
  • Verified via logs: startup has zero TeamSession/warmup activity
  • Verified: sending message to team triggers lazy ensure_session correctly
  • Verified: ensure_session idempotent on repeated messages

🤖 Generated with Claude Code

zhuqingyu-netizen and others added 3 commits May 16, 2026 15:34
Remove eager restore_all_sessions at startup and add ensure_session
calls in send_message/send_message_to_agent so team sessions are
created on demand rather than blocking app startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dispose_all still cleans up sessions correctly; the test now verifies
cleanup via get_session_scheduler instead of asserting send_message
fails (which now auto-rebuilds via ensure_session).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tcp404 tcp404 merged commit 6281f31 into main May 16, 2026
5 checks passed
@tcp404 tcp404 deleted the investigate/team-warm-mechanism branch May 16, 2026 07:59
This was referenced May 16, 2026
piorpua pushed a commit that referenced this pull request May 16, 2026
🤖 I have created a release *beep* *boop*
---


## [0.1.4](v0.1.3...v0.1.4)
(2026-05-16)


### Features

* **ai-agent:** log every CLI detection + add doctor subcommand
([#285](#285))
([5ef6d0a](5ef6d0a))
* **runtime:** full shell-style command in spawn logs
([#278](#278))
([dd51616](dd51616))


### Bug Fixes

* **ai-agent:** negotiate OpenClaw protocol v3..v4
([#288](#288))
([dfeece0](dfeece0))
* **team:** model routing + schema unification + lazy warm mode
persistence ([#286](#286))
([199a392](199a392))


### Performance Improvements

* **team:** lazy warm — only start agent processes on first message
([#282](#282))
([6281f31](6281f31))


### Code Refactoring

* **app:** extract CLI definitions to cli.rs
([#280](#280))
([5685d52](5685d52))
* **app:** introduce commands/ module with layered bootstrap for
subcommands ([#283](#283))
([1216597](1216597))
* **app:** replace argv sniffing with clap Subcommand for mcp-* helpers
([#277](#277))
([c3d137c](c3d137c))
* **app:** split monolithic lib.rs/main.rs into per-module files
([#284](#284))
([f3462cb](f3462cb))
* rename binary from aionui-backend to aioncli
([#289](#289))
([30eeca3](30eeca3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.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.

3 participants