Skip to content

feat(agent): add control specialists and async subagent spawning#3379

Merged
senamakel merged 6 commits into
tinyhumansai:mainfrom
senamakel:agent-control-specialists
Jun 4, 2026
Merged

feat(agent): add control specialists and async subagent spawning#3379
senamakel merged 6 commits into
tinyhumansai:mainfrom
senamakel:agent-control-specialists

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented Jun 4, 2026

Summary

  • Adds five built-in control specialist agents for task management, settings/system diagnostics, profile/memory, account administration, and screen awareness.
  • Exposes those specialists through the orchestrator subagent inventory so routing creates first-class delegate_* tools instead of relying on the generic tools agent.
  • Adds spawn_async_subagent for fire-and-forget low-attention background subagent work, with lifecycle progress events and worker-thread persistence when available.
  • Collapses spawn_async_subagent rows into subagent timeline rows in the chat runtime UI.

Problem

  • Recent task, settings, account, memory, and screen-intelligence tools were registered but lacked narrow agent ownership, leaving risky mutations mixed into broad tool surfaces.
  • The orchestrator also needed an explicit background subagent primitive for low-attention work that should not block the current user response.

Solution

  • Added dedicated worker-leaf agent definitions with named tool allowlists, focused prompts, and confirmation guidance for risky writes.
  • Registered the new agents in the built-in loader and orchestrator subagents list, with loader tests that guard the new routing surface.
  • Added SpawnAsyncSubagentTool, registered it in all_tools, documented its narrow use in the orchestrator prompt and tools README, and added Rust metadata/error tests.
  • Updated ChatRuntimeProvider and its unit test so async spawn tool calls collapse into the spawned subagent timeline entry.

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.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — N/A: full merged coverage was not run locally; focused Rust/Vitest coverage was added and CI coverage gate will enforce changed-line coverage.
  • Coverage matrix updated — N/A: internal agent registry/orchestration capability routing; no TEST-COVERAGE-MATRIX feature row added/removed/renamed.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no matrix feature IDs apply.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) — N/A: no release-cut smoke surface changed.
  • Linked issue closed via Closes #NNN in the ## Related section — N/A: no GitHub issue was provided for this branch.

Impact

  • Runtime/platform impact: Rust core agent registry/tool surface and React chat timeline only; no migration required.
  • Security: risky tool families move behind narrower agent prompts with read-before-write and confirmation guidance; async subagent tool is execute-level and explicitly disallows current-response-critical work.
  • Compatibility: existing built-in agents and direct tools remain available; this adds new delegate routes and one new orchestration tool.

Related

  • Closes: N/A - no linked issue.
  • Follow-up PR(s)/TODOs: Consider adding an agent/tool coverage audit test that validates named allowlists against the fully registered tool catalog.

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: agent-control-specialists
  • Commit SHA: 286a7f9b2a61964b6d9b60db9c1d6650650586e3

Validation Run

  • pnpm --filter openhuman-app format:check (via pre-push hook; passed)
  • pnpm typecheck (via pre-push hook pnpm compile; passed)
  • Focused tests: pnpm debug unit src/providers/__tests__/ChatRuntimeProvider.test.tsx (40 tests passed); pnpm debug rust agent_registry (passed)
  • Rust fmt/check (if changed): cargo fmt --manifest-path Cargo.toml --check (passed); root Rust checked via cargo check --manifest-path app/src-tauri/Cargo.toml transitive dependency during pre-push, warnings only
  • Tauri fmt/check (if changed): cargo fmt --manifest-path app/src-tauri/Cargo.toml --all --check and cargo check --manifest-path app/src-tauri/Cargo.toml via pre-push hook (passed, warnings only)

Validation Blocked

  • command: git push -u origin agent-control-specialists / git push origin HEAD:refs/heads/agent-control-specialists
  • error: GitHub SSH connection closed/reset after local pre-push validation completed; final explicit branch push used --no-verify to avoid re-running the already-passed hook.
  • impact: Branch is pushed; local validation from the hook completed before retry. CI will rerun remotely.

Behavior Changes

  • Intended behavior change: orchestrator can route task/settings/profile/account/screen requests to dedicated built-in specialists and can start low-attention async background subagents.
  • User-visible effect: async subagent spawns appear as a single subagent timeline row instead of duplicate tool-call plus subagent rows.

Parity Contract

  • Legacy behavior preserved: existing delegate agents, spawn_subagent, spawn_worker_thread, and broad tools agent remain available.
  • Guard/fallback/dispatch parity checks: new built-ins are worker leaves with named tool scopes; async subagent errors on missing registry/agent/prompt and emits existing subagent progress events.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • New Features

    • Background async subagent spawning so tasks can be delegated fire-and-forget.
    • Five new specialist agents: Task Manager, Account Admin, Settings, Profile Memory, and Screen Awareness.
    • Chat timeline now collapses parent/child rows for async delegation for cleaner visualization.
  • Tests

    • Added regression and unit tests covering async spawn behavior and new agent registrations.
  • Documentation

    • Updated prompts and agent guidance for new agents and async delegation usage.

@senamakel senamakel requested a review from a team June 4, 2026 15:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

Warning

Review limit reached

@senamakel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 84 minutes and 49 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b73a66bc-cfd8-446e-a7a4-052c298bd9c3

📥 Commits

Reviewing files that changed from the base of the PR and between 7d185a0 and f14cddf.

📒 Files selected for processing (3)
  • app/src/providers/ChatRuntimeProvider.tsx
  • app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
  • src/openhuman/mcp_server/resources.rs
📝 Walkthrough

Walkthrough

Adds a fire-and-forget spawn_async_subagent tool, registers five specialist built-in agents with configs and prompt builders, wires them into the agent registry and orchestrator (including tool allowlist), updates the Chat UI to collapse async delegation into subagent timeline rows, and adds tests/docs.

Changes

Async subagent delegation and specialist agent system

Layer / File(s) Summary
spawn_async_subagent tool implementation
src/openhuman/agent_orchestration/tools.rs, src/openhuman/agent_orchestration/tools/spawn_async_subagent.rs, src/openhuman/tools/ops.rs
Validates agent_id/prompt, requires active parent context, spawns background worker/Tokio task with parent-context propagation, emits lifecycle events (SubagentSpawnedSubagentCompleted/SubagentFailed), returns {task_id, agent_id, mode: "async", worker_thread_id}, and provides add_background_contract plus unit tests.
Specialist agent definitions
src/openhuman/agent_registry/agents/{account_admin,profile_memory,screen_awareness,settings,task_manager}_agent/*
Five new built-in specialist agents, each with agent.toml, prompt.md, and Rust prompt builder that composes archetype + optional rendered sections; modules export prompt.
Agent registry wiring
src/openhuman/agent_registry/agents/{mod.rs,loader.rs}
Registers the five specialists in BUILTINS, updates agents/mod.rs exports, and extends loader tests to assert orchestrator subagents and specialist invariants (Worker tier leaf, named tools, includes ask_user_clarification, excludes shell).
Orchestrator configuration
src/openhuman/agent_registry/agents/orchestrator/{agent.toml,prompt.md}
Adds the five specialist agent routes to orchestrator subagents and adds spawn_async_subagent to the orchestrator’s named tool allowlist; prompt docs describe allowed async background uses and forbidden scenarios.
Chat UI timeline collapsing
app/src/providers/ChatRuntimeProvider.tsx, app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
findPendingDelegationContext treats spawn_async_subagent like spawn_subagent/delegate_* enabling parent tool row collapse into child subagent row; comment updated and new test verifies lifecycle collapse for streamed prompt → subagent row.
Test coverage and documentation
src/openhuman/agent/harness/builtin_definitions.rs, src/openhuman/tools/ops_tests.rs, src/openhuman/tools/README.md
builtin_definitions test extended with five new agent IDs; tools tests add regression/assertions for spawn_async_subagent; tools README clarified domain-owned tool registration semantics.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as Caller (Agent turn)
  participant SpawnTool as SpawnAsyncSubagentTool
  participant Registry as AgentDefinitionRegistry
  participant Orchestrator as Orchestrator
  participant Worker as Background worker / Tokio task
  Caller->>SpawnTool: execute(agent_id, prompt, ...)
  SpawnTool->>Registry: resolve agent definition (agent_id)
  SpawnTool->>Orchestrator: publish DomainEvent::SubagentSpawned (task_id, agent_id)
  SpawnTool->>Worker: spawn Tokio task with parent context (run_subagent)
  Worker->>Orchestrator: publish SubagentCompleted / SubagentFailed events
  Orchestrator->>Caller: progress events (optional)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • graycyrus

Poem

🐰 I hopped a quiet async trail,
spawned small helpers without avail—
they ran in background, humming true,
while timelines folded, neat and new.
A carrot-cheer for work that grew. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: addition of control specialist agents and async subagent spawning capability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. labels Jun 4, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/agent_orchestration/tools/spawn_async_subagent.rs`:
- Around line 201-210: The progress event currently hardcodes
dedicated_thread=true which misreports persistence when worker_thread_id is
None; update the AgentProgress::SubagentSpawned construction (the block that
sends via progress_sink) to set dedicated_thread = worker_thread_id.is_some()
(or equivalent) so dedicated_thread reflects whether a worker thread was
actually created; keep other fields (agent_id, task_id, mode, prompt_chars,
worker_thread_id, display_name) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7f2fddf-43d8-443a-ba1a-9df65bbf1566

📥 Commits

Reviewing files that changed from the base of the PR and between ce3ac82 and 286a7f9.

📒 Files selected for processing (32)
  • app/src/providers/ChatRuntimeProvider.tsx
  • app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
  • src/openhuman/agent/harness/builtin_definitions.rs
  • src/openhuman/agent_orchestration/tools.rs
  • src/openhuman/agent_orchestration/tools/spawn_async_subagent.rs
  • src/openhuman/agent_registry/agents/account_admin_agent/agent.toml
  • src/openhuman/agent_registry/agents/account_admin_agent/mod.rs
  • src/openhuman/agent_registry/agents/account_admin_agent/prompt.md
  • src/openhuman/agent_registry/agents/account_admin_agent/prompt.rs
  • src/openhuman/agent_registry/agents/loader.rs
  • src/openhuman/agent_registry/agents/mod.rs
  • src/openhuman/agent_registry/agents/orchestrator/agent.toml
  • src/openhuman/agent_registry/agents/orchestrator/prompt.md
  • src/openhuman/agent_registry/agents/profile_memory_agent/agent.toml
  • src/openhuman/agent_registry/agents/profile_memory_agent/mod.rs
  • src/openhuman/agent_registry/agents/profile_memory_agent/prompt.md
  • src/openhuman/agent_registry/agents/profile_memory_agent/prompt.rs
  • src/openhuman/agent_registry/agents/screen_awareness_agent/agent.toml
  • src/openhuman/agent_registry/agents/screen_awareness_agent/mod.rs
  • src/openhuman/agent_registry/agents/screen_awareness_agent/prompt.md
  • src/openhuman/agent_registry/agents/screen_awareness_agent/prompt.rs
  • src/openhuman/agent_registry/agents/settings_agent/agent.toml
  • src/openhuman/agent_registry/agents/settings_agent/mod.rs
  • src/openhuman/agent_registry/agents/settings_agent/prompt.md
  • src/openhuman/agent_registry/agents/settings_agent/prompt.rs
  • src/openhuman/agent_registry/agents/task_manager_agent/agent.toml
  • src/openhuman/agent_registry/agents/task_manager_agent/mod.rs
  • src/openhuman/agent_registry/agents/task_manager_agent/prompt.md
  • src/openhuman/agent_registry/agents/task_manager_agent/prompt.rs
  • src/openhuman/tools/README.md
  • src/openhuman/tools/ops.rs
  • src/openhuman/tools/ops_tests.rs

Comment thread src/openhuman/agent_orchestration/tools/spawn_async_subagent.rs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 4, 2026
@senamakel senamakel merged commit e075320 into tinyhumansai:main Jun 4, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant