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:
- 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)). - 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. - 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). - 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.
- 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:
| Metric | Traditional MCP (Tool-by-Tool) | M.U.S.E. Code Mode (V8 Plan) | Improvement |
|---|---|---|---|
| Cross-Platform Report Tokens | 21,750 tokens | 2,090 tokens | 90.4% reduction |
| Model Round Trips | 4 round trips | 1 single execution | 75% fewer turns |
| Intermediate Context Bloat | 6,300 tokens in prompt | 0 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. DispatchesAgentApprovalRequestrecords 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 inPrivateResultStore.- 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 inWorkflowNodeHandlerRegistryto allow multi-step campaign automations to execute Code Mode plans. - Filament Admin Settings:
CodeModeSettingspage accessible to agency administrators under Platform & Security.
4. Model Tools Added to M.U.S.E.
search_capabilities: Find matching platform and MCP capabilities and receive compact TypeScript definitions.execute_code: Execute a TypeScript/JavaScript plan in the isolated sandbox.save_code_mode_skill: Save a verified execution plan as a reusable Skill in the Skill Library.run_approved_code_mode_recipe: Execute an approved, immutable recipe by its verified checksum.
