# PREFRONTAL v3.1: From Guard Rails to Recipe Engine --- How Structured Orchestration Compounds Agent Intelligence

**Oscar Serra^1^, Jarvis^1^**
^1^Independent Research
*7 April 2026 --- v3.1*

---

## Abstract

The gap between preventing bad behaviour and enabling great behaviour is the central challenge of agent architecture. Version 2.4 of this paper proposed compounded intelligence through fractal reflection --- a post-action review cycle that converts events into reusable rules. Deployment validated the compounding hypothesis (+96% CII) but exposed a structural asymmetry: guards prevent mistakes but do not guide excellence.

This paper introduces Prefrontal v3.1, a major architectural revision that transforms the orchestration layer from a passive guard system into an active **recipe execution engine**. The key insight comes from convergent evolution across three independent systems: Anthropic's Claude Code achieves its effectiveness through *skills* --- structured workflow prompts injected on demand that decompose complex tasks into ordered steps; Journey Kits (Berman, 2026) demonstrates that the commercial value of AI agents lies not in the model but in the structured *recipe* wrapped around it; and our own `prefrontal-prompt.md`, a rich orchestration prompt that has sat unused in the codebase for months, already encodes the recipe format we now propose to execute.

The architectural pivot is economical. Prefrontal becomes a **first call** rather than a post-action reflection --- receiving the user's request, selecting or composing a recipe, dispatching parallel subagents, monitoring their progress, and conducting fractal reflection only after the recipe completes. Because this orchestration call shares nearly the same context as the main agent (same SOUL.md, same memory hierarchy, same session history), Anthropic's prompt cache makes the additional LLM call approximately 5% overhead in tokens. The fractal reflection that drove v2.4's compounding becomes the orchestrator's post-completion review --- still present, now properly situated within a complete cognitive cycle that includes pre-action planning, during-action monitoring, and post-action learning.

**Keywords:** recipe execution, agent orchestration, compounded intelligence, cognitive cycle, prompt cache, subagent parallelism, structured workflows

---

## 1. Introduction --- The Recipe Gap

### 1.1 Why Claude Code Works

In March 2026, an accidental source code exposure revealed the internal architecture of Anthropic's Claude Code, the commercially leading AI coding agent. Its effectiveness derives not from a superior model, but from a `while(true)` loop wrapped in three mechanisms:

1. **Skills**: structured prompts injected on demand that encode specific workflows. A "commit" skill prescribes: check status, diff changes, review history, draft message, stage files, commit. A "review-pr" skill prescribes: fetch PR, read changes, check tests, assess impact, write review. These are not suggestions --- they are recipes that the agent executes step by step.

2. **Fork subagents**: child agents that inherit the parent's full context (exploiting prompt cache for near-zero marginal cost), run in background with isolated tool sets, and return results to the orchestrator.

3. **Five-layer context compression**: aggressive management of the context window through conversation compaction, tool result summarisation, and a `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` that separates cacheable from per-turn content.

These are operational recipes distilled from failures.

The meta-pattern is clear: Claude Code's effectiveness comes from skills that are recipes, executed in sequence, by an agent that knows which recipe to apply.

### 1.2 The Journey Kits Thesis

Matthew Berman's Journey Kits (journeykits.ai, 2026) makes clear an insight that was implicit in the Claude Code analysis: **the value is not the model --- it is the structured workflow wrapped around it**. Journey Kits proposes an "npm for AI agent workflows" --- a registry of reusable recipes that bundle skills, source code, documentation, and metadata into distributable packages.

The thesis is direct: if you give the same model to two teams, the one with better recipes wins. The model is the commodity; the recipe is the differentiator. This inverts the conventional wisdom that model capability is the primary driver of agent quality.

Journey Kits identifies the recipe as the atomic unit of agent value. A recipe is not a prompt --- it is a structured workflow with preconditions, ordered steps, success criteria, and failure handlers. The distinction matters: a prompt says "fix this bug"; a recipe says "reproduce the bug, locate the root cause, write a failing test, implement the fix, verify the test passes, check for regressions, commit with a descriptive message."

### 1.3 The v2.4 Gap

Version 2.4 of this paper promised compounded intelligence through fractal reflection --- "the compounding engine" that converts events into reusable rules at multiple abstraction levels. The implementation delivered guards, observability, and monitoring, but lacked a navigation system for agents.

v2.4 omitted the compounding engine itself. Fractal reflection, described in Section 3.1 of v2.4 as the primary mechanism of intelligence compounding, exists only as a prompt template (`prefrontal-prompt.md`) that was never wired into the execution pipeline. The four-question reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) runs only when the agent voluntarily follows the system prompt's instructions, which it does inconsistently.



### 1.4 The Cache-Shared First Call

The architectural insight that enables v3.1 is economic. Anthropic's prompt cache means that a second LLM call with *nearly the same context* as the first is dramatically cheaper than two independent calls. If the system prompt, SOUL.md, memory hierarchy, and session history are identical between calls, only the differing portion (the orchestration instruction vs. the task instruction) incurs full token cost.

Prefrontal becomes a **first call**, planning execution at ~5% overhead. Orchestration is nearly free.

The same cache property enables the fractal reflection to remain a *second call* after task completion, also at minimal marginal cost. The complete cognitive cycle --- plan, execute, reflect --- costs approximately 10% more than unorchestrated execution but produces structured, repeatable, self-improving behaviour.

---

## 2. Architecture --- The Orchestrator Model

### 2.1 System Overview

Prefrontal v3.1 introduces a three-phase cognitive cycle that wraps every agent interaction:

```
User message
    |
    v
[Phase 1: PLAN] -- Prefrontal LLM call (cache-shared)
    |   - Classify intent
    |   - Select or compose recipe
    |   - Present plan to user (if complex)
    |   - Allocate subagents
    v
[Phase 2: EXECUTE] -- Subagent dispatch
    |   - Fan-out workers with isolated contexts
    |   - Prefrontal monitors progress via events
    |   - Stall detection and intervention
    |   - Periodic status updates to UI
    v
[Phase 3: REFLECT] -- Fractal reflection (cache-shared)
    |   - MEMORY: persist new knowledge
    |   - PATTERN: multi-level abstraction
    |   - RIPPLE: scan for staleness
    |   - IMPROVE: opportunistic fixes
    v
Response to user
```

**Figure 1.** The three-phase cognitive cycle. Phases 1 and 3 are cache-shared LLM calls with approximately 5% token overhead each. Phase 2 is standard agent execution with Prefrontal monitoring via WebSocket events.

For simple requests, Phase 1 bypasses recipe selection to avoid overhead.

### 2.2 Prefrontal as First Call

The traditional agent architecture processes user messages directly: the message enters the model alongside the system prompt, and the model decides what to do. Prefrontal v3.1 interposes an orchestration layer:

1. The user's message arrives at the gateway.
2. **Before** the main agent processes it, Prefrontal receives the message with the same context (SOUL.md, memory hierarchy, session history) plus an orchestration-specific instruction set.
3. Prefrontal classifies the intent, selects a recipe, and emits a structured plan.
4. The plan is injected into the main agent's context as a structured preamble.
5. The main agent executes with the recipe's steps as explicit guidance.

The critical design decision is that Prefrontal does *not* replace the main agent, nor does it introduce a separate "manager agent". Prefrontal is a cache-shared first call using the *exact same agent*, simply prepending the recipe. The main agent retains full autonomy; the recipe provides structure, not bureaucratic constraint. This preserves the flexibility that makes LLM agents valuable while adding the predictability that makes them reliable.

**Why first, not second?** Version 2.4's fractal reflection operated as a post-action review --- useful for learning, but unable to prevent the mistakes it learned from. By moving to a pre-action position, Prefrontal can shape the agent's approach *before* tokens are spent on a flawed strategy. The post-action reflection remains, but now reviews execution against the plan rather than against an implicit standard.

### 2.3 The Cache Trick

The economics of this architecture depend entirely on prompt caching. Consider a typical agent turn:

| Component | Tokens | Cached? |
|-----------|--------|---------|
| System prompt (SOUL.md, agents, rules) | ~8,000 | Yes (static) |
| Memory hierarchy (retrieved files) | ~4,000 | Yes (session) |
| Session history | ~6,000 | Yes (session) |
| Orchestration instruction | ~800 | No |
| User message | ~200 | No |
| **Total** | **~19,000** | **~95% cached** |

The Prefrontal call uses the same first 18,000 tokens as the main agent call. Only the orchestration instruction (replacing the main agent's task instruction) differs. At Anthropic's cache pricing (90% discount on cached tokens), the Prefrontal call costs approximately 5% of a full call.

This is not an optimisation --- it is an architectural enabler. Without prompt caching, a pre-action orchestration call would double the cost of every turn. With it, orchestration is nearly free, and the question shifts from "can we afford orchestration?" to "can we afford *not* to orchestrate?"

### 2.4 Subagent Parallelism

For decomposable tasks, Prefrontal fans out parallel subagents:

- **Fork subagents** inherit the parent's rendered prompt (cache-shared) and receive a scoped task: "investigate the stack trace," "write a failing test," "check for similar patterns in the codebase." 

- **Prefrontal monitors** subagent progress via WebSocket events. Each subagent emits structured status updates: task accepted, tool calls in progress, intermediate findings, completion with results.

- **Stall detection**: if a subagent exceeds its expected duration (configurable per recipe step, default 120 seconds) or enters a tool-denial loop (3 consecutive denials), Prefrontal intervenes --- either reassigning the task, providing additional context, or escalating to the user.

- **Result aggregation**: as subagents complete, Prefrontal assembles their outputs into a coherent response. For investigation tasks, this means synthesising findings. For implementation tasks, this means verifying consistency across parallel changes.

The parallelism model mirrors Claude Code's fork pattern but adds active monitoring. Claude Code's forked subagents run independently and return results; Prefrontal's subagents are *supervised* --- the orchestrator watches their progress and can intervene. This supervision is the difference between delegation and orchestration.

### 2.5 Periodic Progress Reports

For long-running tasks (multi-file refactors, complex investigations, deployment sequences), Prefrontal emits periodic status updates to the Tinker UI via WebSocket events:

```json
{
  "type": "prefrontal:progress",
  "recipe": "feature-implementation",
  "step": 3,
  "totalSteps": 7,
  "stepName": "Write failing tests",
  "subagents": [
    {"id": "sa-001", "status": "complete", "task": "Investigate root cause"},
    {"id": "sa-002", "status": "running", "task": "Write test cases", "elapsed": "45s"},
    {"id": "sa-003", "status": "pending", "task": "Implement fix"}
  ],
  "elapsed": "2m15s"
}
```

The Tinker UI renders these as a real-time progress panel in the right sidebar, extending the existing call tree with recipe step indicators, subagent status badges, and elapsed time per step. Users see not just *that* the agent is working, but *what* it is doing, *where* it is in the recipe, and *how long* each step is taking.

### 2.6 Visualisation: The Call Tree

The existing Prefrontal call tree panel (`prefrontal-tree.ts`) displays agent topology with real-time phase indicators. Version 3.0 extends this with:

- **Recipe overlay**: the current recipe's steps are displayed as a vertical timeline alongside the call tree, with the active step highlighted and completed steps checked.
- **Subagent mapping**: each subagent node in the tree is linked to its recipe step, showing which part of the plan each worker is executing.
- **Cost tracking**: cumulative token usage per subagent and per recipe step, enabling real-time cost visibility.
- **Stall indicators**: subagents that exceed their expected duration are highlighted with a warning indicator, and Prefrontal's intervention actions are displayed inline.

---

## 3. The Recipe System

### 3.1 Recipe Format

A recipe is a structured markdown document with the following schema:

```markdown
# Recipe: debug

## Metadata
- intent: bug-fix, error-investigation, crash-analysis
- complexity: medium
- estimated-duration: 5-15 minutes
- models: [sonnet, opus]

## Preconditions
- [ ] Error report or symptom description available
- [ ] Repository context loaded

## Steps

### Step 1: Reproduce
Confirm the bug exists. Run the failing command, check logs, verify the symptom.
- tools: [Bash, Read]
- gate: Must have confirmed reproduction before proceeding.

### Step 2: Locate
Find the root cause. Search the codebase, read stack traces, trace the execution path.
- tools: [Grep, Glob, Read]
- gate: Must have identified a specific file and line range.

### Step 3: Understand
Read the surrounding code. Understand the intent, the constraints, the history.
- tools: [Read, Bash(git log)]
- gate: Must articulate why the current code is wrong.

### Step 4: Fix
Implement the minimal fix. Change only what is necessary.
- tools: [Edit, Write]
- gate: Fix must be consistent with the root cause from Step 2.

### Step 5: Verify
Run tests. Check that the fix works and nothing else broke.
- tools: [Bash]
- gate: All relevant tests must pass.

### Step 6: Document
Update any affected documentation, comments, or memory files.
- tools: [Edit, Write]
- gate: No stale documentation remains.

## Success Criteria
- Bug is fixed and verified by test
- Root cause is documented
- No regressions introduced

## Failure Handlers
- Step 1 fails (cannot reproduce): Gather more information from user
- Step 4 fails (fix too complex): Escalate to user with analysis
- Step 5 fails (tests break): Revert and re-analyse
```

Recipes are human-readable markdown files, editable, storable in memory, and versionable via git, favouring transparency and composability.

### 3.2 Built-in Recipes

Prefrontal v3.1 ships with six built-in recipes covering the most common agent tasks:

| Recipe | Steps | Typical Duration | Key Insight |
|--------|-------|-----------------|-------------|
| **debug** | 6 (reproduce, locate, understand, fix, verify, document) | 5--15 min | Must reproduce before fixing |
| **feature** | 7 (clarify, design, plan, implement, test, verify, document) | 10--30 min | Must design before implementing |
| **investigate** | 5 (scope, search, analyse, synthesise, report) | 5--20 min | Must scope before searching |
| **refactor** | 6 (identify, measure, plan, execute, verify, document) | 10--25 min | Must measure before changing |
| **review** | 5 (overview, deep-read, test, assess, report) | 5--15 min | Must read completely before opining |
| **deploy** | 7 (pre-check, build, test, stage, verify, promote, post-check) | 10--40 min | Must verify at every stage |

Each recipe encodes hard-won operational lessons. The debug recipe's "reproduce before fixing" step prevents the most common agent failure mode: jumping directly to a code change based on the error message without confirming the bug's actual behaviour. The feature recipe's "design before implementing" step prevents premature coding --- the anti-gold-plating principle elevated from a prompt injection to a structural gate.

### 3.3 Custom Recipes

Users can author domain-specific recipes and add them to the recipe library. A data-science team might add recipes for "explore-dataset," "train-model," and "evaluate-results." A DevOps team might add "incident-response," "capacity-planning," and "runbook-execution."

Custom recipes are stored in the memory hierarchy (under `memory/recipes/`) and are automatically available to Prefrontal's recipe selection. This makes the recipe library a *growing* asset --- each new recipe captures operational knowledge that compounds across future sessions, extending the compounding thesis from individual lessons (v2.4) to entire workflows (v3.1).

### 3.4 Recipe Selection

When a user message arrives, Prefrontal classifies the intent and selects the appropriate recipe through a three-tier strategy:

1. **Keyword matching**: explicit signals in the message ("fix this bug" -> debug, "add a feature" -> feature, "what's going on with" -> investigate). Fast, cheap, handles the common cases.

2. **Structure analysis**: message length, presence of error messages or stack traces, code blocks, file paths. A message with a stack trace is likely a debug task even if it does not contain the word "bug."

3. **LLM classification**: for ambiguous messages, Prefrontal's LLM call includes recipe metadata (intent keywords, descriptions) and selects the best match. This is the same call that performs the orchestration, so it incurs no additional cost.

Unstructured messages bypass orchestration.

### 3.5 Step Enforcement

Each recipe step includes a **gate** --- a condition that must be satisfied before the agent proceeds to the next step. Gates are expressed in natural language and evaluated by the orchestrator:

- *"Must have confirmed reproduction before proceeding"* --- Prefrontal checks whether the subagent's output includes evidence of reproduction (a failing test, a reproduced error message, a confirmed symptom).
- *"Must have identified a specific file and line range"* --- Prefrontal checks for file paths and line numbers in the investigation output.

Gates are advisory, not absolute. If a subagent presents a compelling case for skipping a step ("the bug is obvious from the error message, reproduction is unnecessary"), Prefrontal can grant an exception. The enforcement is structural --- it creates a default path of thoroughness that requires explicit justification to deviate from, rather than a rigid pipeline that breaks on edge cases.

This is the critical difference between a recipe and a script. A script executes mechanically; a recipe provides structure that an intelligent agent can follow, adapt, or override with justification.

---

## 4. The Cognitive Cycle (Complete)

Version 2.4 acknowledged that its architecture captured "only the second half" of the cognitive cycle --- post-action reflection without pre-action planning. GStack's forcing questions (Tan, 2026) demonstrated the value of pre-action reflection, and we incorporated a minimal version (five forcing questions for complex tasks). But forcing questions are not planning --- they refine intent without producing a structured execution strategy.

Version 3.0 completes the cycle.

### 4.1 Pre-Action: From Questions to Recipes

The pre-action phase now encompasses:

1. **Forcing questions** (retained from v2.4): What is the user *actually* asking? What would a wrong answer look like? What constraints exist? These questions refine intent.

2. **Recipe selection**: based on the refined intent, Prefrontal selects or composes an appropriate recipe. For standard tasks, this means choosing from the built-in library. For novel tasks, Prefrontal composes an ad hoc recipe by combining steps from multiple templates.

3. **Plan presentation**: for complex tasks (estimated duration >5 minutes or >3 steps), Prefrontal presents the plan to the user before execution. This allows user redirection and creates an execution contract.

4. **Subagent allocation**: Prefrontal assigns recipe steps to subagents, selecting appropriate models for each (Haiku for simple searches, Sonnet for implementation, Opus for complex reasoning). This operationalises the adaptive effort routing from v2.4 at the recipe level.

### 4.2 During-Action: Supervised Execution

The during-action phase is entirely new. Version 2.4 had no mechanism for monitoring agent execution in progress --- the agent ran, and the reflection reviewed the outcome. Version 3.0 introduces:

- **Progress & Updates**: Subagents emit structured events. Prefrontal updates the UI, showing active steps and progress.
- **Stall detection**: Prefrontal detects stalls (timeouts, retry loops) and intervenes by reassigning or providing context.
- **Cross-subagent coordination**: Prefrontal relays critical findings between parallel subagents to prevent wasted effort.

### 4.3 Post-Action: Fractal Reflection, Orchestrated

The post-action phase retains v2.4's fractal reflection protocol (MEMORY, PATTERN, RIPPLE, IMPROVE) but elevates it from a voluntary prompt instruction to an *orchestrated execution*:

1. **Mandatory execution**: Reflection is a distinct, unavoidable LLM call post-completion.
2. **Recipe-aware reflection**: Reflection assesses the turn context, recipe, plan, and execution trace to identify bottlenecks.
3. **Recipe improvement**: Prefrontal updates recipes automatically when systematic issues are identified.
4. **Structured Knowledge**: Extracted lessons are written to memory, deeply tied to their specific recipe context for higher actionability.

### 4.4 The FRACTAL Pattern: Cache-Shared Follow-Up Calls

The architectural pattern underlying both the pre-action orchestration and the post-action reflection is what we call the **FRACTAL pattern**: a cache-shared follow-up call with a different role.

The fork's `fractal-reflection` extension already implements this pattern for post-action reflection: it makes a second LLM call after each turn, with nearly the same context (exploiting the prompt cache), but with a different instruction ("reflect on what just happened" instead of "execute the user's request"). Version 3.0 applies the same pattern to pre-action orchestration: a first LLM call with the same context but a different instruction ("plan how to handle this request" instead of "handle this request").

The FRACTAL pattern applies generally: any cognitive function (planning, reflection, review) can be implemented via cache-shared calls at ~5% marginal cost, enabling multiple perspectives per turn.

---

## 5. Integration with Existing Extensions

Prefrontal v3.1 does not replace the existing extension ecosystem --- it orchestrates it. Each extension retains its autonomous function while gaining a coordination layer.

### 5.1 Total Recall (Memory Retrieval)

Total Recall provides the hybrid retrieval system (semantic search via local embeddings + structured search via filename patterns) that supplies context to every agent turn. In v3.1, Prefrontal uses Total Recall in two new ways:

- **Recipe-contextual retrieval**: when selecting a recipe, Prefrontal queries Total Recall for prior executions of the same recipe type, injecting relevant lessons into the plan. "Last time you ran the debug recipe on this module, the root cause was in the dependency injection layer."

- **Reflection-driven writes**: knowledge extracted during fractal reflection is written back through Total Recall's indexing pipeline, ensuring new lessons are immediately retrievable in future sessions.

### 5.2 Identity Persistence (SOUL.md)

The agent's identity --- personality, values, communication style --- is encoded in SOUL.md and loaded into every LLM call. In v3.1, this identity persists across all three phases of the cognitive cycle. The Prefrontal orchestration call, the subagent execution calls, and the fractal reflection call all share the same SOUL.md, ensuring that the agent's personality is consistent whether it is planning, executing, or reflecting.

By sharing SOUL.md across all calls, Prefrontal maintains a unified voice, avoiding the personality discontinuities of separate "planner" agents.

### 5.3 Learned Intuition (AMYGDALA)

The AMYGDALA extension (Serra, 2026) --- a neural action gating system that learns to recognise dangerous operations through situation embeddings --- integrates with v3.1 at the subagent level. Each subagent's tool calls pass through AMYGDALA's prudence network before execution, providing learned safety gating that complements the recipe's structural gates.

The integration is bidirectional: AMYGDALA's training data now includes recipe context (which step, which recipe, what preconditions were met), enabling the prudence network to learn that "a file write during debug.fix after successful debug.locate is safe" while "a file write without prior investigation is dangerous." Recipe context makes safety gating more precise.

### 5.4 Fractal Reflection (Orchestrated)

In v2.4, the `fractal-reflection` extension operated independently --- a post-turn LLM call that ran on its own schedule. In v3.1, Prefrontal orchestrates when reflection runs and what context it receives:

- **After recipe completion**: full reflection with recipe context, execution trace, and plan comparison.
- **After simple tasks**: lightweight reflection (MEMORY only, skip PATTERN/RIPPLE/IMPROVE).
- **After failures**: extended reflection with root cause analysis and recipe update recommendations.

This orchestration eliminates the "reflection fatigue" identified in v2.4 Section 5.6 --- the problem of mandatory reflection on every turn creating visible latency during rapid exchanges. By matching reflection depth to task complexity, v3.1 preserves compounding while reducing overhead.

---

## 6. Evaluation Design

### 6.1 FAAR Improvement Targets

The recipe system should produce measurable improvements in first-attempt accuracy by preventing the most common failure modes:

| Failure Mode | v2.4 FAAR Impact | v3.1 Mechanism | Target FAAR Delta |
|-------------|-------------------|----------------|-------------------|
| Fixing without reproducing | -0.08 | debug recipe step gate | +0.06 |
| Coding without designing | -0.06 | feature recipe step gate | +0.04 |
| Searching without scoping | -0.05 | investigate recipe step gate | +0.03 |
| Skipping verification | -0.04 | all recipes include verify step | +0.03 |
| **Cumulative** | **-0.23** | | **+0.16** |

These targets would move the weighted FAAR from 0.90 to ~0.95.

### 6.2 Cost Analysis

The recipe engine adds two LLM calls per complex task (orchestration + reflection). The cost depends on cache hit rates:

| Scenario | Cache Hit Rate | Overhead per Turn | Monthly Impact (est.) |
|----------|---------------|-------------------|----------------------|
| Optimal (stable context) | 95% | ~5% per call, ~10% total | +$2--4 |
| Typical (moderate context churn) | 85% | ~8% per call, ~16% total | +$4--8 |
| Worst case (high context churn) | 70% | ~15% per call, ~30% total | +$8--15 |

Even worst-case overhead is modest compared to savings from improved first-attempt accuracy.

### 6.3 Latency Analysis

The orchestration call adds latency before the agent begins visible work:

| Task Complexity | Orchestration Latency | User-Perceived Impact |
|----------------|----------------------|----------------------|
| Simple (passthrough) | <100ms (classification only) | None |
| Medium (recipe selection) | 1--3s | Minor (plan displayed immediately) |
| Complex (recipe + subagent allocation) | 3--8s | Offset by progress visibility |

For complex tasks, the orchestration latency is offset by faster overall completion (fewer retries, fewer wrong turns) and improved user experience (progress visibility instead of opaque waiting).

### 6.4 Comparison with Claude Code's Skill System

| Dimension | Claude Code Skills | Prefrontal Recipes |
|-----------|-------------------|-------------------|
| Selection | Hard-coded triggers in system prompt | LLM-classified intent matching |
| Execution | Injected as prompt text, agent follows voluntarily | Orchestrated with step gates and monitoring |
| Parallelism | Fork subagents, unsupervised | Fork subagents, supervised by Prefrontal |
| Learning | Skills are static (updated by developers) | Recipes evolve through fractal reflection |
| Cost model | Single call (skill text in prompt) | Cache-shared calls (~10% overhead) |
| Failure handling | Agent's own judgment | Structured failure handlers per step |

The key differentiator is **learning**. Claude Code's skills are effective but static --- they encode developer knowledge at deployment time and do not improve through use. Prefrontal's recipes evolve: each execution generates reflection data that can update the recipe itself, creating a compounding loop where recipes get better the more they are used.

---



### 6.5 Failure Modes and Limitations

While cache-shared orchestration minimizes overhead, it is vulnerable to **cache evictions**. If the session goes dormant and Anthropic evicts the prompt cache, Phase 1 incurs a full context token cost. Furthermore, complex recipes with many parallel subagents can exhaust API rate limits, requiring the orchestrator to pace execution or queue sub-tasks.
## 7. Implementation Status

### 7.1 What Is Built (v2.4 Baseline)

The following components are deployed and operational:

- **Exploration gate**: blocks mutating tools until read-only operations are performed. Live, hooked into every turn.
- **Anti-gold-plating rules**: 11 engineering discipline injections. Live.
- **Forcing questions**: 5 pre-action questions for complex tasks. Live.
- **Denial tracking**: escalation after 3 consecutive tool denials. Live.
- **Permission hooks**: user-defined shell script gates. Live.
- **FAAR tracker**: task outcome recording with category, model, tokens. Live.
- **Effort router**: expensive model warnings on subagent spawns. Live.
- **CORF trigger**: high-stakes decision flagging. Live.
- **Feature flags**: per-hook enable/disable via gateway RPC. Live.
- **Call tree panel**: real-time agent topology in Tinker UI. Live.
- **Guardian process**: 3-minute health checks with auto-recovery. Live.
- **Tool concurrency partitioner**: read-only vs. mutating classification. Tested, wiring pending.
- **Prompt cache boundary**: static/dynamic prompt split. Tested, wiring pending.
- **Fork subagents**: cache-shared child agents. Tested, wiring pending.
- **Deferred tool loading**: on-demand schema loading. Tested, wiring pending.

Total: ~3,300 lines of TypeScript, 151 tests, 11 test files, 6 RPC endpoints.

### 7.2 What Is New in v3.1

The following components are proposed and specified but not yet implemented:

- **Recipe engine**: recipe parsing, step tracking, gate evaluation, failure handler dispatch.
- **Recipe library**: 6 built-in recipes (debug, feature, investigate, refactor, review, deploy) plus custom recipe loading from memory hierarchy.
- **Intent classifier**: three-tier strategy (keyword, structure, LLM) for recipe selection.
- **Orchestrator loop**: Prefrontal as first call with plan injection into main agent context.
- **Subagent supervisor**: progress monitoring, stall detection, cross-subagent coordination, intervention.
- **Progress reporter**: WebSocket event emission for recipe step progress, subagent status, elapsed time.
- **Reflection orchestrator**: mandatory post-recipe reflection with recipe context injection.
- **Recipe evolution**: automatic recipe updates based on reflection findings.
- **UI extensions**: recipe overlay on call tree, cost tracking per step, stall indicators.

### 7.3 Roadmap

**Phase 1 (Foundation)**: Recipe format specification, parser, and built-in library. Intent classifier with keyword and structure matching. Estimated: 1--2 sessions.

**Phase 2 (Orchestration)**: Prefrontal as first call. Orchestrator loop with plan injection. Single-agent execution (no parallelism yet). Estimated: 2--3 sessions.

**Phase 3 (Parallelism)**: Subagent supervisor. Progress reporter. Stall detection. Wire the existing fork-subagent module into the recipe engine. Estimated: 2--3 sessions.

**Phase 4 (Reflection)**: Reflection orchestrator. Recipe-aware reflection context. Recipe evolution from reflection findings. Estimated: 1--2 sessions.

**Phase 5 (UI)**: Recipe overlay on call tree. Cost tracking. Progress panel. Estimated: 1--2 sessions.

**Phase 6 (Learning)**: Recipe selection improves from usage data. Gate thresholds adapt. Recipes fork into variants for different contexts. This phase has no fixed endpoint --- it is the compounding loop itself.

---

## 8. Conclusion

The history of software engineering is a history of structured workflows replacing ad hoc improvisation. Waterfall, agile, TDD, CI/CD --- each methodology succeeded not by making developers smarter but by making their process more structured. The same transition is now happening in AI agent architecture.

Version 2.4 of this paper demonstrated that intelligence compounds through architecture. Four mechanisms --- fractal reflection, tiered memory, CORF parallelism, and adaptive routing --- produced a 96% improvement in composite intelligence over six months. But v2.4's architecture was defensive: it prevented bad behaviour more effectively than it produced good behaviour. The guards worked; the highway was missing.

Version 3.0 proposes the highway. By transforming Prefrontal from a guard system into a recipe execution engine, we complete the cognitive cycle that v2.4 acknowledged was only half-built. Pre-action planning selects the right recipe. During-action monitoring supervises execution. Post-action reflection extracts lessons and improves the recipes themselves. The compounding loop closes: each recipe execution makes the next execution of that recipe better.

The convergent evolution evidence is now three-layered. Claude Code's skills are recipes executed by a `while(true)` loop. Journey Kits proposes recipes as the atomic unit of agent value. Meta-Harness demonstrates that harness optimisation --- the automated discovery of better recipes --- produces 6x performance gains. Three independent teams, working from different premises, arrived at the same conclusion: **the recipe is the unit of agent intelligence**.

The honest assessment remains that much of v3.1 is specified but not yet implemented. The recipe engine, the orchestrator loop, the subagent supervisor, and the reflection orchestrator exist as designs in this paper, not as code in the repository. The v2.4 baseline --- guards, observability, monitoring --- is live and validated. The v3.1 additions are the next implementation target.

The architectural insight is clear: prompt caching makes orchestration nearly free. What remains is wiring existing components into this cognitive cycle.

The intern who never makes the same mistake twice writes things down. The intern who gets promoted writes *recipes* --- structured workflows that make the next person as effective as they are. Version 3.0 is about building agents that write recipes.

---

## References

Anthropic. (2026). Claude Code source code [Accidentally exposed, March 2026]. Analysis based on publicly available descriptions.

Berman, M. (2026). Journey Kits: npm for AI agent workflows. https://journeykits.ai

Chen, X. et al. (2026). MemexRL: Learning to manage agent memory through reinforcement. *arXiv preprint*.

Chollet, F. (2019). On the measure of intelligence. *arXiv preprint arXiv:1911.01547*.

Khattab, O. et al. (2023). DSPy: Compiling declarative language model calls into self-improving pipelines. *arXiv preprint arXiv:2310.03714*.

Lee, J. et al. (2026). Meta-Harness: Automatically optimising agent scaffolding for terminal benchmarks. *arXiv preprint*.

Li, W. et al. (2026). CraniMem: Neural memory compression with hippocampal indexing for LLM agents. *arXiv preprint*.

Madaan, A. et al. (2023). Self-Refine: Iterative refinement with self-feedback. *NeurIPS 2023*.

Maharana, A. et al. (2024). LoCoMo: Long-context memory evaluation for conversational agents. *arXiv preprint*.

Nouse Research. (2026). Hermes Agent: Self-improving skill libraries for autonomous agents.

Packer, C. et al. (2023). MemGPT: Towards LLMs as operating systems. *arXiv preprint arXiv:2310.08560*.

Park, J. S. et al. (2023). Generative agents: Interactive simulacra of human behavior. *UIST 2023*.

Park, S. et al. (2026). Governed Memory: Access control and governance for agent memory systems. *arXiv preprint*.

Serra, O. (2026). AMYGDALA: Adaptive modulation of agent disposition via affective learned association. *Working paper*.

Serra, O. & Jarvis. (2026). PREFRONTAL v2.4: Compounded Intelligence --- How Persistent Agents Get Smarter by Remembering What They Learn. *Working paper*.

Shinn, N. et al. (2023). Reflexion: Language agents with verbal reinforcement learning. *NeurIPS 2023*.

Tan, P. (2026). GStack: Multi-perspective code review through role-based prompt specialisation.

Wang, G. et al. (2023). Voyager: An open-ended embodied agent with large language models. *arXiv preprint arXiv:2305.16291*.

Zhang, L. et al. (2026). A survey of memory architectures for LLM-based agents. *arXiv preprint*.

---

## Appendix A: Recipe Execution Pseudocode

```
ALGORITHM: RecipeExecution(user_message, context, recipe_library)

Input: user_message (raw user request)
       context (SOUL.md, memory hierarchy, session history)
       recipe_library (set of available recipes)
Output: response to user, set of memory writes W

# Phase 1: PLAN (cache-shared LLM call)
intent <- classify_intent(user_message)
if intent.complexity < THRESHOLD_SIMPLE:
    return passthrough(user_message, context)  # no orchestration

recipe <- select_recipe(intent, recipe_library)
plan <- compose_plan(recipe, context)

if plan.estimated_duration > 5 minutes:
    present_plan_to_user(plan)
    if user.redirects:
        plan <- revise_plan(user.feedback)

subagents <- allocate_subagents(plan, context)

# Phase 2: EXECUTE (supervised subagent dispatch)
for each step S in plan.steps:
    workers <- subagents[S]
    dispatch(workers, S.task, S.tools)

    while not S.complete:
        events <- collect_events(workers, timeout=S.expected_duration)

        if stall_detected(events, S):
            intervene(workers, S, context)

        if cross_subagent_update(events):
            relay_findings(events, subagents)

        emit_progress(S, workers)

    if not gate_satisfied(S.gate, workers.output):
        if S.failure_handler exists:
            execute(S.failure_handler)
        else:
            escalate_to_user(S, workers.output)

response <- aggregate_results(plan, subagents)

# Phase 3: REFLECT (cache-shared LLM call)
reflection_context <- {
    recipe: recipe,
    plan: plan,
    execution_trace: subagents.traces,
    response: response
}

W <- FractalReflection(reflection_context, memory_files)

if reflection.recipe_update:
    update_recipe(recipe, reflection.recipe_update)

return response, W
```

## Appendix B: Built-in Recipe Index

| Recipe | Trigger Patterns | Steps | Key Gate |
|--------|-----------------|-------|----------|
| debug | "fix", "bug", stack traces | 6 | Reproduce before fix |
| feature | "add", "implement" | 7 | Design before code |
| investigate | "why", "check" | 5 | Scope before search |
| refactor | "clean up", "refactor" | 6 | Measure before change |
| review | PR URLs, diff blocks | 5 | Read completely before opining |
| deploy | "deploy", "release" | 7 | Verify at every stage |
