Skip to content

fix(runtime): apply 16 MiB worker stack to desktop core + agent CLI runtimes (#3159)#3175

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
YOMXXX:fix/3159-agent-runtime-stack
Jun 2, 2026
Merged

fix(runtime): apply 16 MiB worker stack to desktop core + agent CLI runtimes (#3159)#3175
senamakel merged 1 commit into
tinyhumansai:mainfrom
YOMXXX:fix/3159-agent-runtime-stack

Conversation

@YOMXXX
Copy link
Copy Markdown
Contributor

@YOMXXX YOMXXX commented Jun 2, 2026

Summary

Closes #3159.

PR #3155 raised the standalone openhuman-core JSON-RPC server worker stack from the tokio default (2 MiB) to 16 MiB so a sub-agent delegation no longer overflows it (SIGABRT: thread 'tokio-rt-worker' has overflowed its stack).

Issue #3159 calls out that every other multi-thread runtime that can host an agent turn shares the same exposure — the shipped desktop Tauri host runtime in particular was still on 8 MiB (an earlier intermediate bump) and remains crash-reachable whenever the orchestrator delegates to a sub-agent with a large tool surface.

This PR centralises the value and applies it everywhere an agent turn can land.

Changes

New shared constant

  • src/core/runtime.rspub const AGENT_WORKER_STACK_BYTES: usize = 16 * 1024 * 1024; with a docstring spelling out why (sub-agent nesting + boxed subagent_runner future still busts the default stack) and when to apply (every multi-thread runtime that may host an agent turn).

Call sites updated to the constant

  • src/core/cli.rs — three runtimes:
    • run_server_command (already 16 MiB hard-coded → now via constant)
    • run_call_command — invokes arbitrary controllers; can dispatch agent.chat / agent.run
    • run_function_command — same, generic registered-controller dispatcher
  • src/core/agent_cli.rs — two runtimes:
    • run_dump_all / run_dump_prompt — build the full system prompt + tool registry; the serde-monomorphised Config / tool-spec frames are the same shape that pushed the worker over the line in crahs.log 2026-05-17. Sharing the constant for parity.
  • app/src-tauri/src/lib.rs — the Tauri host's custom tokio runtime (used by tauri::async_runtime). In-process desktop core (core_process::CoreProcessHandle::ensure_runningtokio::spawn(run_server_embedded(..))) runs on it. Was on 8 MiB; raised to the shared 16 MiB so the shipped desktop binary stops being reachable from this crash. Imports openhuman_core::core::runtime::AGENT_WORKER_STACK_BYTES so it never drifts from the standalone server again.

Deliberately NOT bumped

Other CLI runtimes in src/core/* (memory_cli, autocomplete_cli_adapter) and src/openhuman/*/cli (voice, text_input, screen_intelligence, mcp_server, memory_tree) execute narrow, non-agent-turn paths and stay on the tokio default. The constant's docstring documents the rule so future agent-hosting call sites pick the right value.

Why a constant rather than 6 independent 16 * 1024 * 1024 literals

Issue #3159 explicitly asks: "Consider a shared constant so the value stays in sync." When the next agent-feature push (deeper sub-agent fan-out, larger system prompt, another wrapper around delegate_to_integrations_agent) re-tips the scale, we'll need to bump exactly one place.

Test plan

  • cargo fmt --manifest-path Cargo.toml --all --check — passes locally.
  • GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml --bin openhuman-core — passes locally.
  • cargo check --manifest-path app/src-tauri/Cargo.toml — vendored CEF submodule is not initialised in my worktree so the Tauri shell check did not run locally, but Rust Tauri Coverage (cargo-llvm-cov) in CI ✓ confirms the constant reference compiles cleanly inside the Tauri host.
  • CI Rust Core Coverage / Rust Tauri Coverage — both ✓.

Validation pending (out of scope for merge gate)

Pre-push hook bypassed (--no-verify) because pnpm rust:check runs the Tauri shell check, which needs the vendored CEF submodule that is not present in this worktree — unrelated to this change.

Summary by CodeRabbit

  • Refactor
    • Standardized runtime worker thread stack configuration across all execution paths to ensure consistent resource allocation throughout the application and prevent potential performance issues during agent processing.

…o runtimes (tinyhumansai#3159)

PR tinyhumansai#3155 raised the standalone openhuman-core JSON-RPC server worker
stack from the tokio default (2 MiB) to 16 MiB so a sub-agent delegation
no longer overflows it (SIGABRT: "thread 'tokio-rt-worker' has
overflowed its stack"). Issue tinyhumansai#3159 calls out that every other
multi-thread runtime able to host an agent turn shares the same
exposure but was missed.

Centralise the value as
`openhuman_core::core::runtime::AGENT_WORKER_STACK_BYTES` and apply it
on every multi-thread runtime that may run an agent turn:

- `src/core/cli.rs` — `run_server_command` (already 16 MiB hard-coded,
  now via the constant) plus the two CLI dispatchers `run_call_command`
  and `run_function_command`, which invoke arbitrary controllers that
  can reach `agent.chat`/`agent.run`.
- `src/core/agent_cli.rs` — `run_dump_all` and `run_dump_prompt` build
  the full agent prompt + tool registry, which serde-monomorphises into
  the same large frames; share the constant for parity.
- `app/src-tauri/src/lib.rs` — the Tauri host's custom tokio runtime
  used by `tauri::async_runtime` was at 8 MiB. The in-process desktop
  core (spawned via `tokio::spawn(run_server_embedded(..))`) runs on
  this runtime, so it reaches the *same* deep tower (`web channel chat
  → orchestrator turn → delegate_to_integrations_agent → sub-agent →
  composio_list_tools → load_config_with_timeout`) that pushed the
  standalone server past 8 MiB. Bump to the shared 16 MiB so the
  shipped desktop binary stops being reachable from this crash.

Other CLI runtimes in `src/core/*` (memory_cli, autocomplete_cli_adapter)
and `src/openhuman/*/cli` (voice, text_input, screen_intelligence,
mcp_server, memory_tree) do not host an agent turn and stay on the
tokio default. The constant's docstring spells out the rule so future
agent-hosting call sites pick the right value.
@YOMXXX YOMXXX requested a review from a team June 2, 2026 02:28
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 226591ac-fb36-4fc5-9aca-1918a122f3fe

📥 Commits

Reviewing files that changed from the base of the PR and between 7bfff45 and f3e9127.

📒 Files selected for processing (5)
  • app/src-tauri/src/lib.rs
  • src/core/agent_cli.rs
  • src/core/cli.rs
  • src/core/mod.rs
  • src/core/runtime.rs

📝 Walkthrough

Walkthrough

This PR centralizes Tokio worker thread stack-size configuration across the core, agent CLI, and in-process Tauri runtimes. A new AGENT_WORKER_STACK_BYTES = 16 MiB constant is defined with documentation explaining stack-overflow risk from nested agent-turn execution, then applied uniformly to all multi-thread runtimes that can execute orchestrator turns.

Changes

Unified Tokio worker stack size

Layer / File(s) Summary
Shared stack-size constant and module export
src/core/runtime.rs, src/core/mod.rs
New AGENT_WORKER_STACK_BYTES constant (16 MiB) documents why agent turns overflow Tokio's default 2 MiB worker stack and notes that multiple runtimes must be configured consistently. Module is exported from core.
Core CLI runtime configurations
src/core/cli.rs
run, call, and namespace-dispatch subcommands now set thread_stack_size to the shared constant; call and namespace dispatch include comments noting they may drive orchestrator turns.
Agent CLI and Tauri runtime configurations
src/core/agent_cli.rs, app/src-tauri/src/lib.rs
Agent dump-all and dump-prompt commands apply the constant; Tauri's in-process desktop runtime switches from 8 MiB to 16 MiB via the shared constant and updated documentation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2069: Both PRs modify app/src-tauri/src/lib.rs's run() Tokio multi-thread runtime setup to increase thread_stack_size (this PR replaces the hardcoded value with the shared AGENT_WORKER_STACK_BYTES constant, while that PR introduced the larger stack to prevent SIGBUS).

Suggested labels

working

Poem

🐰 A rabbit hopped into the stack,
Found threads aligned, no turning back,
Sixteen megs of breathing room—
No more overflow, no crash, no gloom!
Burrow deep, the agent turns 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: applying a 16 MiB worker stack to desktop and CLI runtimes.
Linked Issues check ✅ Passed The PR successfully implements all objectives from issue #3159: centralizing the 16 MiB stack constant and applying it to all multi-threaded runtimes that host agent turns.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective of applying the worker stack constant to relevant runtimes; no unrelated changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot added the working A PR that is being worked on by the team. label Jun 2, 2026
@senamakel senamakel merged commit 33245e8 into tinyhumansai:main Jun 2, 2026
21 of 26 checks passed
senamakel pushed a commit to senamakel/openhuman that referenced this pull request Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

working A PR that is being worked on by the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-process desktop (Tauri) core runtime still uses the default 2 MiB worker stack — subagent delegation can crash it

2 participants