Edge-Native Fractal Agent Engine Blueprint for sub-second, zero-cost, offline autonomous agent execution.
Copy the agent definition below into:
~/.claude/agents/edge-fractal-agent.md---
name: Edge Fractal Agent
description: Edge-Native Fractal Agent Engine Blueprint for sub-second, zero-cost, offline autonomous agent execution.
---
# 🚀 Edge-Native Fractal Agent Engine: Strategic Blueprint
> **Goal**: Pair a hyper-specialized Edge Small Language Model (SLM) with the `fractal-kernel` Node.js manifest architecture to achieve sub-second, zero-cost, offline autonomous agent execution on standard edge CPUs (Intel i3 / Raspberry Pi / Edge Nodes).
---
## 🏗️ The 3-Pillar Architecture
```
┌─────────────────────────────────────────────────────────────────────────┐
│ EDGE SLM BRAIN (1.5B) │
│ - Fine-Tuned Qwen2.5-1.5B / Phi-4-mini (Quantized Q4_K_M: ~1.1GB RAM) │
│ - Speed: 50-80 tokens/sec on Intel i3 CPU │
└────────────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ VIRTUAL SIMULATION GUARDRAIL │
│ - Runs candidate manifests & routing in-memory before mounting │
│ - Zero file system writes until dry-run verification succeeds │
└────────────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ FRACTAL-KERNEL RUNTIME ENGINE │
│ - Auto-discovers self-contained feature modules │
│ - Mounts dynamic routes and executes Node.js business logic │
└─────────────────────────────────────────────────────────────────────────┘
```
---
## 🎯 1. Model Selection & Fine-Tuning Strategy
### Target Base Model
* **Primary Recommendation**: `Qwen/Qwen2.5-1.5B-Instruct` or `Qwen2.5-Coder-1.5B`
* **RAM Footprint**: **~1.1 GB RAM** (4-bit `Q4_K_M` GGUF)
* **Execution Latency**: **< 200 ms initial response, 60+ tokens/sec on i3 CPU**
### Training Focus (The Secret to Extreme Quality at 1.5B Parameters)
Rather than general knowledge, the 1.5B model is fine-tuned **exclusively** on 3 task vectors:
1. **Manifest Generation**: Strict, deterministic creation of `fractal-kernel` JSON feature manifests.
2. **Dynamic Routing**: Evaluating incoming request payloads and mapping them to module routes.
3. **Simulation Tracing**: Generating internal dry-run validation checks to detect invalid schemas.
---
## 🧪 2. Dataset Synthesis Pipeline for `fractal-kernel`
To make a 1.5B model out-perform a generic 70B model on your specific architecture, we build a **High-Density Synthetic Dataset** containing 2,000 instruction pairs:
```json
{
"messages": [
{
"role": "system",
"content": "You are the Fractal-Kernel Edge Routing SLM. Generate precise feature manifests and dry-run simulation checks."
},
{
"role": "user",
"content": "Add an automated dynamic rate-limiter feature module."
},
{
"role": "assistant",
"content": "```json\n{\n \"simulation\": {\n \"dry_run\": \"PASSED\",\n \"memory_impact_mb\": 4.2,\n \"dependencies\": [\"redis-cache\"]\n },\n \"manifest\": {\n \"name\": \"rate-limiter\",\n \"version\": \"1.0.0\",\n \"mountPath\": \"/api/middleware/rate-limit\",\n \"features\": [\"sliding-window\", \"ip-throttle\"]\n }\n}\n```"
}
]
}
```
---
## 🔌 3. Native Node.js `fractal-kernel` Integration
Deploy the fine-tuned model directly inside your Node.js Kernel using `node-llama-cpp` for zero-overhead native C++ bindings:
```javascript
// edge-agent-kernel.js
import { LlamaModel, LlamaContext, LlamaChatSession } from "node-llama-cpp";
import path from "path";
class FractalEdgeAgent {
async init() {
this.model = new LlamaModel({
modelPath: path.join(__dirname, "models", "fractal-agent-1.5b-q4.gguf")
});
this.context = new LlamaContext({ model: this.model });
this.session = new LlamaChatSession({ contextSequence: this.context.getSequence() });
}
async processRequest(userPrompt) {
// Execute sub-second local inference
const response = await this.session.prompt(userPrompt);
const parsed = JSON.parse(response);
// Enforce Virtual Simulation Check before mounting
if (parsed.simulation?.dry_run === "PASSED") {
this.mountFeatureModule(parsed.manifest);
} else {
console.warn("Simulation failed. Aborting feature mount.");
}
}
}
```
---
## 🏁 4. Execution Roadmap
1. **Dataset Build**: Generate 2,000 JSON instruction pairs tailored to `fractal-kernel`.
2. **Kaggle Training**: Train `Qwen2.5-1.5B` via LoRA 4-bit on Kaggle dual T4 GPUs (~45 minutes execution).
3. **GGUF Export**: Export to `Q4_K_M` GGUF (~1.1 GB file).
4. **Edge Benchmark**: Mount in Node.js via `node-llama-cpp` on your i3 PC and measure sub-second response times.
> Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard refuses 3+ file scope. Returns caveman diff receipt. Use when scope is bounded and obvious; do NOT use for new features, new files (unless asked), or cross-file refactors.
> Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard refuses 3+ file scope. Returns caveman diff receipt. Use when scope is bounded and obvious; do NOT use for new features, new files (unless asked), or cross-file refactors.
Produces clean reusable raster assets from approved Impeccable mock references without redesigning the direction.