fix: wire Anthropic API as model provider for WASM agents#1449
Open
h22fred wants to merge 2 commits intoruvnet:mainfrom
Open
fix: wire Anthropic API as model provider for WASM agents#1449h22fred wants to merge 2 commits intoruvnet:mainfrom
h22fred wants to merge 2 commits intoruvnet:mainfrom
Conversation
WASM agents created via wasm_agent_create/wasm_gallery_create echo input back instead of performing LLM inference because no model provider is attached after construction. The WasmAgent WASM module supports set_model_provider(callback) which accepts a JS async function for LLM calls, but createWasmAgent() never called it — leaving the agent in echo-only test mode. This commit: - Adds createAnthropicProvider() that calls the Anthropic Messages API - Calls agent.set_model_provider() in createWasmAgent() when ANTHROPIC_API_KEY is set - Adds test coverage for the provider wiring Fixes ruvnet#1448 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…M execution The MCP tool `hooks_worker-dispatch` was using setTimeout to fake progress (0→50→100% over 1.5s) instead of actually executing workers. The HeadlessWorkerExecutor class already exists and spawns `claude --print` as a subprocess with process pooling, timeouts, context building, and output parsing — but was never called from the MCP tool layer. This commit: - Imports HeadlessWorkerExecutor in hooks-tools.ts - Creates a lazy-initialized executor singleton - Routes headless worker types (audit, optimize, testgaps, document, ultralearn, refactor, deepdive, predict) through the real executor - Keeps local workers (map, consolidate, benchmark, preload) as immediate completion (they don't need AI) - Falls back gracefully with a warning when Claude Code CLI is not available - Returns actual output and parsedOutput in worker status - Supports both blocking and background execution modes Fixes ruvnet#1448 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wasm_agent_create/wasm_gallery_create) currently echo input back instead of performing LLM inferencecreateWasmAgent()never callsagent.set_model_provider(), leaving the agent in echo-only test modeWasmAgentWASM module already supportsset_model_provider(callback)— it just was never wired upChanges
src/ruvector/agent-wasm.ts: AddedcreateAnthropicProvider()that calls the Anthropic Messages API viafetch(), and wires it intocreateWasmAgent()whenANTHROPIC_API_KEYis set__tests__/ruvector/agent-wasm.test.ts: Added test for model provider being set when API key is presentHow it works
When
ANTHROPIC_API_KEYis not set, the agent falls back to echo mode (backwards compatible).Additional context
Also discovered during testing:
@ruvector/rvagent-wasmis listed inpackage.jsonbut has ESM resolution issues (missingexportsfield in the WASM package — needs fix in@ruvector/rvagent-wasmitself, addingindex.jssymlink works around it)agent_spawn+task_assignworkflows don't execute — agents stay idle (separate issue)Fixes #1448
Test plan
ANTHROPIC_API_KEYset:wasm_agent_create→wasm_agent_promptshould return real LLM responseANTHROPIC_API_KEY: should fall back to echo mode (no regression)🤖 Generated with Claude Code