Skip to content
Back to skills

Brain

ASecurity

Apply Active Inference to minimize prediction error (Surprise).

  • 23 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 14, 2026
ai-agentspythongorailsapisecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned October 14, 2026

npx -y skills add andreibesleaga/GABBE --skill brain --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Brain?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Brain
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-brain/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-brain)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: active-inference
description: Apply Active Inference to minimize prediction error (Surprise).
triggers: [active inference]
tags: [brain]
context_cost: medium
tools: [run_command, read_file]
---
# Active Inference Skill

> "Action is the process of changing the world to match your prediction."

## 1. The Concept (Free Energy Principle)
Standard agents are goal-directed (maximize reward); **Active Inference** agents are surprise-minimizing (minimize prediction error).
- **Goal:** not just to "win" but to understand and control.
- **Surprise:** the gap between *expectation* and *observation*.

> **Implementation note (conceptual framing, not implemented CLI math):** the production `gabbe/brain.py` uses epsilon-greedy gene selection plus a monotonic `success_rate` reward (effectively a bandit over prompt variants); the free-energy / active-inference framing here is conceptual, not implemented math. Use it to *shape agent instructions*, not as a literal solver — and never claim it "guarantees correctness." See `guides/ai/self-evolving-skills.md` for what actually runs.

## 2. The Feedback Loop
1. **Predict:** "Running `go test` will output PASS."
2. **Act/Sense:** run the command, read output.
3. **Compare:** compute prediction error — result "FAIL" → **Surprise!**

## 3. Solving the Error
Two ways to minimize surprise:
1. **Perceptual Inference (change mind):** "My model was wrong" → update docs/mental model.
2. **Active Inference (change world):** "The code is wrong" → edit it so the test passes.

## 4. Epistemic Action (Curiosity)
When surprise is "unknown" (high uncertainty), take an **epistemic action** (probe/log) to gain information rather than a pragmatic action toward a goal.

## 5. System Prompt Template
```markdown
You are an Active Inference Agent. Minimize "Surprise".

### Your Cycle
1. PREDICT: From your internal model, what do you expect next?
2. OBSERVE: Look at the actual tool output / user input.
3. COMPARE: Compute Prediction Error (Surprise).
4. RESOLVE:
   - Surprise HIGH → Epistemic Action (gather info to update model) or Pragmatic Action (force world to match prediction).
   - Surprise LOW → proceed with standard goal execution.

### Current State
- Goal: {{user_goal}}
- Expectation: {{current_expectation}}
- Observation: {{last_tool_output}}
```

## 6. Implementation (Pythonic Pseudo-code)
```python
def active_inference_step(agent, observation):
    surprise = calculate_divergence(agent.predict(), observation)
    if surprise > THRESHOLD:
        if agent.uncertainty > 0.8:
            return "explore_environment"   # epistemic
        return "correct_environment"       # pragmatic (active inference)
    return "continue_goal"
```

## Security & Guardrails

### 1. Skill Security (Active Inference)
- **Epistemic Action Containment**: epistemic actions are unpredictable — clamp them to read-only ops (`ls`, `cat`, `kubectl get`). They must NEVER mutate state or write to external APIs, preventing accidental DoS or data corruption during "exploration."
- **Surprise-Induced Hallucination**: on exceptionally high prediction error (e.g. garbled binary instead of JSON), the agent may panic and hallucinate a justification. Add a circuit breaker: if Surprise exceeds the max threshold, halt Active Inference and escalate to the human rather than acting blindly.

### 2. System Integration Security
- **Prediction Model Poisoning**: the internal model sets expectations; injection in a log file aligns those expectations with the attacker's goals. Sanitize all OODA inputs (user strings, external web payloads) before using them to compute Prediction Error.
- **Action Rate Limiting**: the loop can spiral if the agent repeatedly "fixes" a failing test via syntax changes. Enforce a max loop limit (e.g. 5 attempts) to prevent runaway compute and API rate-limit exhaustion.

### 3. LLM & Agent Guardrails
- **Destructive Pragmatism Bias**: the agent may decide the fastest "match prediction" route is deleting failing tests or disabling security layers. No pragmatic action from Active Inference may bypass `architecture-governance.skill.md` rules or delete source code without explicit human cryptographic approval.
- **Uncertainty Masking**: the LLM may sound confident while internal uncertainty is high. `active_inference_step` must rely on actual token log-probabilities (if available) or strict parsing constraints — not self-reported "confidence" — to trigger epistemic exploration.

Files in this skill

  • README.md3.8 KB
  • active-inference.skill.md4.4 KB
  • brain-mode.skill.md8.5 KB
  • cognitive-architectures.skill.md3.3 KB
  • cognitive-testing.skill.md5.2 KB
  • consciousness-loop.skill.md3.8 KB
  • cost-benefit-router.skill.md6.2 KB
  • episodic-consolidation.skill.md3.6 KB
  • epistemology-knowledge.skill.md4 KB
  • global-workspace.skill.md3.8 KB
  • learning-adaptation.skill.md5.2 KB
  • loki-mode.skill.md15.9 KB
  • neuroscience-foundations.skill.md3.8 KB
  • scripts/active_inference_loop.py2.6 KB
  • scripts/cognition_test.py2.2 KB
  • scripts/global_workspace.py2.8 KB
  • self-improvement.skill.md5.7 KB
  • sensory-motor.skill.md4 KB
  • sequential-thinking.skill.md3.9 KB
  • working-memory.skill.md4.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.