This guide covers how to test and debug The Wizard, Redstring's AI agent.
The easiest way to test The Wizard is using the self-starting E2E runner:
API_KEY=your-openrouter-key MODEL=openai/gpt-5.1-chat npm run test:wizard:e2eThis automatically:
- Starts the agent-server
- Waits for it to be ready
- Runs all Wizard E2E tests
- Cleans up and shuts down
The agent server (formerly bridge-daemon) handles AI requests and state synchronization:
npm run agent-server
# or for compatibility:
npm run bridgeThis starts the server on port 3001. Keep this terminal open.
For full end-to-end testing with goal execution:
npm run devThis starts the UI on port 4000. The UI's Committer processes queued goals.
Dry-run mode (tests bridge connectivity, no API key needed):
npm run test:wizard:dryFull mode (tests AI intent detection, requires API key):
API_KEY=your-openrouter-key npm run test:wizardAuto-discover mode (tests all wizard tools automatically):
API_KEY=your-openrouter-key npm run test:wizard:autoSelf-starting E2E mode (starts server, runs tests, cleans up - best for CI/AI testing):
API_KEY=your-openrouter-key MODEL=openai/gpt-5.1-chat npm run test:wizard:e2e| Test | Description | Requires API Key |
|---|---|---|
| Bridge State Sync | UI can sync state to bridge | No |
| Create Edge | AI detects "connect X to Y" intent | Yes |
| Update Edge | AI detects "change connection" intent | Yes |
| Delete Edge | AI detects "remove connection" intent | Yes |
| Delete Graph | AI uses context instead of asking for ID | Yes |
| Pending Actions API | Bridge returns pending actions | No |
| Telemetry API | Bridge returns telemetry data | No |
| Auto-Discover Tools | Discovers and tests all wizard tools | Yes (with --auto-discover) |
┌─────────────────────────────────────────────────────────────┐
│ User Request │
│ "connect Earth to Sun" │
└─────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Bridge Daemon (:3001) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Planner │ → │ Queue │ → │ Executor │ │
│ │ (LLM Call) │ │ Manager │ │ (roleRunners)│ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ UI Committer (:4000) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Patch │ → │ Apply │ → │ Store │ │
│ │ Auditor │ │ Mutations │ │ (Zustand) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
| File | Purpose |
|---|---|
bridge-daemon.js |
Main AI agent, intent detection, prompt engineering |
src/services/orchestrator/roleRunners.js |
Task executor (handles tool operations) |
src/services/Committer.js |
Applies patches to the store |
src/ai/BridgeClient.jsx |
Syncs UI state to bridge |
test/ai/wizard-e2e.js |
E2E test harness |
curl http://localhost:3001/api/bridge/healthcurl http://localhost:3001/api/bridge/statecurl http://localhost:3001/api/bridge/pending-actionscurl http://localhost:3001/api/bridge/telemetrycurl http://localhost:3001/api/bridge/debug/tracesStart the bridge with npm run bridge.
The app-semantic-server needs to proxy requests to the internal bridge daemon. Check that /api/bridge/state and /api/bridge/actions are being proxied.
Goals execute in the UI's Committer. Make sure the UI is running (npm run dev).
The prompt should instruct the AI to use context. Check AGENT_PLANNER_PROMPT in bridge-daemon.js.
- Check that nodes exist in the graph
- Check that the executor handles
create_edge,delete_edgetools - Check that
definitionNodeis being processed correctly
-
Update the prompt in
bridge-daemon.js:- Add to intent enum in OUTPUT FORMAT
- Add intent documentation with example
-
Add intent handler in
bridge-daemon.js:- Add
if (resolvedIntent === 'your_intent')block - Queue tasks via
queueManager.enqueue
- Add
-
Add executor handler in
roleRunners.js:- Add
else if (task.toolName === 'your_tool')block - Push operations to
opsarray
- Add
-
Add test in
wizard-e2e.js:- Add test case with example prompt
- Validate expected behavior
The wizard can now test itself automatically! The --auto-discover flag enables a self-testing mode that:
- Discovers all tools - Queries
/api/bridge/toolsto get the complete list of wizard capabilities - Generates test cases - Creates appropriate test messages for each tool
- Executes tests - Runs the wizard with test messages and validates responses
- Reports results - Shows which tools work and which fail
✅ Zero maintenance - New tools are automatically tested ✅ Full coverage - Every intent gets exercised ✅ Regression safety - Know immediately if something breaks ✅ Self-documenting - Living examples of what the wizard can do
$ API_KEY=your-key npm run test:wizard:auto
Test 8: Auto-discover all wizard tools...
Discovered 12 tools: qa, create_graph, create_node, analyze, update_node, delete_node, delete_graph, update_edge, delete_edge, create_edge, bulk_delete, enrich_node
Testing qa: "What graphs do I have?"
✓ qa returns response
Testing analyze: "Analyze the current graph structure"
✓ analyze returns response
Testing create_node: "Add a Computer node to this graph"
✓ create_node returns response
📊 Test Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Passed: 11
Failed: 0
✅ All tests passed!Returns all available wizard tools/intents for auto-discovery testing.
Response:
{
"tools": [
{
"name": "create_graph",
"description": "Create a new knowledge graph with nodes and edges",
"parameters": { "type": "object", ... }
},
...
],
"count": 12,
"type": "intent-based",
"note": "The wizard uses intent-based planning, not function calling..."
}Main AI agent endpoint. Accepts user message and context.
{
"message": "connect Earth to Sun",
"context": {
"activeGraphId": "graph-123",
"activeGraph": {
"name": "Solar System",
"nodeCount": 2,
"edgeCount": 1
},
"conversationHistory": [],
"apiConfig": {
"provider": "openrouter",
"model": "openai/gpt-4o-mini"
}
}
}Sync UI state to bridge.
Get queued actions for UI to process.
Get execution telemetry and chat history.
| Variable | Description | Default |
|---|---|---|
BRIDGE_PORT |
Bridge daemon port | 3001 |
API_KEY |
OpenRouter/Anthropic API key | - |
BRIDGE_URL |
Bridge URL for tests | http://localhost:3001 |