Skip to content

AIOHM Platform 2.9.2: M.U.S.E. Code Mode ​

Programmatic MCP tool calling, progressive capability discovery, and isolated execution for M.U.S.E. and the AIOHM agent ecosystem.

1. What is Changing? ​

Traditional Model Context Protocol (MCP) interactions execute tools one-by-one over multiple conversational round trips. Every intermediate result—even thousands of raw database or analytics rows—is passed directly back into the LLM context window.

M.U.S.E. Code Mode transforms tool orchestration:

  1. Progressive Capability Discovery (search_capabilities): Stops loading exhaustive MCP catalogs into prompt context. M.U.S.E. discovers only the functions it needs for a specific task and receives compact TypeScript signatures (api.<domain>.<method>(args)).
  2. Programmatic Execution Plan (execute_code): M.U.S.E. writes a compact TypeScript program that calls multiple integrations in parallel (Promise.all), filters records, and formats output.
  3. Isolated Sandbox (scripts/code-mode-sandbox.mjs): Executes the program in an isolated V8 vm process with strict safety boundaries (no filesystem, process, network, or credential access).
  4. AIOHM Capability Broker: The host-side broker validates tenant authorization, guards risk levels, shields API credentials, and routes write/communication operations through Human-in-the-Loop (HITL) approval gates.
  5. One Focused Result: Only the final, filtered result enters M.U.S.E.'s reasoning context.

2. Measurable Benchmarks ​

Audited using php artisan aiohm:code-mode-benchmark:

MetricTraditional MCP (Tool-by-Tool)M.U.S.E. Code Mode (V8 Plan)Improvement
Cross-Platform Report Tokens21,750 tokens2,090 tokens90.4% reduction
Model Round Trips4 round trips1 single execution75% fewer turns
Intermediate Context Bloat6,300 tokens in prompt0 tokens (filtered in sandbox)100% eliminated
Execution Latency~7,400 ms (est. inference)~292 ms (parallel Node V8)Order of magnitude faster

3. Platform Capabilities & Architecture ​

  • CapabilityRegistry: Catalogs core sovereign capabilities (analytics.*, social.*, mautic.*, wordpress.*, seo.*, knowledge.*, scout.*) and dynamic MCP servers. Generates ambient TypeScript definitions and discovers approved recipes.
  • CapabilityBroker: Host-side dispatcher executing authenticated requests against AIOHM's underlying services. Dispatches AgentApprovalRequest records whenever state-modifying actions are attempted without a pre-approved checksum.
  • CodeModeEngine: Manages the bidirectional JSON RPC protocol over stdin/stdout with the sandbox runner, enforces execution quotas, and stores private output handles in PrivateResultStore.
  • Reusable Intelligence (save_code_mode_skill): Proven execution recipes can be promoted directly to the AIOHM Skill Library and exposed as workflow automation nodes.
  • Workflow Builder Node (code_mode_execution): Registered in WorkflowNodeHandlerRegistry to allow multi-step campaign automations to execute Code Mode plans.
  • Filament Admin Settings: CodeModeSettings page accessible to agency administrators under Platform & Security.

4. Model Tools Added to M.U.S.E. ​

  1. search_capabilities: Find matching platform and MCP capabilities and receive compact TypeScript definitions.
  2. execute_code: Execute a TypeScript/JavaScript plan in the isolated sandbox.
  3. save_code_mode_skill: Save a verified execution plan as a reusable Skill in the Skill Library.
  4. run_approved_code_mode_recipe: Execute an approved, immutable recipe by its verified checksum.