fable-agent/PHASES/phase-15-fusion.md

104 lines
4.1 KiB
Markdown

# Phase 15: Multi-Model Fusion
**Date:** 2026-06-14
**Drivers:**
- Fable 5 / Mythos 5 blocked by US export control directive (June 12, 2026)
- OpenRouter Fusion API achieves Fable-tier intelligence at half the price
- fusion-fable pattern proves fan-out panel + judge synthesis matches or exceeds single best model
- Fable 5 leaked system prompt provides tone, citation, refusal, and behavior patterns
- CineFable provides visual media generation patterns (image/video via fal.ai)
---
## What Was Built
### 1. Fusion Executor (`src/examples/executors/fusion-executor.ts`)
- PhaseExecutor-compatible multi-model panel execution
- Draft → Critique → Fuse pipeline
- Configurable panels: opus4.8-4.8, opus4.8-gpt5.5, opus4.8-gpt5.5-gemini, sonnet-haiku-opus
- Structured analysis output: Consensus, Contradictions, Unique Insights, Blind Spots
- Judge model always synthesizes final answer grounded in panel analysis
### 2. OpenRouter Fusion Executor (`src/examples/executors/openrouter-fusion-executor.ts`)
- Direct integration with OpenRouter Fusion API
- PhaseExecutor-compatible for drop-in use in feedback loop
- Configurable draft/critic/fusion model overrides
- Graceful fallback when API key not configured
### 3. Fable 5 Prompt Engine (`src/upgrades/fable5-prompt-engine.ts`)
- Tone & behavior rules extracted from leaked Fable 5 system prompt
- Citation format helpers (inline and footnote)
- Refusal handling (cybersecurity_exploit, harmful_content, financial/medical)
- Effort-level prompt builder (Low → Ultracode)
- Self-check utility
### 4. Media Generator (`src/upgrades/media-generator.ts`)
- CineFable-style image generation (fal-ai/nano-banana-pro)
- Image-to-video generation (alibaba/happy-horse/image-to-video)
- Gallery persistence (local storage)
- Storyboard creation with reorderable shots
- Mock mode for development without API key
### 5. Fusion Workflow Pattern (`src/fable5/dynamic-workflows.ts`)
- New "fusion-panel" workflow pattern
- Parallel dispatch with configurable concurrency
- Judge synthesis with verification
### 6. Compound Stack Integration (`src/fable5/compound-stack.ts`)
- Fusion as a stakable layer in CompoundStack
- fusionPanel() method with panel slug selection
### 7. CLI Commands (`src/index.ts`)
- `fusion run` — execute fusion panel with model selection
- `fusion panels` — list available panel configurations
- `generate image` — CineFable-style image generation
- `generate video` — Happy Horse video generation
---
## File Map
| File | Purpose |
|------|---------|
| `src/core/fusion-types.ts` | Shared fusion types, panel configs |
| `src/examples/executors/fusion-executor.ts` | Fusion PhaseExecutor |
| `src/examples/executors/openrouter-fusion-executor.ts` | OpenRouter Fusion API executor |
| `src/upgrades/fable5-prompt-engine.ts` | Fable 5 tone/citation/refusal patterns |
| `src/upgrades/media-generator.ts` | CineFable image/video generation |
| `src/fable5/dynamic-workflows.ts` | Fusion workflow pattern |
| `src/fable5/compound-stack.ts` | Fusion layer integration |
| `src/fable5/model-router.ts` | OpenRouter Fusion model route |
| `src/index.ts` | Fusion + generate CLI commands |
| `SKILLS/fusion/SKILL.md` | Fusion skill definition |
| `PHASES/phase-15-fusion.md` | This file |
---
## How to Use
```bash
# Quick fusion (default: opus4.8-4.8)
node dist/index.js fusion run "Design the architecture for a distributed task queue"
# Use OpenRouter Fusion API instead
OPENROUTER_API_KEY=sk-... node dist/index.js fusion run "Compare database options" --openrouter
# Cheap fusion panel
node dist/index.js fusion run "Review this PR" --panel sonnet-haiku-opus
# Generate image (needs FAL_KEY)
node dist/index.js generate image "A futuristic cityscape at sunset" --aspect "16:9"
# Generate video from image
node dist/index.js generate video ./input.png --prompt "gentle camera pan"
```
## What's Next
- [ ] Integrate fusion executor with EnhancedMetaAgent for automatic fusion routing
- [ ] Add real API calls to FusionExecutor.callModel() for production use
- [ ] Add OpenRouter Fusion API response caching
- [ ] Wire MediaGenerator into DreamingSystem for visual distillation
- [ ] Add scene detection to video generation pipeline