Skip to content

feat(runtime): add javascript facade and skill creator agent#1971

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:feat/javascript-runtime-skill-creator
May 17, 2026
Merged

feat(runtime): add javascript facade and skill creator agent#1971
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:feat/javascript-runtime-skill-creator

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented May 16, 2026

Summary

  • add a first-class javascript runtime surface in the Rust core for tool listing and dispatch
  • move the current Node-backed implementation behind a backend-specific runtime_node module
  • add a built-in skill_creator agent and expose it to the orchestrator as create_skill
  • scrub stale QuickJS-era runtime naming in touched docs and comments to match the new layering

Problem

  • the codebase still exposed JavaScript runtime behavior under Node-specific or legacy skill-runtime naming, which makes future multi-language runtime expansion awkward
  • the orchestrator did not have a dedicated specialist for creating skills and JavaScript runtime code paths for the repo

Solution

  • introduce openhuman::javascript as the first-class public language module while keeping the existing Node bootstrap as the current backend implementation
  • rename the backend module to runtime_node and update tool/runtime imports and controller wiring accordingly
  • add a sandboxed skill_creator built-in agent with Node-capable tools and wire it into the orchestrator subagent inventory
  • keep the RPC/tool bridge behavior intact while renaming the public namespace to javascript

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/coverage.yml. Run pnpm test:coverage and pnpm test:rust locally; PRs below 80% on changed lines will not merge. N/A: not run locally here; rely on CI for gate validation.
  • Coverage matrix updated — added/removed/renamed feature rows in docs/TEST-COVERAGE-MATRIX.md reflect this change (or N/A: behaviour-only change) N/A: behaviour/module refactor only, no matrix row changes.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related N/A: no matrix feature IDs were updated.
  • 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 manual smoke rows changed.
  • Linked issue closed via Closes #NNN in the ## Related section N/A: no linked GitHub issue was provided.

Impact

  • runtime/platform impact: Rust core, agent definitions, and Tauri-adjacent docs only; desktop product surface remains the same
  • compatibility: public runtime naming shifts to javascript, with the current Node implementation preserved behind runtime_node
  • extensibility: future language runtimes can now sit beside javascript without forcing Node-specific naming into the top-level API

Related

  • Closes: N/A
  • Follow-up PR(s)/TODOs:
    • optionally move remaining internal log prefixes from node_runtime::* to runtime_node::* / javascript::* if desired

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

Linear Issue

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

Commit & Branch

  • Branch: feat/javascript-runtime-skill-creator
  • Commit SHA: 326970ee

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck
  • Focused tests:
    • GGML_NATIVE=OFF cargo test --lib openhuman::runtime_node --manifest-path Cargo.toml
    • GGML_NATIVE=OFF cargo test --lib openhuman::agent::agents::loader --manifest-path Cargo.toml
  • Rust fmt/check (if changed):
    • cargo fmt --all
    • GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml
  • Tauri fmt/check (if changed):
    • pre-push hook ran pnpm --filter openhuman-app rust:check

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: expose the first-class runtime surface as javascript, move the current Node implementation behind runtime_node, and add a skill_creator agent for orchestrator delegation
  • User-visible effect: no direct UI flow change; runtime/module naming and orchestrator delegation surface gain the new create_skill specialist

Parity Contract

  • Legacy behavior preserved: the existing Node bootstrap and tool dispatch behavior remain the implementation backend; only the public layering and module naming changed
  • Guard/fallback/dispatch parity checks: focused runtime and agent-loader tests passed after the rename and agent wiring changes

Duplicate / Superseded PR Handling

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

Summary by CodeRabbit

  • New Features

    • Added a built-in "Skill Creator" agent to help create/manage skills targeting a Node.js runtime.
    • Added JavaScript runtime interfaces to list available tools and execute named tools.
  • Documentation

    • Updated architecture docs to describe a managed Node.js runtime and SKILL.md-based skill metadata.
  • Refactor

    • Transitioned from per-skill QuickJS sandboxes to a managed Node.js runtime and reorganized runtime surfaces.

Review Change Stack

@senamakel senamakel requested a review from a team May 16, 2026 22:40
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

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: 449a5b43-6ecf-47f4-be43-b8e0cbab89b7

📥 Commits

Reviewing files that changed from the base of the PR and between a363b2b and 8ce5da5.

📒 Files selected for processing (4)
  • src/core/all.rs
  • src/openhuman/agent/agents/loader.rs
  • src/openhuman/mod.rs
  • src/openhuman/tools/ops.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/openhuman/tools/ops.rs
  • src/openhuman/mod.rs
  • src/openhuman/agent/agents/loader.rs
  • src/core/all.rs

📝 Walkthrough

Walkthrough

This PR renames core bootstrap routines, exposes a JavaScript language surface backed by a runtime_node implementation (types/ops/rpc/schemas), re-exports Node runtime utilities under openhuman::javascript, updates tool imports, registers JavaScript controllers, and adds a new skill_creator built-in agent with prompt builder and tests.

Changes

JavaScript Runtime and Agent System

Layer / File(s) Summary
Core runtime bootstrap rename
src/core/jsonrpc.rs, src/core/jsonrpc_tests.rs, src/openhuman/channels/*, src/openhuman/composio/*, src/openhuman/scheduler_gate/gate.rs
Exported function bootstrap_skill_runtime is renamed to bootstrap_core_runtime and all call sites, test assertions, and docstring references are updated to use the new name.
Module structure reorganization
src/openhuman/mod.rs, src/openhuman/javascript/mod.rs, src/openhuman/runtime_node/mod.rs
Public module surface changes from node_runtime to new javascript and runtime_node modules, with javascript re-exporting Node runtime types and schemas under JavaScript-namespaced aliases.
Runtime tool controllers implementation
src/openhuman/runtime_node/types.rs, src/openhuman/runtime_node/ops.rs, src/openhuman/runtime_node/schemas.rs, src/openhuman/runtime_node/rpc.rs
New modules define RuntimeToolSummary and ExecuteToolOutcome types, implement list_tools() and execute_tool() with domain event publishing and elapsed-time tracking, and wire two RPC controllers for javascript.list_tools and javascript.execute_tool with schema definitions and request handlers.
Tool system import path updates
src/openhuman/tools/impl/system/node_exec.rs, src/openhuman/tools/impl/system/npm_exec.rs, src/openhuman/tools/impl/system/shell.rs, src/openhuman/tools/ops.rs
Update NodeBootstrap import paths to use crate::openhuman::javascript instead of crate::openhuman::node_runtime across shell, node_exec, and npm_exec tools.
Core controller registration
src/core/all.rs
Extend global controller registry to register JavaScript runtime controllers in both registered-controller and declared-schema lists, and update namespace descriptions for javascript and socket.
Skill creator agent implementation
src/openhuman/agent/agents/mod.rs, src/openhuman/agent/agents/loader.rs, src/openhuman/agent/agents/skill_creator/agent.toml, src/openhuman/agent/agents/skill_creator/mod.rs, src/openhuman/agent/agents/skill_creator/prompt.md, src/openhuman/agent/agents/skill_creator/prompt.rs, src/openhuman/agent/agents/orchestrator/agent.toml, src/openhuman/agent/harness/builtin_definitions.rs
Add new built-in skill_creator agent with TOML configuration (sandboxed, named tool allowlist including node/npm/patch/memory tools, coding model hint), dynamic prompt builder that concatenates archetype with context sections, module wiring, and integration into orchestrator subagents list.
Documentation and test updates
app/test/e2e/helpers/skill-e2e-runtime.ts, gitbooks/developing/architecture.md, src/core/event_bus/events_tests.rs, src/openhuman/config/schema/node.rs, src/openhuman/memory/global.rs, src/openhuman/skills/README.md, src/openhuman/skills/mod.rs, src/openhuman/skills/types.rs, src/openhuman/tool_timeout/mod.rs, src/openhuman/screen_intelligence/cli/mod.rs, src/openhuman/webhooks/*
Update architecture docs to reflect Node.js runtime (replacing QuickJS references), change skill manifest runtime field from quickjs to nodejs, update module docstrings to clarify component responsibilities, revise test assertions to expect Node.js runtime, and refine error messages for unrecognized webhook targets.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • tinyhumansai/openhuman#723: Main refactoring PR that moves Node runtime surfaces into openhuman/javascript and runtime_node modules with updated tool wiring, directly overlapping this PR's module reorganization and tool integration.
  • tinyhumansai/openhuman#1859: Related to core controller registration and e2e test-support controllers used by startup/test wiring.

🐰 "From QuickJS to Node we leap,
bootstrap renamed, the changes deep.
Controllers and tools now greet,
Skill Creator learns to speak and meet.
JavaScript slots, a runtime neat."

🚥 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 'feat(runtime): add javascript facade and skill creator agent' clearly summarizes the main changes: introducing a JavaScript runtime facade and a new skill_creator agent, which are the primary focuses of the extensive changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 the working A PR that is being worked on by the team. label May 16, 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: 4

🤖 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 `@gitbooks/developing/architecture.md`:
- Line 166: The doc currently mixes "Node.js Runtime" terminology with leftover
"QuickJS" descriptions; update the architecture narrative to be consistent by
replacing all QuickJS-specific wording (e.g., "QuickJS", "QuickJS-per-skill
execution", and any sections describing per-skill QuickJS VMs, execution flow or
security assumptions tied to QuickJS) with Node.js-oriented equivalents or a
clear note that QuickJS is deprecated/removed; ensure the "Node.js Runtime"
header and paragraphs about resolving/ installing node, runtime bridge, and tool
execution reflect a single model, and audit the other QuickJS occurrences (the
other sections flagged) to unify wording and adjust any flow/security statements
to the Node.js model.

In `@src/openhuman/agent/agents/skill_creator/prompt.rs`:
- Around line 10-38: Add tracing to the prompt assembly in function build: emit
a trace/debug at entry (include ctx id or summary if available), log each render
call invocation (render_user_files, render_tools, render_safety,
render_workspace) and capture their Result outcome and the produced string
length (or error) and the boolean decision whether the section was appended
(e.g., user_files_included, tools_included, workspace_included), log branch
decisions when skipping empty sections, and log on any early errors returned
from render_* with the error info; finally emit a trace/debug at exit with the
final out.len() and success status. Use the crate's tracing/log macros (trace!
or debug!) and keep logs limited to lengths/flags only, not the prompt content.

In `@src/openhuman/runtime_node/ops.rs`:
- Around line 32-113: Add structured debug/trace instrumentation to the runtime
tool flow: in build_runtime_tools log at trace entry with the incoming Config
summary, trace before/after the call to
crate::openhuman::memory::create_memory_with_local_ai (include success or mapped
error), and trace the call/return of tools::all_tools_with_runtime; in
list_tools trace entry, number of tools returned and trace exit after sorting;
in execute_tool trace entry with tool_name and prefer_markdown, trace the result
of build_runtime_tools, trace the branch that finds or fails to find the tool
(include tool_name), emit debug when publishing
DomainEvent::ToolExecutionStarted, trace before/after tool.execute_with_options
(include errors), compute and debug-log elapsed_ms and success, and trace before
returning ExecuteToolOutcome; use the crate's tracing/log macros (debug/trace)
and include identifiers like build_runtime_tools, list_tools, execute_tool,
create_memory_with_local_ai, tools::all_tools_with_runtime, summarize_tool, and
publish_global to make logs easy to correlate.

In `@src/openhuman/runtime_node/schemas.rs`:
- Around line 116-159: The two functions handle_list_tools and
handle_execute_tool contain operational runtime logic and should be converted
into thin delegators that forward work to implementations in rpc.rs; extract the
orchestration (config loading, calling javascript::list_tools /
javascript::execute_tool, building payload/log and RpcOutcome) into new async
functions in the runtime rpc module (e.g. list_tools_handler and
execute_tool_handler) and update handle_list_tools and handle_execute_tool to
only deserialize params to the appropriate types (ListToolsParams /
ExecuteToolParams) and call the corresponding rpc.rs handler, returning its
result unchanged so schemas.rs remains declarative and only responsible for
registration/delegation.
🪄 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: 15809d28-9397-46de-b3d5-9173bd4edbd1

📥 Commits

Reviewing files that changed from the base of the PR and between 40a384e and 326970e.

📒 Files selected for processing (44)
  • app/test/e2e/helpers/skill-e2e-runtime.ts
  • gitbooks/developing/architecture.md
  • src/core/all.rs
  • src/core/event_bus/events_tests.rs
  • src/core/jsonrpc.rs
  • src/core/jsonrpc_tests.rs
  • src/openhuman/agent/agents/loader.rs
  • src/openhuman/agent/agents/mod.rs
  • src/openhuman/agent/agents/orchestrator/agent.toml
  • src/openhuman/agent/agents/skill_creator/agent.toml
  • src/openhuman/agent/agents/skill_creator/mod.rs
  • src/openhuman/agent/agents/skill_creator/prompt.md
  • src/openhuman/agent/agents/skill_creator/prompt.rs
  • src/openhuman/agent/harness/builtin_definitions.rs
  • src/openhuman/channels/proactive.rs
  • src/openhuman/channels/runtime/startup.rs
  • src/openhuman/composio/periodic.rs
  • src/openhuman/composio/providers/registry.rs
  • src/openhuman/config/schema/node.rs
  • src/openhuman/javascript/mod.rs
  • src/openhuman/memory/global.rs
  • src/openhuman/mod.rs
  • src/openhuman/runtime_node/bootstrap.rs
  • src/openhuman/runtime_node/downloader.rs
  • src/openhuman/runtime_node/extractor.rs
  • src/openhuman/runtime_node/mod.rs
  • src/openhuman/runtime_node/ops.rs
  • src/openhuman/runtime_node/resolver.rs
  • src/openhuman/runtime_node/schemas.rs
  • src/openhuman/runtime_node/types.rs
  • src/openhuman/scheduler_gate/gate.rs
  • src/openhuman/screen_intelligence/cli/mod.rs
  • src/openhuman/skills/README.md
  • src/openhuman/skills/mod.rs
  • src/openhuman/skills/types.rs
  • src/openhuman/tool_timeout/mod.rs
  • src/openhuman/tools/impl/system/node_exec.rs
  • src/openhuman/tools/impl/system/npm_exec.rs
  • src/openhuman/tools/impl/system/shell.rs
  • src/openhuman/tools/ops.rs
  • src/openhuman/webhooks/bus.rs
  • src/openhuman/webhooks/ops.rs
  • src/openhuman/webhooks/router.rs
  • src/openhuman/webhooks/schemas.rs

Comment thread gitbooks/developing/architecture.md
Comment thread src/openhuman/agent/agents/skill_creator/prompt.rs
Comment thread src/openhuman/runtime_node/ops.rs
Comment thread src/openhuman/runtime_node/schemas.rs
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: 2

♻️ Duplicate comments (1)
gitbooks/developing/architecture.md (1)

166-177: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Runtime narrative is still mixed with QuickJS-era sections.

This update describes Node.js/runtime_node, but the same document still states QuickJS-based execution in several places (Line 60, Line 81, Line 92, Line 226, Line 263, Line 277, Line 308, Line 311, Line 320), leaving contradictory architecture guidance.

Also applies to: 189-200

🤖 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 `@gitbooks/developing/architecture.md` around lines 166 - 177, The document
mixes Node.js/runtime_node details with leftover QuickJS descriptions causing
contradictions; search for and replace or update all QuickJS-era references
(e.g., mentions around "QuickJS", "QuickJS-based execution", and related lines
referenced in the comment) to reflect the current Node.js runtime model,
ensuring consistency in sections that describe "Node.js Runtime", "Current JS
backend: runtime_node", the tool bridge behavior (SKILL.md and runtime bridge),
and any integrity/installation notes so that every reference describes
Node-backed execution rather than QuickJS-based VMs; keep terminology consistent
(use "Node.js", "runtime_node", "managed Node" where applicable) and remove or
rework any QuickJS-specific instructions or examples.
🤖 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/runtime_node/rpc.rs`:
- Around line 20-23: The RPC handlers (e.g., list_tools_handler) currently
return Result<serde_json::Value, String>; change their signatures to return
RpcOutcome<serde_json::Value> and update all return points to construct
RpcOutcome::Ok(...) or RpcOutcome::Err(...) (propagating errors via the
RpcOutcome type) instead of using Result<T, String>, ensuring any CLI/JSON
conversion remains at the schema/delegation boundary rather than inside these
handlers; apply the same change to the other handlers noted (the ones around
lines referenced in the review) so the module consistently uses RpcOutcome<T> as
the RPC contract.
- Around line 23-25: Add tracing calls around the RPC handler flow: at function
entry and exit, and before/after each key call such as
config_rpc::load_config_with_timeout() and javascript::list_tools(), using
tracing::debug or tracing::trace; log the input context, success/failure of each
call (including error details on Err) and include the final payload and the
returned log vector in the exit trace so runtime diagnostics are available.
Locate the handler in rpc.rs and insert tracing::trace!("enter <handler_name>");
before work begins, trace the result of load_config_with_timeout() and
list_tools() with context, and trace!("exit <handler_name> payload={:?}
logs={:?}", payload, log_vec) on success (and corresponding traces on error
paths). Ensure you import tracing and use appropriate debug/trace levels per
guideline.

---

Duplicate comments:
In `@gitbooks/developing/architecture.md`:
- Around line 166-177: The document mixes Node.js/runtime_node details with
leftover QuickJS descriptions causing contradictions; search for and replace or
update all QuickJS-era references (e.g., mentions around "QuickJS",
"QuickJS-based execution", and related lines referenced in the comment) to
reflect the current Node.js runtime model, ensuring consistency in sections that
describe "Node.js Runtime", "Current JS backend: runtime_node", the tool bridge
behavior (SKILL.md and runtime bridge), and any integrity/installation notes so
that every reference describes Node-backed execution rather than QuickJS-based
VMs; keep terminology consistent (use "Node.js", "runtime_node", "managed Node"
where applicable) and remove or rework any QuickJS-specific instructions or
examples.
🪄 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: aeec22ae-214f-4afd-ade3-33efdfbf0f53

📥 Commits

Reviewing files that changed from the base of the PR and between 326970e and a363b2b.

📒 Files selected for processing (6)
  • gitbooks/developing/architecture.md
  • src/openhuman/agent/agents/skill_creator/prompt.rs
  • src/openhuman/runtime_node/mod.rs
  • src/openhuman/runtime_node/ops.rs
  • src/openhuman/runtime_node/rpc.rs
  • src/openhuman/runtime_node/schemas.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/openhuman/runtime_node/mod.rs
  • src/openhuman/agent/agents/skill_creator/prompt.rs

Comment on lines +20 to +23
pub(crate) async fn list_tools_handler(
_params: ListToolsParams,
) -> Result<serde_json::Value, String> {
let config = config_rpc::load_config_with_timeout().await?;
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.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Use RpcOutcome<T> as the RPC handler return contract.

These handlers convert to CLI JSON inside rpc.rs and return Result<Value, String>. Keep rpc.rs returning RpcOutcome<T> and do CLI conversion at the schema/delegation boundary.

Proposed contract-aligned patch
--- a/src/openhuman/runtime_node/rpc.rs
+++ b/src/openhuman/runtime_node/rpc.rs
@@
 pub(crate) async fn list_tools_handler(
     _params: ListToolsParams,
-) -> Result<serde_json::Value, String> {
+) -> Result<RpcOutcome<serde_json::Value>, String> {
@@
-    RpcOutcome::new(payload, log).into_cli_compatible_json()
+    Ok(RpcOutcome::new(payload, log))
 }
@@
 pub(crate) async fn execute_tool_handler(
     params: ExecuteToolParams,
-) -> Result<serde_json::Value, String> {
+) -> Result<RpcOutcome<serde_json::Value>, String> {
@@
-    RpcOutcome::new(payload, log).into_cli_compatible_json()
+    Ok(RpcOutcome::new(payload, log))
 }
--- a/src/openhuman/runtime_node/schemas.rs
+++ b/src/openhuman/runtime_node/schemas.rs
@@
-        list_tools_handler(params).await
+        list_tools_handler(params).await?.into_cli_compatible_json()
@@
-        execute_tool_handler(params).await
+        execute_tool_handler(params).await?.into_cli_compatible_json()

As per coding guidelines, "src/openhuman/*/rpc.rs: Use RpcOutcome<T> as the return type for RPC controller handlers in src/openhuman/<domain>/rpc.rs".

Also applies to: 36-39, 33-34, 57-58

🤖 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_node/rpc.rs` around lines 20 - 23, The RPC handlers
(e.g., list_tools_handler) currently return Result<serde_json::Value, String>;
change their signatures to return RpcOutcome<serde_json::Value> and update all
return points to construct RpcOutcome::Ok(...) or RpcOutcome::Err(...)
(propagating errors via the RpcOutcome type) instead of using Result<T, String>,
ensuring any CLI/JSON conversion remains at the schema/delegation boundary
rather than inside these handlers; apply the same change to the other handlers
noted (the ones around lines referenced in the review) so the module
consistently uses RpcOutcome<T> as the RPC contract.

Comment on lines +23 to +25
let config = config_rpc::load_config_with_timeout().await?;
let tools = javascript::list_tools(&config)?;
let payload = json!({ "tools": tools });
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.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add debug/trace instrumentation in RPC handlers.

The new RPC entrypoints currently have no debug/trace logs for entry/exit and call boundaries; the returned log vector is not a substitute for runtime diagnostics.

Minimal tracing patch sketch
 use serde::Deserialize;
 use serde_json::{json, Value};
+use tracing::{debug, trace};
@@
 pub(crate) async fn list_tools_handler(
     _params: ListToolsParams,
 ) -> Result<serde_json::Value, String> {
+    debug!("[runtime_node::rpc] list_tools_handler: start");
     let config = config_rpc::load_config_with_timeout().await?;
+    trace!("[runtime_node::rpc] list_tools_handler: javascript::list_tools");
     let tools = javascript::list_tools(&config)?;
@@
-    RpcOutcome::new(payload, log).into_cli_compatible_json()
+    debug!(tool_count = payload["tools"].as_array().map(|v| v.len()).unwrap_or(0), "[runtime_node::rpc] list_tools_handler: done");
+    RpcOutcome::new(payload, log).into_cli_compatible_json()
 }
@@
 ) -> Result<serde_json::Value, String> {
+    debug!(tool_name = %params.tool_name, prefer_markdown = params.prefer_markdown, "[runtime_node::rpc] execute_tool_handler: start");
     let config = config_rpc::load_config_with_timeout().await?;
@@
+    trace!(tool_name = %params.tool_name, "[runtime_node::rpc] execute_tool_handler: javascript::execute_tool");
     let outcome =
         javascript::execute_tool(&config, &params.tool_name, args, params.prefer_markdown).await?;
@@
+    debug!(tool_name = %payload["tool_name"].as_str().unwrap_or("<unknown>"), elapsed_ms = payload["elapsed_ms"].as_u64().unwrap_or(0), "[runtime_node::rpc] execute_tool_handler: done");
     RpcOutcome::new(payload, log).into_cli_compatible_json()
 }

As per coding guidelines, "src/**/*.rs: Rust core code must use log / tracing at debug / trace levels for verbose diagnostics on new/changed flows...".

Also applies to: 39-47, 52-57

🤖 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_node/rpc.rs` around lines 23 - 25, Add tracing calls
around the RPC handler flow: at function entry and exit, and before/after each
key call such as config_rpc::load_config_with_timeout() and
javascript::list_tools(), using tracing::debug or tracing::trace; log the input
context, success/failure of each call (including error details on Err) and
include the final payload and the returned log vector in the exit trace so
runtime diagnostics are available. Locate the handler in rpc.rs and insert
tracing::trace!("enter <handler_name>"); before work begins, trace the result of
load_config_with_timeout() and list_tools() with context, and trace!("exit
<handler_name> payload={:?} logs={:?}", payload, log_vec) on success (and
corresponding traces on error paths). Ensure you import tracing and use
appropriate debug/trace levels per guideline.

@senamakel senamakel merged commit 18ca68a into tinyhumansai:main May 17, 2026
25 checks passed
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.

1 participant