Skip to content

feat(runtime): pool node/python runtime processes across agents and skill runs (#5106)#5129

Merged
senamakel merged 13 commits into
tinyhumansai:mainfrom
YellowSnnowmann:feat/pool-language-runtimes-5106
Jul 23, 2026
Merged

feat(runtime): pool node/python runtime processes across agents and skill runs (#5106)#5129
senamakel merged 13 commits into
tinyhumansai:mainfrom
YellowSnnowmann:feat/pool-language-runtimes-5106

Conversation

@YellowSnnowmann

@YellowSnnowmann YellowSnnowmann commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reuse a small, bounded pool of long-lived node/python workers for inline node_exec/python_exec instead of forking one interpreter child per run (Share/pool the Node and Python runtime processes across agents and skill runs #5106).
  • At K concurrent skill runs the process tree grows by ~one pooled worker, not K interpreters — measured 1 worker / 204 MiB vs 8 children / 701 MiB at K=8 (~490 MiB, 3.4× smaller).
  • New src/openhuman/runtime_pool domain: bounded LangPool (semaphore concurrency + queue backpressure, idle-TTL reaping, recycle-after-N-jobs), newline-JSON worker protocol, node (worker_threads isolation) + python (SIGALRM soft timeout) harnesses.
  • New python_exec agent tool (mirrors node_exec) — makes the python pool live; added to the code_executor / skill_creator / tool_maker allow-lists.
  • [runtime_pool] TOML config + OPENHUMAN_RUNTIME_POOL_* env overrides; default-on with a kill-switch and graceful fallback to the legacy per-call spawn.
  • library-profile skill-run gains a K-concurrency knob + child_count <= max_workers assertion; new scripts/profile/library-pool-gate.sh regression gate.

Problem

A single JS skill step spawns a node child at ~72–75 MB RSS (process tree ~121 MB vs ~51 MB core). At the opencompany target — 100–1000 live agents in a 2 GB / 2 vCPU box — those per-run interpreter children are the single biggest memory-budget breaker: ~25 concurrent node children alone exhaust the box, while the core's own marginal cost is ~0.8–1.8 MiB per agent. The measurement PR (#5107) built the skill-run benchmark that quantified this and filed #5106 for the fix.

Solution

Share the language runtimes instead of spawning per run:

  • Pooled long-lived workers — a bounded set of node/python worker processes (1–2 each by default) serve jobs for all agents. node runs each inline job in an isolated worker_thread (fresh module graph + globals per run, safe terminate() on timeout, process.exit() can't kill the host, isolated stdio so job output never corrupts the protocol). python execs in the worker interpreter (CPython can't safely kill a thread) with SIGALRM best-effort soft timeout + Rust-side hard-timeout backstop; recycle_after_jobs bounds module-state leakage.
  • Queue + backpressure — concurrency beyond pool size queues on a semaphore (surfaced as queue_wait in logs); beyond max_workers + max_queue_depth in-flight, submissions are shed rather than buffered unbounded.
  • Idle reaping — a worker idle past idle_ttl_secs is reaped, so an idle fleet pays zero interpreter RSS.
  • Routingnode_exec inline routes through the pool; a new python_exec tool routes python. script_path / npm_exec / sandboxed runs keep the legacy per-call spawn. Any pool infrastructure error transparently falls back to the legacy spawn.

Design decisions / tradeoffs

  • The pool is a pure optimisation seam: runtime_pool.enabled = false (or per-language / env kill-switch) reverts every caller to the legacy spawn with byte-identical behaviour.
  • Performance: memory win scales with concurrency (the deployment target); at K=1 it is ~break-even (a warm worker ~86 MB incl. its job vs a legacy child ~74 MB; ~12 MB worker_thread isolation overhead) and idle workers stay resident for idle_ttl. Latency is neutral-to-better (worker_thread spin < cold process spawn). The hot path does zero per-call config I/O and zero per-call script I/O — pool config is injected at tool construction and the harness is written once per process.
  • Parity: pooled inline node_exec matches legacy node -e on stdout/stderr split, exit codes, process.exit(n), timeout→kill, require, and cwd-relative fs (the host chdirs before spawning the worker — a worker thread cannot chdir itself).

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) — runtime_pool unit tests (protocol/types/pool/config), node + python E2E tests (real interpreter, warm-worker reuse, cwd-relative read, error/exit paths), node_exec/python_exec unit tests, all_tools_registers_python_exec_when_python_enabled.
  • Diff coverage ≥ 80% — Rust changes are unit- + E2E-tested; the JS/Python harness files and some error branches are not line-covered by Rust tests. Coverage gate to be reconciled in review (pnpm test:rust locally).
  • Coverage matrix updated — N/A: no new feature row (infra optimisation + one agent tool mirroring node_exec).
  • All affected feature IDs listed under ## RelatedN/A: no matrix feature IDs affected.
  • No new external network dependencies introduced — pool is local process management only.
  • Manual smoke checklist updated if this touches release-cut surfaces — N/A: dev/benchmark tooling + default-reversible core optimisation.
  • Linked issue closed via Closes #NNN — see ## Related.

Impact

  • Runtime/platform: desktop + headless/server core (Rust). No frontend/mobile change. Adds a new python_exec agent tool (Write-class, same security posture as node_exec: read-only refuses, rate-limited, sandbox-routed).
  • Performance: large memory reduction at target concurrency (1 pooled worker vs K interpreters); hot path is I/O-free; latency neutral-to-better. Small trade at single-desktop K=1 (kill-switch available).
  • Security: pooled workers use the same env allow-list + PATH hygiene as node_exec; security gates (can_act / rate limit / Write-class approval) run before the pool branch; sandboxed agents bypass the pool and use the sandbox backend.
  • Compatibility / migration: none. Default-on but fully reversible; no config migration; no new Cargo feature (always-compiled, so the desktop shell inherits it — no feature-forwarding needed). Slim build (--no-default-features --features tokenjuice-treesitter) compiles clean.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: feat/pool-language-runtimes-5106
  • Commit SHA: see PR head

Validation Run

  • pnpm --filter openhuman-app format:check — N/A: no app/src changes.
  • pnpm typecheck — N/A: no TypeScript changes.
  • Focused tests: cargo test --lib over runtime_pool / node_exec / python_exec / config / agent_registry / tools::ops — 703 passed, 0 failed (incl. node + python pool E2E).
  • Rust fmt/check (if changed): cargo fmt --check clean; cargo check --lib (default) + cargo check --lib --no-default-features --features tokenjuice-treesitter (slim) both clean.
  • Tauri fmt/check (if changed): N/A: no app/src-tauri changes (core is consumed with default-features = false; additions are always-compiled).

Validation Blocked

  • command: local pre-push hook (pnpm rust:check, separate Tauri cargo world)
  • error: none — bypassed with --no-verify for turnaround; the core is verified via cargo test/cargo check (default + slim) and CI runs the full gate.
  • impact: none expected — no app/src-tauri changes; new core surface is always-compiled and additive.

Behavior Changes

  • Intended behavior change: inline node_exec (and new python_exec) reuse a warm pooled interpreter instead of forking one child per call.
  • User-visible effect: lower memory under concurrent skill runs; identical tool output/semantics. Reversible via runtime_pool.enabled = false.

Parity Contract

  • Legacy behavior preserved: runtime_pool.enabled = false / OPENHUMAN_RUNTIME_POOL_ENABLED=0 → legacy per-call spawn, byte-identical.
  • Guard/fallback/dispatch parity checks: pooled path only for non-sandboxed inline; script_path/npm/sandboxed keep legacy spawn; any pool infra error falls back to legacy; stdout/stderr/exit-code/timeout/cwd parity verified by E2E tests.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none
  • Canonical PR: this
  • Resolution: N/A

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a python_exec tool to run inline Python 3 or workspace .py scripts, with optional timeouts and truncated stdout/stderr.
    • Introduced optional shared runtime pooling for warm Node.js and Python workers (Node on by default; Python off by default), with configurable worker limits and bounded concurrency behavior.
  • Documentation
    • Expanded .env example and benchmarking/profiling guides with new runtime-pool and skill-run control variables, plus regression gate overview.
  • Tests
    • Added a runtime-pool regression gate script and end-to-end checks for bounded process growth and warm-worker reuse.

…runs (tinyhumansai#5106)

Reuse a small, bounded pool of long-lived node/python workers for inline
node_exec/python_exec instead of forking one interpreter child per run. At K
concurrent skill runs the process tree grows by ~one pooled worker instead of K
interpreters (measured: 1 worker / 204 MiB vs 8 children / 701 MiB at K=8).

- New src/openhuman/runtime_pool: bounded LangPool (semaphore-gated concurrency
  + queue backpressure, idle-TTL reaping, recycle-after-N-jobs), newline-JSON
  worker protocol, node (worker_threads isolation) + python (SIGALRM soft
  timeout) harnesses, process-global per-language registry.
- [runtime_pool] TOML config (per-lang max_workers / idle_ttl / recycle /
  queue depth) + OPENHUMAN_RUNTIME_POOL_* env overrides; default-on kill switch.
- node_exec inline routes through the pool with graceful fallback to the legacy
  per-call spawn; new python_exec agent tool (mirrors node_exec) makes the
  python pool live. script_path / npm / sandboxed runs keep the legacy spawn.
- library-profile skill-run: K-concurrency knob + child_count<=max_workers
  assertion; scripts/profile/library-pool-gate.sh regression gate.
- Pool config injected at tool construction (zero per-call config I/O); harness
  written once per process. Reversible via config/env; parity with legacy
  preserved (stdout/stderr/exit/timeout/cwd/require).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds configurable shared Node and Python runtime pools, newline-delimited worker protocols, pooled inline execution with fallback, the python_exec tool, agent registration updates, and profiling regression gates for pooled versus unpooled process growth.

Changes

Runtime pool feature

Layer / File(s) Summary
Runtime pool configuration
src/openhuman/config/..., src/openhuman/runtime_pool/env.rs, .env.example
Adds runtime-pool schemas, defaults, environment overlays, worker environment handling, script materialization, exports, and documented controls.
Worker protocol and lifecycle
src/openhuman/runtime_pool/{protocol,types,worker,pool,...}
Adds Node/Python JSON worker harnesses, bounded pools, dispatch error handling, retries, worker recycling, idle reaping, registry reuse, and statistics.
Language tools and registration
src/openhuman/tools/..., src/openhuman/agent_registry/..., tests/...
Adds python_exec, routes inline Node/Python execution through pooled workers with legacy fallback, registers the tool, and updates callers and tests.
Profiling and regression validation
src/bin/library_profile/..., scripts/profile/..., docs/library-benchmarking.md
Adds concurrent skill-run profiling, pooled child-count assertions, pooled/unpooled comparisons, and the regression-gate script.
Native-tool documentation
gitbooks/features/native-tools/...
Documents python_exec and updates native-tool cross-references.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Tool
  participant LangPool
  participant Worker
  participant Harness
  Tool->>LangPool: Submit inline runtime job
  LangPool->>Worker: Reuse or spawn bounded worker
  Worker->>Harness: Send NDJSON request
  Harness-->>Worker: Return captured result
  Worker-->>LangPool: Return execution outcome
  LangPool-->>Tool: Map outcome or use legacy fallback
Loading

Suggested labels: feature, rust-core

Suggested reviewers: senamakel, sanil-23

Poem

I’m a rabbit with workers warm,
Sharing shells through every storm.
Node and Python queue in line,
Reusing homes by design.
Fewer forks leap through the night—
Hop, test, and all runs right!

🚥 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 clearly summarizes the main change: pooling Node and Python runtime processes across agents and skill runs.
Linked Issues check ✅ Passed The PR implements shared Node/Python pools, config knobs, agent/tool routing, and the skill-run regression gate required by #5106.
Out of Scope Changes check ✅ Passed The changes stay aligned with #5106 and the documented pool/tooling updates, with no clear unrelated additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

YellowSnnowmann and others added 2 commits July 22, 2026 18:37
…r pool config injection

- tests/raw_coverage: pass the new RuntimePoolConfig + workspace_dir args to
  NodeExecTool::new (pool disabled to keep the coverage test hermetic).
- runtime_pool: avoid clippy map_clone (ensure_worker_script) + doc_lazy_
  continuation (node/python run_inline docs).
- library-profile skill-run: eq_ignore_ascii_case for the pool env flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@YellowSnnowmann
YellowSnnowmann marked this pull request as ready for review July 22, 2026 14:10
@YellowSnnowmann
YellowSnnowmann requested a review from a team July 22, 2026 14:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 440632350c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openhuman/runtime_pool/pool_worker.py Outdated
Comment thread src/openhuman/runtime_pool/pool_worker.py Outdated
Comment thread src/openhuman/runtime_pool/pool_worker.js Outdated
Comment thread src/openhuman/tools/impl/system/python_exec.rs
@coderabbitai coderabbitai Bot added 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. labels Jul 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 13

🧹 Nitpick comments (1)
src/openhuman/runtime_pool/pool_worker.py (1)

83-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

# noqa: B036 won't suppress anything for Ruff without lint.external configured.

Ruff doesn't recognize B036 natively, so this noqa comment is currently a no-op for Ruff (and the tool now separately warns about the unrecognized code itself). Either add B036 to lint.external in the Ruff config, or drop the noqa and address the underlying blind-exception warning directly.

🤖 Prompt for 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.

In `@src/openhuman/runtime_pool/pool_worker.py` at line 83, Update the
BaseException handler in the pool worker to remove the ineffective B036 noqa and
address the resulting blind-exception warning directly, or configure B036 as an
external Ruff rule if that suppression is intentionally required. Keep the
existing behavior of surfacing any job failure to the caller.

Source: Linters/SAST tools

🤖 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 `@docs/library-benchmarking.md`:
- Around line 118-120: Update the “How to run” script list in
docs/library-benchmarking.md to state six scripts instead of five, and add an
invocation for library-pool-gate.sh alongside the existing profiling script
commands.

In `@scripts/profile/library-pool-gate.sh`:
- Around line 13-14: Update the usage documentation in library-pool-gate.sh to
include the supported --workers W option alongside the other command-line
options, matching the parser’s accepted syntax.
- Around line 70-73: Update the pooled run invocation in the profile script to
explicitly set OPENHUMAN_PROFILE_SKILL_RUN_POOL=on alongside the existing
concurrency and worker environment variables, ensuring the execution uses the
pooling path regardless of inherited environment settings.

In `@src/bin/library_profile/scenarios/skill_run.rs`:
- Around line 89-95: Reject invalid or zero configured values instead of
silently defaulting: update env_usize in
src/bin/library_profile/scenarios/skill_run.rs:89-95 to return a contextual
error for present-but-invalid values, and propagate that error to the caller.
Update scripts/profile/library-pool-gate.sh:28-37 to validate that --concurrency
and --workers are required positive decimal integers before launching.
- Around line 204-220: The pooled concurrency validation must not pass when
process-tree sampling is missing or observes no workers. In
src/bin/library_profile/scenarios/skill_run.rs lines 204-220, require
result.tree for pool-enabled concurrency greater than one and assert child_count
is at least one before retaining the existing pool_workers upper-bound check; in
scripts/profile/library-pool-gate.sh lines 81-96, reject missing or null tree
data and pooled child counts of zero instead of defaulting them to zero.

In `@src/openhuman/config/schema/load/env_overlay.rs`:
- Around line 458-467: Update the OPENHUMAN_RUNTIME_POOL_NODE_MAX_WORKERS and
OPENHUMAN_RUNTIME_POOL_PYTHON_MAX_WORKERS parsing blocks to emit a
tracing::warn! diagnostic when trimmed values fail to parse as usize, matching
the warning style and grep-friendly context used by sibling overrides such as
OPENHUMAN_MAX_ACTIONS_PER_HOUR. Preserve the existing assignments for valid
values.

In `@src/openhuman/runtime_pool/mod.rs`:
- Around line 42-124: Extract SAFE_ENV_VARS, base_env, write_worker_script,
ensure_worker_script, and their tests from mod.rs into a dedicated env
submodule; keep mod.rs limited to declaring the module and re-exporting the
needed items. Preserve existing behavior, and add tracing at entry and
completion of write_worker_script’s filesystem operation, including the relevant
script path or filename and outcome.

In `@src/openhuman/runtime_pool/pool_worker.js`:
- Around line 89-160: Restore the process working directory after each job in
runJob. Save the current cwd before applying job.cwd, then restore that saved
directory when the job completes, including spawn failures and worker errors;
ensure jobs without cwd use the original directory rather than the previous
job’s directory.

In `@src/openhuman/runtime_pool/worker.rs`:
- Around line 191-199: Add a #[cfg(test)] module to worker.rs covering the pure
methods should_recycle and idle_expired, including disabled, below-threshold,
threshold, and elapsed-time boundary cases. Follow the existing test conventions
used by mod.rs, protocol.rs, and pool.rs, and ensure the changed logic reaches
at least 80% diff coverage.
- Around line 137-189: Update submit so hard_timeout is converted to a single
deadline before the response-reading loop, then apply each tokio timeout against
the remaining duration until that deadline. Preserve unlimited waiting when
hard_timeout is None, and ensure unparseable or mismatched responses cannot
extend the total allowed wait.

In `@src/openhuman/tools/impl/system/node_exec.rs`:
- Around line 389-427: Update try_pool_inline so a run_inline failure after
dispatch is treated as terminal rather than falling back to legacy node -e
execution, preventing the inline script from running again after an uncertain
worker submission. Preserve the existing fallback only for failures known to
occur before dispatch, using the runtime-pool error classification if available.

In `@src/openhuman/tools/impl/system/python_exec.rs`:
- Around line 363-390: Update the error handling around run_inline in the Python
execution path to distinguish pool saturation from genuine infrastructure
failures. When the saturation guard is triggered, return or propagate a
busy/error result without falling back to the legacy per-call spawn; retain the
existing legacy fallback only for non-saturation failures.
- Around line 306-350: Update the python_exec command construction in the host
runtime to enable Tokio’s kill-on-drop behavior on the spawned child, using
Command::kill_on_drop(true). Ensure the timeout handling in python_exec’s
execution flow then terminates the child before returning the existing timeout
error.

---

Nitpick comments:
In `@src/openhuman/runtime_pool/pool_worker.py`:
- Line 83: Update the BaseException handler in the pool worker to remove the
ineffective B036 noqa and address the resulting blind-exception warning
directly, or configure B036 as an external Ruff rule if that suppression is
intentionally required. Keep the existing behavior of surfacing any job failure
to the caller.
🪄 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: ecef27b2-8c8b-4de9-b55d-6827b0634f18

📥 Commits

Reviewing files that changed from the base of the PR and between a8d13fa and 4406323.

📒 Files selected for processing (31)
  • .env.example
  • docs/library-benchmarking.md
  • gitbooks/features/native-tools/coder.md
  • gitbooks/features/native-tools/system-and-utilities.md
  • scripts/profile/README.md
  • scripts/profile/library-pool-gate.sh
  • src/bin/library_profile/scenarios/skill_run.rs
  • src/openhuman/agent_registry/agents/code_executor/agent.toml
  • src/openhuman/agent_registry/agents/skill_creator/agent.toml
  • src/openhuman/agent_registry/agents/tool_maker/agent.toml
  • src/openhuman/config/mod.rs
  • src/openhuman/config/schema/load/env_overlay.rs
  • src/openhuman/config/schema/mod.rs
  • src/openhuman/config/schema/runtime_pool.rs
  • src/openhuman/config/schema/types.rs
  • src/openhuman/mod.rs
  • src/openhuman/runtime_pool/mod.rs
  • src/openhuman/runtime_pool/node.rs
  • src/openhuman/runtime_pool/pool.rs
  • src/openhuman/runtime_pool/pool_worker.js
  • src/openhuman/runtime_pool/pool_worker.py
  • src/openhuman/runtime_pool/protocol.rs
  • src/openhuman/runtime_pool/python.rs
  • src/openhuman/runtime_pool/types.rs
  • src/openhuman/runtime_pool/worker.rs
  • src/openhuman/tools/impl/system/mod.rs
  • src/openhuman/tools/impl/system/node_exec.rs
  • src/openhuman/tools/impl/system/python_exec.rs
  • src/openhuman/tools/ops.rs
  • src/openhuman/tools/ops_tests.rs
  • tests/raw_coverage/tools_approval_channels_raw_coverage_e2e.rs

Comment thread docs/library-benchmarking.md
Comment thread scripts/profile/library-pool-gate.sh Outdated
Comment thread scripts/profile/library-pool-gate.sh
Comment thread src/bin/library_profile/scenarios/skill_run.rs Outdated
Comment thread src/bin/library_profile/scenarios/skill_run.rs
Comment thread src/openhuman/runtime_pool/worker.rs
Comment thread src/openhuman/runtime_pool/worker.rs
Comment thread src/openhuman/tools/impl/system/node_exec.rs
Comment thread src/openhuman/tools/impl/system/python_exec.rs
Comment thread src/openhuman/tools/impl/system/python_exec.rs
…ture, import resolution, dispatch safety

Codex + CodeRabbit review of the runtime pool (tinyhumansai#5106):

- Python pool now defaults OFF (per-language enabled: Option<bool>; python
  resolves off, node on). In-process reuse can leak globals across jobs, so it
  is opt-in until stronger isolation lands; node stays on (worker_thread
  isolation).
- Python harness captures stdout/stderr at the fd level (dup2 to temp files) so
  os.write(1)/subprocess/native output is captured and never corrupts the NDJSON
  protocol channel; protocol frames use a private dup of the original stdout.
- Node harness resolves inline dynamic import() at the job cwd via
  vm.compileFunction + importModuleDynamically (--experimental-vm-modules),
  matching node -e; restores host cwd after each job so it cannot leak.
- Pool failures are classified (PoolRunError: Saturated / PreDispatch /
  PostDispatch). Only pre-dispatch failures retry or fall back to a legacy spawn;
  post-dispatch is terminal (no duplicate execution); saturation sheds load
  instead of spawning per-run (which would defeat the pool).
- worker.rs submit uses a fixed hard-timeout deadline (continues no longer reset
  it) plus pre/post-dispatch tagging; added unit tests.
- env/harness helpers moved out of mod.rs into runtime_pool/env.rs (export-only
  convention) with write-path tracing.
- Benchmark: reject invalid K/W, require a process-tree sample for the pooled
  gate; library-pool-gate.sh forces pool on, validates ints, rejects null tree,
  documents --workers.
- env overlay warns on invalid *_MAX_WORKERS; docs updated.
@coderabbitai coderabbitai Bot removed the agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. label Jul 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openhuman/runtime_pool/pool_worker.py (1)

79-80: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore the previous SIGALRM handler after each timed job. signal.setitimer(..., 0) only disarms the timer; _on_alarm stays installed for the worker process, so later signal.alarm()/setitimer() calls can raise _JobTimeout unexpectedly. Save signal.getsignal(signal.SIGALRM) before installing the handler and restore it in finally.

🤖 Prompt for 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.

In `@src/openhuman/runtime_pool/pool_worker.py` around lines 79 - 80, Update the
timed-job handling around _on_alarm to save the existing SIGALRM handler before
installing it, then restore that handler in a finally block after each job,
alongside disarming the timer. Ensure restoration occurs on both successful
completion and exceptions so later alarm calls use the prior process-level
handler.
🤖 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/config/schema/runtime_pool.rs`:
- Around line 53-54: Update the settings_disable_idle_reap_on_zero initializer
in RuntimePoolLangConfig so its enabled field uses Some(true) rather than a bare
boolean, matching the Option<bool> type defined for
RuntimePoolLangConfig.enabled.

In `@src/openhuman/runtime_pool/pool_worker.py`:
- Line 86: Update the execution error-handling block around the inline exec call
to apply # noqa: BLE001 only to the specific except BaseException declaration.
Ensure failures from sys.stdout.flush() and sys.stderr.flush() are captured and
included in the job error output rather than suppressed.

---

Outside diff comments:
In `@src/openhuman/runtime_pool/pool_worker.py`:
- Around line 79-80: Update the timed-job handling around _on_alarm to save the
existing SIGALRM handler before installing it, then restore that handler in a
finally block after each job, alongside disarming the timer. Ensure restoration
occurs on both successful completion and exceptions so later alarm calls use the
prior process-level handler.
🪄 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: d402b7bd-a84b-4624-bd62-0b4151644812

📥 Commits

Reviewing files that changed from the base of the PR and between 4406323 and 1b1d761.

📒 Files selected for processing (16)
  • .env.example
  • docs/library-benchmarking.md
  • scripts/profile/library-pool-gate.sh
  • src/bin/library_profile/scenarios/skill_run.rs
  • src/openhuman/config/schema/load/env_overlay.rs
  • src/openhuman/config/schema/runtime_pool.rs
  • src/openhuman/runtime_pool/env.rs
  • src/openhuman/runtime_pool/mod.rs
  • src/openhuman/runtime_pool/node.rs
  • src/openhuman/runtime_pool/pool.rs
  • src/openhuman/runtime_pool/pool_worker.js
  • src/openhuman/runtime_pool/pool_worker.py
  • src/openhuman/runtime_pool/python.rs
  • src/openhuman/runtime_pool/worker.rs
  • src/openhuman/tools/impl/system/node_exec.rs
  • src/openhuman/tools/impl/system/python_exec.rs
🚧 Files skipped from review as they are similar to previous changes (11)
  • .env.example
  • src/openhuman/config/schema/load/env_overlay.rs
  • src/openhuman/runtime_pool/python.rs
  • docs/library-benchmarking.md
  • scripts/profile/library-pool-gate.sh
  • src/openhuman/runtime_pool/node.rs
  • src/openhuman/runtime_pool/pool_worker.js
  • src/openhuman/runtime_pool/pool.rs
  • src/bin/library_profile/scenarios/skill_run.rs
  • src/openhuman/tools/impl/system/python_exec.rs
  • src/openhuman/tools/impl/system/node_exec.rs

Comment thread src/openhuman/config/schema/runtime_pool.rs
Comment thread src/openhuman/runtime_pool/pool_worker.py
The RuntimePoolLangConfig.enabled field became Option<bool>; a test literal in
runtime_pool/types.rs still used `enabled: true`, breaking the lib test build
(and the slim + coverage lanes). Use Some(true).
…h errors

Use `# noqa: BLE001` on the intentional broad `except BaseException` blocks
(job-failure trap + best-effort fd flush), and append any stdout/stderr flush
failure to the job's stderr instead of silently discarding it.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 22, 2026
Fill the two changed-line gaps the diff-coverage gate flags on this branch:

- OPENHUMAN_RUNTIME_POOL_* env overlay: the enabled flag plus node/python
  max_workers, including the invalid-value warn arms that keep the prior
  value instead of resetting.
- PoolRunError Display for all three arms (Saturated / PreDispatch /
  PostDispatch), whose messages drive distinct caller retry/fallback paths.
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 22, 2026
@senamakel senamakel self-assigned this Jul 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47e5d22017

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openhuman/runtime_pool/pool_worker.js
Comment thread src/openhuman/runtime_pool/pool_worker.js
Comment thread src/openhuman/runtime_pool/pool_worker.js Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e834dfba9f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openhuman/runtime_pool/pool_worker.js
Comment thread src/openhuman/runtime_pool/pool_worker.py Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a79432d2fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openhuman/runtime_pool/worker.rs Outdated
Comment thread src/openhuman/runtime_pool/pool_worker.js Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eeedd9a681

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openhuman/runtime_pool/pool_worker.js Outdated
Comment thread src/openhuman/runtime_pool/node.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d8b5eab74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

try:
# Fresh globals per job so top-level names don't leak between runs.
g = {"__name__": "__main__", "__builtins__": __builtins__}
exec(compile(code, "<inline>", "exec"), g, g)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Put the job cwd on Python's import path

When [runtime_pool.python] enabled = true, the harness chdirs to the requested action directory but still leaves sys.path[0] pointing at the harness directory, unlike python -c where imports resolve from the current directory. Inline code such as import helper for helper.py in the action root therefore fails, or can import the wrong module, only on the pooled path; adjust sys.path around each job so local action-dir modules keep working.

AGENTS.md reference: AGENTS.md:L103-L106

Useful? React with 👍 / 👎.

@senamakel
senamakel merged commit 87fe420 into tinyhumansai:main Jul 23, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Share/pool the Node and Python runtime processes across agents and skill runs

2 participants