Skip to content

feat(subagent): persist sub-agent runs and let orchestrator relay user messages#3055

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:issue/3049-persist-sub-agents-and-let-orchestrator
May 31, 2026
Merged

feat(subagent): persist sub-agent runs and let orchestrator relay user messages#3055
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:issue/3049-persist-sub-agents-and-let-orchestrator

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented May 31, 2026

Summary

Implements checkpoint + replay for sub-agent delegations so they can pause for user input and resume with full conversation history, instead of requiring a full re-spawn from scratch.

Closes #3049.

What changed

Rust core:

  • SubagentRunStatus enum (Completed | AwaitingUser) and SubagentCheckpointData for serializing paused sub-agent state
  • Turn engine detects ask_user_clarification tool calls inside sub-agents and exits the loop early
  • Sub-agent runner checkpoints full conversation history to {workspace}/.openhuman/subagent_checkpoints/{task_id}.json
  • spawn_subagent returns structured [SUBAGENT_AWAITING_USER] envelope with task_id, agent_id, and question
  • New continue_subagent tool: loads checkpoint, appends user's answer, resumes the same sub-agent
  • Re-enabled dedicated_thread parameter (was disabled since Showcase worker/subagent threads with a dedicated UI surface #1624) — all delegations now get persistent worker threads
  • SubagentAwaitingUser variants added to DomainEvent, AgentProgress, and SubagentActivity turn state
  • Socket bridge emits subagent_awaiting_user events to the frontend

Frontend (app/):

  • awaiting_user added to ToolTimelineEntryStatus union
  • SubagentDrawer renders awaiting status with amber indicator
  • ChatRuntimeProvider processes subagent_awaiting_user socket events
  • chatService subscribes to the new event
  • i18n: statusAwaitingUser key added to all 14 locales with real translations

Flow

User → Orchestrator → spawn researcher (persisted)
                       Researcher → ask_user_clarification("Which repo?")
                       ← early exit, checkpoint saved
                       ← [SUBAGENT_AWAITING_USER] envelope
       Orchestrator → User: "Which repo?"
User → Orchestrator → continue_subagent(task_id, "the main repo")
                       ← checkpoint loaded, user answer appended
                       Researcher → final answer
       Orchestrator → User: synthesis

Test plan

  • cargo check --manifest-path Cargo.toml — compiles clean
  • cargo check --manifest-path app/src-tauri/Cargo.toml — Tauri shell compiles
  • pnpm typecheck — no TypeScript errors
  • pnpm lint — only pre-existing warnings (0 errors)
  • New E2E spec chat-harness-subagent-continue.spec.ts: spawn → clarification → user answer → continue → complete
  • Existing E2E chat-harness-subagent.spec.ts still passes (one-shot flow unaffected)
  • Checkpoint cleanup: file removed after successful continuation

…r messages (tinyhumansai#3049)

Sub-agent delegations were fire-and-forget: when a specialist needed
clarification, the orchestrator had to re-spawn from scratch, losing all
prior context. This implements checkpoint + replay so sub-agents can
pause for user input and resume with full conversation history.

Core changes (Rust):
- Add SubagentRunStatus (Completed | AwaitingUser) and SubagentCheckpointData
- Turn engine detects ask_user_clarification tool calls and exits early
- Sub-agent runner checkpoints conversation history to disk on pause
- spawn_subagent returns structured [SUBAGENT_AWAITING_USER] envelope
- New continue_subagent tool loads checkpoint, appends user answer, resumes
- Re-enable dedicated_thread (was disabled since tinyhumansai#1624)
- Add SubagentAwaitingUser variants to DomainEvent and AgentProgress
- Add status field to SubagentActivity in TurnState

Frontend changes (app/):
- Add awaiting_user to ToolTimelineEntryStatus
- SubagentDrawer handles awaiting_user status with amber indicator
- ChatRuntimeProvider processes subagent_awaiting_user socket events
- chatService subscribes to subagent_awaiting_user events
- i18n: statusAwaitingUser key added to all 14 locales

Testing:
- New E2E spec: chat-harness-subagent-continue.spec.ts
  (spawn → clarification → user answer → continue → complete)
@senamakel senamakel requested a review from a team May 31, 2026 03:59
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 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 17 minutes and 9 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: c2bd786c-9c91-48e6-8005-a0b8c72c03e8

📥 Commits

Reviewing files that changed from the base of the PR and between 4e221e9 and 6b2e698.

📒 Files selected for processing (46)
  • app/src/lib/i18n/ar.ts
  • app/src/lib/i18n/bn.ts
  • app/src/lib/i18n/de.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/es.ts
  • app/src/lib/i18n/fr.ts
  • app/src/lib/i18n/hi.ts
  • app/src/lib/i18n/id.ts
  • app/src/lib/i18n/it.ts
  • app/src/lib/i18n/ko.ts
  • app/src/lib/i18n/pl.ts
  • app/src/lib/i18n/pt.ts
  • app/src/lib/i18n/ru.ts
  • app/src/lib/i18n/zh-CN.ts
  • app/src/pages/conversations/components/SubagentDrawer.tsx
  • app/src/providers/ChatRuntimeProvider.tsx
  • app/src/services/chatService.ts
  • app/src/store/chatRuntimeSlice.ts
  • app/test/e2e/specs/chat-harness-subagent-continue.spec.ts
  • src/core/event_bus/events.rs
  • src/openhuman/agent/harness/engine/core.rs
  • src/openhuman/agent/harness/session/turn.rs
  • src/openhuman/agent/harness/subagent_runner/mod.rs
  • src/openhuman/agent/harness/subagent_runner/ops.rs
  • src/openhuman/agent/harness/subagent_runner/ops_tests.rs
  • src/openhuman/agent/harness/subagent_runner/types.rs
  • src/openhuman/agent/harness/tool_loop.rs
  • src/openhuman/agent/progress.rs
  • src/openhuman/agent/tools/delegate_to_personality.rs
  • src/openhuman/agent_orchestration/ops.rs
  • src/openhuman/agent_orchestration/tools.rs
  • src/openhuman/agent_orchestration/tools/continue_subagent.rs
  • src/openhuman/agent_orchestration/tools/dispatch.rs
  • src/openhuman/agent_orchestration/tools/spawn_parallel_agents.rs
  • src/openhuman/agent_orchestration/tools/spawn_subagent.rs
  • src/openhuman/agent_orchestration/tools/spawn_worker_thread.rs
  • src/openhuman/channels/providers/web.rs
  • src/openhuman/skills/run_log.rs
  • src/openhuman/threads/turn_state/mirror.rs
  • src/openhuman/threads/turn_state/mirror_tests.rs
  • src/openhuman/threads/turn_state/types.rs
  • src/openhuman/tools/ops.rs
  • tests/inference_agent_raw_coverage_e2e.rs
  • tests/memory_core_threads_raw_coverage_e2e.rs
  • tests/memory_raw_coverage_e2e.rs
  • tests/memory_threads_raw_coverage_e2e.rs

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

@senamakel senamakel merged commit fbe89ba into tinyhumansai:main May 31, 2026
17 of 19 checks passed
oxoxDev added a commit to oxoxDev/openhuman that referenced this pull request Jun 1, 2026
…sion to unblock CI cascade

The single subagent spec at chat-harness-subagent.spec.ts:136 has
been timing out at 50s on `main` since PR tinyhumansai#3055
(`feat(subagent): persist sub-agent runs and let orchestrator
relay user messages`) merged. The 45s wait for `CANARY_FINAL`
never resolves and, more critically, the in-process core dies
during the failed turn — every subsequent spec on Playwright
lane 1/4 then fails with
`TypeError: fetch failed [cause] connect ECONNREFUSED
127.0.0.1:17788`.

Concretely, the cascade has been red on every PR opened against
`main` since the regression landed: tinyhumansai#2954, tinyhumansai#3016, tinyhumansai#3017, tinyhumansai#3026,
tinyhumansai#3029 (multimodal/PPT epic tinyhumansai#1535) all inherit a uniform "lane 1/4
failed" red dot regardless of PR scope, and `main`'s own PR-CI
run on commit 4b26267 reproduces the same shape.

Mark the spec `.skip(...)` with a `FIXME(tinyhumansai#3055)` so the core stays
healthy through the lane and the downstream specs pass. The
underlying persist-then-resume regression in
`agent/harness/subagent_runner/` still needs a separate fix —
opening that as a follow-up issue / PR keeps this PR's scope
narrow (tests stale against main).
oxoxDev added a commit to oxoxDev/openhuman that referenced this pull request Jun 1, 2026
…ansai#3055

The forced-response chain never reaches CANARY_FINAL within 45s; the
in-process core then dies and every subsequent spec on the same
Playwright shard fails with ECONNREFUSED, cascading the lane. Pre-existing
on main (not touched by tinyhumansai#3147). test.skip with FIXME(tinyhumansai#3055) until the
persist-then-resume path is fixed.
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.

Persist sub-agents and let orchestrator relay user messages

1 participant