mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
1a676c6d4488fdc1e32b35bb9fb141d5bb8e7bf8
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b2ae12ad02 |
perf(agent): prewarm session integrations before first turn
## Summary
- prewarm session `connected_integrations` from the shared Composio cache during `from_config_*` agent construction
- synthesize delegation tools against the prewarmed integration view so fresh sessions start with the correct `delegate_<toolkit>` surface
- skip the turn-1 integration fetch and delegation-surface rebuild when the builder already had an authoritative cache snapshot
- carry the runtime `Config` snapshot on the session agent so mid-session integration-cache probes stop reloading config on the hot path
- add a regression test for the initialized/hash bookkeeping when integrations are injected onto an agent
## Problem
- Fresh agent sessions were doing avoidable cold-start work inside `Agent::turn()` before the first provider call.
- On a new session, the turn path loaded transcript state, fetched connected integrations, rebuilt delegation tools, fetched learned context, and only then froze the system prompt.
- The integration fetch itself reloaded `Config` inside the hot path, and the session builder always synthesized delegation tools against an empty integration set, guaranteeing a repair pass on turn 1.
- That inflated first-token latency for orchestrator-style sessions even when the Composio cache already had a valid integration snapshot.
## Solution
- Reuse `composio::cached_active_integrations(config)` during session construction to prewarm `connected_integrations` when the shared cache is already warm.
- Build delegation tools against that cached integration slice instead of hardcoding `&[]`, then persist the synthesized-tool name set onto the built `Agent`.
- Track whether a session's integration view is authoritative with `connected_integrations_initialized`; turn 1 now only fetches integrations and refreshes delegation tools when the builder could not prewarm the cache.
- Store the full runtime `Config` snapshot on the session agent so mid-session cache reads and fallback integration fetches do not call `Config::load_or_init()` on the hot path.
- Keep the existing fallback behavior for cold-cache sessions and shared-`Arc` reconciliation failures so correctness stays unchanged when prewarming is unavailable.
## Submission Checklist
> If a section does not apply to this change, mark the item as `N/A` with a one-line reason. Do not delete items.
- [x] Tests added or updated (happy path + at least one failure / edge case) per [Testing Strategy](../gitbooks/developing/testing-strategy.md#failure-path-requirement)
- [x] N/A: diff coverage is enforced by CI; local coverage commands were blocked in this environment (`pnpm` unavailable on PATH, focused Rust tests blocked by missing `cmake`).
- [x] Coverage matrix updated — `N/A: behaviour-only change`
- [x] All affected feature IDs from the matrix are listed in the PR description under `## Related`
- [x] No new external network dependencies introduced (mock backend used per [Testing Strategy](../gitbooks/developing/testing-strategy.md#mock-policy))
- [x] Manual smoke checklist updated if this touches release-cut surfaces ([`docs/RELEASE-MANUAL-SMOKE.md`](../docs/RELEASE-MANUAL-SMOKE.md))
- [x] Linked issue closed via `Closes #NNN` in the `## Related` section
## Impact
- Runtime/platform impact: desktop/in-process core agent sessions.
- Performance: reduces first-turn latency when the Composio cache is already warm by avoiding a redundant integration fetch, avoiding a redundant delegation-tool rebuild, and avoiding `Config::load_or_init()` on subsequent cache probes.
- Compatibility: cold-cache sessions preserve the old fallback behavior and still fetch integrations on turn 1 when no prewarmed snapshot exists.
- Security: no change in privilege or network surface; this only changes when cached integration metadata is reused.
## Related
- Closes:
- Follow-up PR(s)/TODOs:
---
## AI Authored PR Metadata (required for Codex/Linear PRs)
> Keep this section for AI-authored PRs. For human-only PRs, mark each field `N/A`.
### Linear Issue
- Key: N/A
- URL: N/A
### Commit & Branch
- Branch: feat/agent-spawn-depth-gate
- Commit SHA:
|
||
|
|
73ea22e011 |
feat(agent): cap runtime subagent spawn depth at MAX_SPAWN_DEPTH=3 (#2234)
Co-authored-by: Cursor <cursoragent@cursor.com> |