[PR #250] [CLOSED] feat: integrate SAGE persistent memory for cross-session knowledge #271

Closed
opened 2026-06-06 22:09:59 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/250
Author: @l33tdawg
Created: 4/10/2026
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • a31ce95 feat: integrate SAGE persistent memory system
  • 1ec2e84 test: add comprehensive SAGE integration tests

📊 Changes

29 files changed (+2042 additions, -1 deletions)

View changed files

📝 .env.example (+10 -0)
📝 backend/cmd/ftester/mocks/tools.go (+33 -0)
📝 backend/cmd/ftester/worker/args.go (+2 -0)
📝 backend/cmd/ftester/worker/executor.go (+12 -0)
📝 backend/cmd/ftester/worker/tester.go (+2 -0)
📝 backend/pkg/config/config.go (+8 -0)
📝 backend/pkg/config/config_test.go (+53 -0)
📝 backend/pkg/controller/assistant.go (+1 -0)
📝 backend/pkg/controller/flow.go (+2 -0)
📝 backend/pkg/providers/handlers.go (+10 -0)
📝 backend/pkg/providers/provider.go (+2 -0)
📝 backend/pkg/providers/providers.go (+25 -0)
backend/pkg/sage/client.go (+399 -0)
backend/pkg/sage/client_test.go (+552 -0)
📝 backend/pkg/templates/prompts/coder.tmpl (+19 -0)
📝 backend/pkg/templates/prompts/enricher.tmpl (+17 -0)
📝 backend/pkg/templates/prompts/memorist.tmpl (+22 -0)
📝 backend/pkg/templates/prompts/pentester.tmpl (+20 -0)
backend/pkg/templates/sage_test.go (+153 -0)
📝 backend/pkg/templates/templates.go (+10 -0)

...and 9 more files

📄 Description

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

# 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

30 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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/250 **Author:** [@l33tdawg](https://github.com/l33tdawg) **Created:** 4/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`a31ce95`](https://github.com/vxcontrol/pentagi/commit/a31ce9524bfecf07c618345635623ae942f810c7) feat: integrate SAGE persistent memory system - [`1ec2e84`](https://github.com/vxcontrol/pentagi/commit/1ec2e84349d92c62fc8a24f99359bdbf9c0d384a) test: add comprehensive SAGE integration tests ### 📊 Changes **29 files changed** (+2042 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+10 -0) 📝 `backend/cmd/ftester/mocks/tools.go` (+33 -0) 📝 `backend/cmd/ftester/worker/args.go` (+2 -0) 📝 `backend/cmd/ftester/worker/executor.go` (+12 -0) 📝 `backend/cmd/ftester/worker/tester.go` (+2 -0) 📝 `backend/pkg/config/config.go` (+8 -0) 📝 `backend/pkg/config/config_test.go` (+53 -0) 📝 `backend/pkg/controller/assistant.go` (+1 -0) 📝 `backend/pkg/controller/flow.go` (+2 -0) 📝 `backend/pkg/providers/handlers.go` (+10 -0) 📝 `backend/pkg/providers/provider.go` (+2 -0) 📝 `backend/pkg/providers/providers.go` (+25 -0) ➕ `backend/pkg/sage/client.go` (+399 -0) ➕ `backend/pkg/sage/client_test.go` (+552 -0) 📝 `backend/pkg/templates/prompts/coder.tmpl` (+19 -0) 📝 `backend/pkg/templates/prompts/enricher.tmpl` (+17 -0) 📝 `backend/pkg/templates/prompts/memorist.tmpl` (+22 -0) 📝 `backend/pkg/templates/prompts/pentester.tmpl` (+20 -0) ➕ `backend/pkg/templates/sage_test.go` (+153 -0) 📝 `backend/pkg/templates/templates.go` (+10 -0) _...and 9 more files_ </details> ### 📄 Description ## Summary Adds [SAGE](https://github.com/l33tdawg/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 - **Configuration** — `SAGE_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 30 files, +2042 lines. Zero changes to core orchestration — SAGE is fully optional and follows the existing Graphiti integration pattern. ## Test plan - [x] `go build ./...` — clean - [x] `go vet ./...` — clean - [x] Unit tests: 32/32 SAGE tests passing (client, tools, templates, config) - [x] Integration tests: client health, embed, remember+recall round-trip - [x] 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:59 -04:00
yindo closed this issue 2026-06-06 22:09:59 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#271