A cognitive-inspired multi-agent orchestration framework with memory systems, decision engine, self-learning feedback loop, and enterprise-grade safety protocols.
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.
- π§ 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
ββββββββββββββββββββ
β 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]
.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
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 aSKILL.mdβ it's automatically registered!
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) |
New Pattern (score β₯ 7) β Candidate (1-4 uses)
β Proven (5+ uses, < 30% failure)
β Deprecated (failure rate > 30%)
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: trueto skip gates
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)
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
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
The system follows a 6-phase execution pipeline:
Agent registry scan β Checkpoint recovery check
Load user request β Retrieve past cases β Load rules & practices
Classify task β Query registry β Select agents β Assess risk β Calculate context budget
For each agent: HITL gate β Snapshot β Context check β Execute β Checkpoint β Error handling
Score results β Detect issues β Evaluate protocols β Store learnings
Delete checkpoint β Clear artifacts β Clear snapshots
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"
}
}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
- An AI coding assistant that supports
.agents/directory structure (e.g., Gemini, Cursor, etc.)
Option 1: Quick Install (Recommended) Open your project terminal and run:
npx gravity-skill initThis 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- Place the
.agents/directory in your project root. - Your AI assistant will automatically pick up the agent system configuration.
- Invoke the workflow by referencing
/workflowin your AI assistant.
- Create a new folder:
agents/your-agent-name/ - Add a
SKILL.mdwith 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 ---
- The agent registry will auto-discover it on next execution!
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- 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
This project is licensed under the MIT License β see the LICENSE file for details.
Pabloraka
Built with π§ cognitive architecture principles