Skip to content

feat: integrate SAGE persistent memory for cross-session knowledge#253

Open
l33tdawg wants to merge 1 commit intovxcontrol:mainfrom
l33tdawg:feat/sage-integration
Open

feat: integrate SAGE persistent memory for cross-session knowledge#253
l33tdawg wants to merge 1 commit intovxcontrol:mainfrom
l33tdawg:feat/sage-integration

Conversation

@l33tdawg
Copy link
Copy Markdown

Summary

Adds SAGE (Sovereign Agent Governed Experience) as an optional persistent memory layer for cross-session knowledge retention. SAGE memories go through BFT consensus, have confidence scores, and decay over time — giving PentAGI agents institutional knowledge that survives between engagements.

  • SAGE client (pkg/sage/client.go) — Ed25519-authenticated HTTP client with persistent keypair identity
  • SAGE tools (sage_recall, sage_remember) — registered in pentester, coder, memorist, and enricher executors
  • Agent prompt awareness — conditional SAGE instructions in prompt templates (follows existing Graphiti pattern)
  • Docker Compose sidecar (docker-compose-sage.yml) — SAGE node + Ollama for semantic embeddings
  • ConfigurationSAGE_ENABLED, SAGE_URL, SAGE_KEY_PATH, SAGE_BOT_NAME, SAGE_TIMEOUT

How it works

When enabled, agents:

  1. Recall from SAGE at the start of tasks — checking for known vulnerabilities, techniques, and patterns from previous engagements
  2. Store significant findings after discovery — SQLi payloads, credential dumps, successful techniques
  3. Build institutional knowledge — each engagement makes future ones more effective

Test results

Tested against OWASP Juice Shop. SAGE-enhanced run completed 8/8 subtasks covering 7 vulnerability classes (recon, SQLi, XSS search, XSS reviews, JWT manipulation, IDOR, path traversal). Agents actively recalled from SAGE before testing and stored findings back — 44 SAGE-related messages observed during the run.

Key behavioral improvements with SAGE enabled:

  • Agents check SAGE for prior knowledge before starting each phase
  • Known endpoints were targeted immediately instead of discovered through blind enumeration
  • Previously untested vectors (JWT, IDOR, path traversal) were prioritized based on SAGE-seeded context
  • A dedicated "Store All Findings in SAGE" subtask was auto-created by the agent

Unit tests: 32/32 passing across client, tools, templates, and config packages.

Usage

```bash

Start with SAGE sidecar

docker compose -f docker-compose.yml -f docker-compose-sage.yml up -d

Enable in .env

SAGE_ENABLED=true
SAGE_URL=http://sage:8080
SAGE_BOT_NAME=pentagi
```

Files changed

29 files, +2042 lines. Zero changes to core orchestration — SAGE is fully optional and follows the existing Graphiti integration pattern.

Test plan

  • `go build ./...` — clean
  • `go vet ./...` — clean
  • Unit tests: 32/32 SAGE tests passing (client, tools, templates, config)
  • Integration tests: client health, embed, remember+recall round-trip
  • E2E: full pentest against Juice Shop with SAGE-enhanced agents
  • Reviewer runs `docker compose -f docker-compose.yml -f docker-compose-sage.yml up -d` and verifies SAGE tools appear in agent tool list

Add SAGE (Sovereign Agent Governed Experience) as an optional persistent
memory layer for cross-session knowledge retention. SAGE memories go
through BFT consensus, have confidence scores, and decay over time.

Components:
- pkg/sage/client.go: Ed25519-authenticated HTTP client with persistent keypair
- pkg/tools/sage_search.go: sage_recall and sage_remember tool implementations
- Agent prompt templates: conditional SAGE instructions for pentester, coder,
  memorist, and enricher agents (follows existing Graphiti pattern)
- docker-compose-sage.yml: composable SAGE + Ollama sidecar for embeddings
- Config: SAGE_ENABLED, SAGE_URL, SAGE_KEY_PATH, SAGE_BOT_NAME, SAGE_TIMEOUT

Tests: 32 new tests across client, tools, templates, and config packages.

Tested against OWASP Juice Shop: SAGE-enhanced run completed 8/8 subtasks
covering 7 vulnerability classes with 44 SAGE-related agent messages.
@asdek
Copy link
Copy Markdown
Contributor

asdek commented Apr 11, 2026

hey @l33tdawg

it looks quite interesting, give us some time to test your product and this integration

@l33tdawg
Copy link
Copy Markdown
Author

No worries mate - let me know if you guys have any questions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants