Skip to content

PabloRaka/gravity-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Version License Status Agents Protocols

πŸ€– Multi-Agent System Framework

A cognitive-inspired multi-agent orchestration framework with memory systems, decision engine, self-learning feedback loop, and enterprise-grade safety protocols.


πŸ“– Overview

This framework implements an intelligent multi-agent system inspired by cognitive architecture. It coordinates 8 specialized AI agents through an orchestration layer, with a memory system that enables learning from past executions.

Key Features

  • 🧠 4-Layer Memory System β€” Short-term, Episodic, Semantic, and Long-term memory
  • 🎯 Intelligent Decision Engine β€” Auto-selects and orders agents based on task analysis
  • πŸ”„ Self-Learning Feedback Loop β€” Evaluates performance and improves over time
  • πŸ“¦ Standard Data Schema β€” Unified communication format across all agents
  • ⚑ Hybrid Execution β€” Sequential, parallel, or hybrid agent execution
  • πŸ›‘οΈ Error Recovery β€” Retry, escalate, and abort protocols built-in
  • πŸ›‘ Human-in-the-Loop (HITL) β€” Approval gates for high-risk actions
  • βͺ Rollback Strategy β€” Automatic undo when agents fail mid-execution
  • πŸ“ Context Window Management β€” Prevent token overflow across agent chains
  • πŸ’Ύ State Checkpointing β€” Crash recovery and execution resumption
  • πŸ“‹ Agent Discovery & Registry β€” Auto-detect new agents without manual config

πŸ—οΈ Architecture

               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚  Agent Registry  β”‚ ← Auto-discover agents
               β”‚  Checkpoint Checkβ”‚ ← Resume if interrupted
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        ↓
User Input β†’ [Short-Term] β†’ [Episodic] β†’ [Semantic]
                        ↓
                [Decision System]  (+ risk assessment)
                        ↓
                 [Orchestrator]
                        ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  For each agent:                      β”‚
    β”‚  [HITL Gate] β†’ [Snapshot] β†’           β”‚
    β”‚  [Context Check] β†’ [Execute] β†’        β”‚
    β”‚  [Checkpoint] β†’ [Error/Rollback]      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        ↓
                [Feedback System]
                        ↓
               [Long-Term Memory]
                        ↓
                   [Cleanup]

πŸ“‚ Project Structure

.agents/
β”œβ”€β”€ agent-system/
β”‚   β”œβ”€β”€ agents/                        # πŸ€– Specialized agents (auto-discovered)
β”‚   β”‚   β”œβ”€β”€ ai-engineer-agent/         # AI/ML model design & deployment
β”‚   β”‚   β”œβ”€β”€ backend-agent/             # Backend systems & API development
β”‚   β”‚   β”œβ”€β”€ bug-analyzer-agent/        # Bug detection & root cause analysis
β”‚   β”‚   β”œβ”€β”€ code-reviewer-agent/       # Code quality & best practices review
β”‚   β”‚   β”œβ”€β”€ database-agent/            # Database design & optimization
β”‚   β”‚   β”œβ”€β”€ frontend-agent/            # Frontend UI development
β”‚   β”‚   β”œβ”€β”€ security-agent/            # Vulnerability scanning & security
β”‚   β”‚   └── software-engineer-agent/   # System architecture & design
β”‚   β”‚
β”‚   β”œβ”€β”€ decision-system/               # 🎯 Agent selection & task routing
β”‚   β”œβ”€β”€ orchestrator/                  # πŸ”„ Multi-agent coordination
β”‚   β”œβ”€β”€ feedback-system/               # πŸ“Š Performance evaluation & learning
β”‚   β”œβ”€β”€ memory-system/                 # 🧠 Cognitive memory layers
β”‚   β”‚   β”œβ”€β”€ short-term/                # Current context + checkpoints
β”‚   β”‚   β”œβ”€β”€ episodic/                  # Past execution cases
β”‚   β”‚   β”œβ”€β”€ semantic/                  # Rules & best practices
β”‚   β”‚   └── long-term/                 # Optimized strategies
β”‚   β”‚
β”‚   └── shared/                        # πŸ“‹ Global rules, schema & protocols
β”‚       β”œβ”€β”€ SKILL.md                   # Standard Data Schema & rules
β”‚       β”œβ”€β”€ agent-registry/            # πŸ“‹ Auto-discovery & capability index
β”‚       β”œβ”€β”€ hitl-protocol/             # πŸ›‘ Human-in-the-Loop approval gates
β”‚       β”œβ”€β”€ rollback-protocol/         # βͺ Undo strategy on failure
β”‚       β”œβ”€β”€ context-management/        # πŸ“ Token budget & summarization
β”‚       └── checkpoint-protocol/       # πŸ’Ύ Crash recovery & state persistence
β”‚
└── workflows/
    └── workflow.md                    # πŸ“ Execution pipeline definition

πŸ€– Agents

All agents are auto-discovered via the Agent Registry. Each agent's SKILL.md includes frontmatter metadata for automatic registration.

Agent Responsibility Risk Level Priority
Security Identify vulnerabilities and harden systems (OWASP) πŸ”΄ High 1
Software Engineer End-to-end architecture and system design 🟑 Medium 2
Backend Build scalable backend systems and APIs 🟑 Medium 3
Database Design, optimize, and manage database systems πŸ”΄ High 4
Frontend Build modern, responsive frontend UIs 🟑 Medium 5
AI Engineer Design & implement AI/ML models and pipelines 🟑 Medium 6
Bug Analyzer Detect, trace, and fix bugs with prevention 🟒 Low 7
Code Reviewer Review code quality, performance, and standards 🟒 Low 8

Adding a new agent? Just create a new folder in agents/ with a SKILL.md β€” it's automatically registered!


🧠 Memory System

The memory architecture is inspired by human cognitive science:

Memory Type Purpose Retention
Short-Term Current task context, checkpoints & active agents 1 execution cycle
Episodic Past cases, outcomes, and lessons learned 50 most recent (FIFO)
Semantic Rules, best practices, and anti-patterns Permanent (rule-based)
Long-Term Proven strategies and optimized flows 100 patterns (score-based)

Pattern Lifecycle

New Pattern (score β‰₯ 7) β†’ Candidate (1-4 uses)
    β†’ Proven (5+ uses, < 30% failure)
    β†’ Deprecated (failure rate > 30%)

πŸ”’ Safety Protocols

πŸ›‘ Human-in-the-Loop (HITL)

Every agent action is classified by risk level. High-risk and critical actions require explicit user approval before execution.

Risk Level Approval Required Examples
🟒 Low ❌ Auto-proceed Code review, analysis
🟑 Medium ❌ Auto-proceed Generate new code
πŸ”΄ High βœ… Required Modify schema, change auth
⚫ Critical βœ… Required Delete data, deploy to prod
  • Timeout default: abort (safe default)
  • Expert mode: auto_approve_all: true to skip gates

βͺ Rollback Strategy

If an agent fails mid-execution, the system automatically reverts changes:

  • Full Rollback β€” Revert all agents in reverse order (LIFO)
  • Partial Rollback β€” Revert only failed dependency chain
  • Selective Rollback β€” User picks which agents to revert
Agent C fails β†’ Rollback C β†’ Rollback B β†’ Rollback A
(reverse execution order, restore snapshots)

πŸ’Ύ State Checkpointing

Progress is saved after each agent completes. If execution is interrupted:

  • Automatically detected on next run
  • User is prompted to resume or start fresh
  • Checkpoints expire after 24 hours

πŸ“ Context Window Management

Prevents token overflow in multi-agent chains:

  • Smart Summarization β€” Large outputs summarized before passing
  • Reference Mode β€” Very large data stored as retrievable artifacts
  • Priority Pruning β€” Metadata dropped first, core data kept intact
  • Per-Agent Budgets β€” Token limits enforced per agent

πŸ”„ Workflow Pipeline

The system follows a 6-phase execution pipeline:

Phase 0: Initialization

Agent registry scan β†’ Checkpoint recovery check

Phase 1: Context Loading

Load user request β†’ Retrieve past cases β†’ Load rules & practices

Phase 2: Decision & Planning

Classify task β†’ Query registry β†’ Select agents β†’ Assess risk β†’ Calculate context budget

Phase 3: Execution

For each agent: HITL gate β†’ Snapshot β†’ Context check β†’ Execute β†’ Checkpoint β†’ Error handling

Phase 4: Evaluation & Learning

Score results β†’ Detect issues β†’ Evaluate protocols β†’ Store learnings

Phase 5: Cleanup

Delete checkpoint β†’ Clear artifacts β†’ Clear snapshots


πŸ“‹ Standard Data Schema

All agents communicate using a unified envelope format (v2.0):

{
  "agent_name": "backend-agent",
  "timestamp": "2026-04-08T15:45:00Z",
  "status": "success",
  "confidence": 0.92,
  "input_received": {
    "from_agent": "database-agent",
    "task_summary": "Implement REST API for user management",
    "summarized": false,
    "artifact_refs": []
  },
  "output": {
    "type": "code",
    "data": {},
    "artifacts": []
  },
  "pre_execution_snapshot": {
    "snapshot_id": "snap_001",
    "files_modified": [],
    "files_created": []
  },
  "context_info": {
    "input_tokens": 1200,
    "output_tokens": 2300,
    "summarized": false
  },
  "metadata": {
    "risk_level": "medium",
    "approval_status": "not_required",
    "checkpoint_id": "chk_001"
  }
}

⚠️ Error Recovery

Agent fails β†’ Retry with simplified prompt
    ↓ fails again
Escalate to software-engineer-agent
    ↓ fails again
Trigger Rollback (reverse order) β†’ Notify user β†’ Report to feedback-system

πŸš€ Getting Started

Prerequisites

  • An AI coding assistant that supports .agents/ directory structure (e.g., Gemini, Cursor, etc.)

Usage

Option 1: Quick Install (Recommended) Open your project terminal and run:

npx gravity-skill init

This will automatically copy the agent system into your project root.

Option 2: Clone for Contribution If you wish to contribute to the framework:

git clone https://github.com/PabloRaka/skills-workflow-for-code.git
cd skills-workflow-for-code
  1. Place the .agents/ directory in your project root.
  2. Your AI assistant will automatically pick up the agent system configuration.
  3. Invoke the workflow by referencing /workflow in your AI assistant.

Adding a New Agent

  1. Create a new folder: agents/your-agent-name/
  2. Add a SKILL.md with required frontmatter:
    ---
    name: your-agent-name
    description: What this agent does
    capabilities:
      - keyword1
      - keyword2
    input_types:
      - type1
    output_types:
      - type1
    risk_level: low | medium | high | critical
    priority: 1-10
    ---
  3. The agent registry will auto-discover it on next execution!

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Ideas for Contribution

  • Add new specialized agents
  • Improve memory retrieval algorithms
  • Add agent performance benchmarks
  • Create example use-case templates
  • Improve rollback granularity
  • Add HITL notification integrations
  • Optimize context summarization strategies

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ‘€ Author

Pabloraka


Built with 🧠 cognitive architecture principles

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors