Agentic Memory Plugin
The Agentic Memory Plugin automatically stores agent responses as organizational knowledge in the background without blocking the main agent workflow. This plugin leverages the AgenticMemoryStoreTool to create a comprehensive knowledge base from conversational interactions.
Overview
This plugin:
- Hooks into agent responses: Listens to the
onResponsePersistevent - Runs in background: Spawns asynchronous tasks that don't block the main agent
- Stores memories automatically: Uses
AgenticMemoryStoreToolto classify and persist knowledge - Logs results: Provides visibility into memory storage success/failure
- Graceful failure handling: Continues operation even if memory storage fails
Configuration
Basic Configuration
Add the following to your codumentor.yaml configuration file:
# Configure the plugin in the plugins section
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
priority: 90 # Run after most plugins but before final persistence
args:
enabled: true
repo_name: "your-knowledge-repo" # Repository to store memories
kb_base_dir: "knowledge" # Directory within repo for knowledge
facets_hint: # Default classification hints
environment: "production"
audience: "team"
Advanced Configuration
All plugin configuration is done through the args section:
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
priority: 90
args:
enabled: true
repo_name: "custom-repo"
kb_base_dir: "custom-knowledge"
retrieval_cue_char_limit: 800 # Max characters from each cue (default 1000)
facets_hint:
type: "conversation"
sensitivity: "internal"
environment: "development"
Configuration Options
All configuration is done through the plugin args section:
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable the agentic memory plugin |
repo_name | string | null | Repository for storing memories (required) |
kb_base_dir | string | "knowledge" | Base directory within repo for knowledge storage |
facets_hint | object | {} | Default facet hints for classification |
retrieval_cue_char_limit | integer | 1000 | Max characters to include from each retrieved cue |
storage_max_iterations | integer | null | Maximum iterations for the memory storage subagent. If not set, uses global agent.max_iterations |
commit_enabled | boolean | true | When false, the storage subagent only writes KB files — no git add / git commit step. Set to false for non-git workspaces (e.g. the scaffolded marketing sample project) so storage doesn't fail on missing .git. When false, push_enabled is implicitly a no-op. |
push_enabled | boolean | true | Push to git remote after committing stored memories. Ignored when commit_enabled is false. On a non-fast-forward failure (another writer pushed first), the plugin automatically runs git pull --rebase --autostash and retries the push once. |
push_timeout | integer | 30 | Seconds to wait for git push (and the recovery git pull --rebase) before timing out (handles credential prompts) |
push_max_consecutive_failures | integer | 5 | Suspend push after this many consecutive failures (counted per push attempt — pull + retry is one attempt; resets on server restart) |
How It Works
Event Flow
- Agent completes response: Main agent finishes generating a response
- onResponsePersist triggered: Plugin receives the response text
- Background task created: Plugin spawns async task without blocking
- Memory tool execution:
AgenticMemoryStoreToolclassifies and stores the response - Result logging: Success/failure is logged for monitoring
Background Execution
The plugin uses Python's asyncio.create_task() to run memory storage in the background:
# Create background task (non-blocking)
task = asyncio.create_task(
self._store_memory_background(assistant_text, session_id, run_id)
)
# Track task for cleanup but don't await
self._background_tasks.add(task)
This ensures the main agent can continue immediately while memories are processed asynchronously.
Memory Classification
The plugin leverages the existing AgenticMemoryStoreTool which:
- Analyzes response content for organizational value
- Classifies knowledge using configurable facets
- Stores as structured Markdown with YAML front matter
- Handles deduplication and updates of existing knowledge
- Automatically detects and stores Rapid Direction Cues (RDCs): Small, actionable hints like naming conventions, historical renamings, and component locations that help future agents navigate efficiently
Repository Setup
Before using the plugin, ensure you have a repository configured for knowledge storage:
- Create or clone a repository: ```bash # Create new repo mkdir my-knowledge-repo cd my-knowledge-repo git init
# Or clone existing repo
git clone https://github.com/yourorg/knowledge-repo.git
```
- Add repository to configuration: ``
yaml repos: - "my-knowledge-repo" repos_dir: "repos" # Directory containing repositories``
- Create knowledge directory structure: ``
bash mkdir -p knowledge echo "# Knowledge Base" > knowledge/README.md git add . && git commit -m "Initialize knowledge base"``
Monitoring and Logging
Log Levels
The plugin logs at different levels:
- INFO: Plugin initialization, registration, successful storage
- DEBUG: Background task creation, detailed execution flow
- WARNING: Storage failures, missing configuration
- ERROR: Unexpected exceptions with full stack traces
Log Categories
Configure specific logging for the plugin:
logging:
logger_levels:
"codumentor.plugins.agentic_memory": "DEBUG"
Example Log Output
INFO - AgenticMemoryPlugin initialized (enabled=True, repo=my-repo)
INFO - AgenticMemoryPlugin registered for onResponsePersist hook
DEBUG - AgenticMemoryPlugin: Triggering background memory storage for session abc123
DEBUG - AgenticMemoryPlugin: Background task created for run xyz789
INFO - AgenticMemoryPlugin: Successfully stored memory for run xyz789
Error Handling
The plugin is designed to fail gracefully:
Repository Not Found
WARNING - AgenticMemoryPlugin: Failed to store memory for run xyz: Repository 'missing-repo' not found
Tool Execution Failure
ERROR - AgenticMemoryPlugin: Background memory storage failed for run xyz: [detailed error]
Configuration Issues
WARNING - AgenticMemoryPlugin: No config provided, cannot register handlers
Performance Considerations
Background Execution
- Memory storage runs asynchronously and doesn't block the main agent
- Multiple memory storage tasks can run concurrently
- Tasks are tracked and can be cleaned up if needed
Resource Usage
- Each background task uses minimal CPU/memory
- Git operations (if enabled) may cause brief I/O spikes
- Network calls to LLM for classification happen in background
Cleanup
The plugin automatically cleans up completed background tasks and provides a cleanup() method for graceful shutdown.
Git Repository Tuning for Large Knowledge Bases
Optional: The Agentic Memory Plugin works without any Git tuning. This section is for long-running deployments where the knowledge base accumulates a large number of commits over time. If you experience slowing Git operations, the recommendations below can help maintain performance.
When Tuning May Be Needed
Consider Git tuning if you observe any of the following:
git status,git log, orgit commitin the knowledge base repo becoming noticeably slow- Clone times increasing as history grows
- Repository maintenance (
git gc) taking longer than expected - The knowledge base has thousands to millions of commits from continuous agent activity
What Affects Git Performance
Git performance depends on the combination of:
- Number of commits — deep history impacts history queries more than new commits
- Number of files in the working tree — tens of thousands is fine; hundreds of thousands may need tuning
- Directory layout — flat directories with many entries are slower than sharded subdirectories
- Number of branches/tags/refs — many refs slow down graph walks
- Git maintenance — repositories without regular maintenance degrade over time
Recommended Git Configuration
For knowledge base repositories with extensive history, enable these Git features:
cd /path/to/your-knowledge-repo
# Enable commit-graph for faster history operations
git config core.commitGraph true
git config gc.writeCommitGraph true
git config fetch.writeCommitGraph true
# Enable changed-path Bloom filters for faster path-specific queries
git config commitGraph.changedPaths true
# Enable incremental maintenance strategy
git config maintenance.strategy incremental
| Setting | Purpose |
|---|---|
core.commitGraph | Stores commit graph structure to speed up graph walks |
gc.writeCommitGraph | Automatically writes commit-graph during garbage collection |
fetch.writeCommitGraph | Updates commit-graph after fetching |
commitGraph.changedPaths | Bloom filters for path-specific history queries |
maintenance.strategy | Runs incremental maintenance automatically |
Periodic Maintenance Commands
Run these commands periodically to keep the repository healthy:
# Start automatic background maintenance (recommended)
git maintenance start
# Or run manually when needed
git maintenance run
git gc
git commit-graph write --reachable --changed-paths
Directory Layout
The plugin stores knowledge files in subdirectories under kb_base_dir (e.g., knowledge/cues/, knowledge/conventions/). This sharded layout is already optimal for Git performance. Avoid placing thousands of files in a single flat directory.
Clone Strategies for CI and Developers
For systems that do not need full history, use lightweight clone strategies:
# Shallow clone for CI pipelines (recommended)
git clone --depth=1 <repository-url>
# Partial clone for developers (lazy-loads historical blobs on demand)
git clone --filter=blob:none <repository-url>
Monitoring Repository Health
Use git-sizer to assess repository characteristics and identify potential issues:
git-sizer --verbose
This helps you understand clone size, object counts, and maintenance requirements before they become problems.
Integration Examples
Basic Setup
# Minimal configuration
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
args:
enabled: true
repo_name: "team-knowledge"
Team Environment
# Team-focused configuration
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
priority: 80
args:
enabled: true
repo_name: "team-knowledge-base"
kb_base_dir: "conversations"
storage_max_iterations: 15 # Limit memory storage subagent to 15 iterations
facets_hint:
audience: "team"
environment: "production"
owner: "engineering"
Development Environment
# Development configuration with detailed logging
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
args:
enabled: true
repo_name: "dev-knowledge"
facets_hint:
environment: "development"
logging:
logger_levels:
"codumentor.plugins.agentic_memory": "DEBUG"
Troubleshooting
Plugin Not Working
- Check configuration: Ensure
enabled: trueinmemory_storesection - Verify repository: Confirm repository exists and is accessible
- Check logs: Look for plugin registration and execution messages
- Test manually: Try running
AgenticMemoryStoreTooldirectly
Background Tasks Not Running
- Check event hooks: Verify
onResponsePersistis being triggered - Monitor background tasks: Look for task creation in DEBUG logs
- Asyncio issues: Ensure proper async/await usage in your environment
Memory Storage Failures
- Repository access: Verify git repository is writable
- Tool configuration: Check
AgenticMemoryStoreToolrequirements - LLM availability: Ensure models are accessible for classification
API Reference
AgenticMemoryPlugin
Constructor
AgenticMemoryPlugin(config: Optional[Config] = None, **kwargs)
Methods
meta(property): Returns plugin metadataregister(bus): Registers event handlerscapabilities(): Returns plugin capabilitiescleanup(): Cleans up background tasks
Configuration Parameters
enabled: Enable/disable pluginrepo_name: Target repository namekb_base_dir: Knowledge base directoryfacets_hint: Default classification hintscommit_enabled: Whether the storage subagent shouldgit commitits writes (defaulttrue). Disable for non-git workspaces such as the marketing sample project.push_enabled: Whether togit pushafter committing (defaulttrue; no-op whencommit_enabledisfalse)
Memory Retrieval
The Agentic Memory Plugin includes automatic retrieval of relevant knowledge from the knowledge base to enhance agent responses. This feature provides "Rapid Direction Cues" that give context without overwhelming the conversation.
How Retrieval Works
- Query Extraction: Uses the latest user message content directly as the search query
- Vector Search: Searches the knowledge base semantically using the raw user query
- Repository Filtering: Results are filtered to the configured repository for relevance
- Cue Formatting: Top results are formatted as concise cues with file paths and content previews
- Context Injection: Cues are injected as system messages before the user query
Retrieval Configuration
Add retrieval settings to the plugin configuration:
plugins:
- module: "codumentor.plugins.agenticmemory"
class: "AgenticMemoryPlugin"
args:
enabled: true
repo_name: "your-knowledge-repo"
retrieval_enabled: true # Enable retrieval (default: true)
retrieval_num_results: 3 # Number of cues to retrieve (default: 3)
Retrieval Parameters
| Option | Type | Default | Description |
|---|---|---|---|
retrieval_enabled | boolean | true | Enable/disable memory retrieval |
retrieval_num_results | integer | 3 | Number of rapid direction cues to retrieve |
Rapid Direction Cues (RDCs)
Rapid Direction Cues are small, actionable hints that help agents navigate the codebase efficiently. The plugin automatically detects and stores RDCs from:
- User corrections or clarifications (e.g., "Actually, that component was renamed to X")
- Historical context provided by users
- Assistant responses when auto-correcting or providing navigation hints
RDC Examples:
- Naming conventions: "The API uses snake_case for endpoints but camelCase in responses"
- Historical renamings: "UserManager was renamed to AccountService in v2.0"
- Component locations: "Authentication logic is in auth-service, not user-service"
- Non-obvious patterns: "Test files use .spec.ts suffix, not .test.ts"
Each RDC is stored in its own minimal file with:
- Type:
rapid_direction_cue - Tag: "Rapid Direction Cue"
- Ultra-brief body: 2-4 lines maximum
- Stored in:
knowledge/cues/directory
Retrieved RDCs Format:
Rapid Direction Cues (Results of a quick kb search, use only the relevant ones, if any):
relative/path/to/file1.py:
Content preview (first 500 chars)...
relative/path/to/file2.md:
Another content preview...
Example Retrieval Flow
- User Query: "How do I implement user authentication?"
- Retrieval Search: Plugin searches knowledge base for "user authentication"
- Results Found: Returns relevant docs about auth patterns, security, etc.
- Context Injection: Cues added before user message:
System: Rapid Direction Cues (Results of a quick kb search, use only the relevant ones, if any):
auth/auth_service.py:
Implements JWT token validation and user session management...
security/oauth_config.md:
OAuth2 configuration for third-party authentication providers...
- Enhanced Response: Agent now has contextual knowledge for more accurate answers
Retrieval Benefits
- Context Awareness: Agent gets relevant background knowledge automatically
- Efficiency: Reduces need for explicit knowledge searches during conversation
- Relevance: Repository filtering keeps cues focused on current project
- Non-Intrusive: Cues are concise and marked as optional reference
Retrieval Limitations
- Not Comprehensive: Vector search finds semantic matches, not exhaustive results
- Repository Scoped: Only searches within configured repository
- Preview Only: Shows first 500 characters of content
- Background Operation: Retrieval failures don't break conversation flow
Web UI Integration
The Agentic Memory Plugin includes a custom UI component that renders memory events in the web interface.
UI Events
The plugin emits the following events to the web UI:
| Event Type | Status | Description |
|---|---|---|
plugin.agentic_memory.storage_started | pending | Memory storage has begun |
plugin.agentic_memory.stored | success | Memory was stored successfully |
plugin.agentic_memory.storage_failed | error | Memory storage failed |
plugin.agentic_memory.retrieved | success | Memory was retrieved (future) |
Event Grouping
The agentic memory plugin uses event grouping to correlate related events into a single UI card. All events in a storage operation share the same event_group_id, causing them to update a single card rather than creating multiple cards.
Event Data Fields:
All events include explicit status and event_group_id in their data payload:
await emit_ui_event("plugin.agentic_memory.storage_started", {
"status": "pending", # Required: explicit status
"event_group_id": run_id, # Correlation key for grouping
"text_length": len(assistant_text),
"repo_name": self.repo_name,
})
await emit_ui_event("plugin.agentic_memory.stored", {
"status": "success", # Required: explicit status
"event_group_id": run_id, # Same key updates existing card
"success": True,
"reasoning": reasoning,
"stored_items": stored_items,
"summary": summary,
})
See Event Grouping in the UI documentation for more details.
Custom Element
The plugin provides a custom web component <x-agentic-memory-card> that renders with:
- Status-specific icons (💭 pending, 🧠 stored, ⚠️ failed)
- Color-coded borders (blue/green/red)
- Repository name badge
- Summary or error message
See ui/plugins/agentic_memory/index.js for the full implementation.
Enabling the UI
The plugin's UI is enabled by default. To disable:
ui:
disabled_extensions:
- agentic_memory
When the UI is disabled, events still appear in the transcript using the generic fallback renderer.
Memory Feedback Review
The Agentic Memory Plugin includes a feedback review system that allows users and administrators to manage memory quality based on user feedback from the RDC review cards.
Overview
When users vote on retrieved RDCs (using the thumbs up/down buttons), they can mark memories as:
- Unhelpful (
is_generally_bad=true): The memory content is generally not useful - Review Requested (
request_review=true): The user wants a human to review this memory
These feedback entries can be reviewed and acted upon through the Memory Feedback Review page.
Permission Model
The review system supports two access levels:
| Permission | Access Level | Capabilities |
|---|---|---|
memory_feedback:review | Admin | View all feedback, delete memory files, ignore feedback |
| (authenticated) | User | View own reports, edit/delete own reports |
Users without the memory_feedback:review permission automatically see their own submitted reports instead.
Welcome Page Widget
The plugin provides a welcome page widget that displays:
- Count of memories marked as "unhelpful"
- Count of memories marked for "human review"
- A "Review Feedback" button that navigates to the full review page
The widget automatically refreshes every 60 seconds to show current counts.
Review Page
The full review page is accessible at /plugins/agentic_memory/review and provides different views based on permissions:
Admin View (with memory_feedback:review permission):
For each feedback entry:
- File path of the memory (with tooltip showing full path)
- Tags indicating: "Unhelpful" and/or "Review Requested"
- User who submitted the feedback (display name or username)
- User's feedback reason (if provided)
- The search query that triggered the RDC retrieval
- Full content of the memory file (expandable)
- Timestamp of when feedback was submitted
Available actions:
- Delete Memory: Permanently removes the memory file from the knowledge base
- Ignore Feedback: Hides this feedback entry from future listings (memory file remains unchanged)
User View (own reports only):
For each of the user's own reports:
- Same information as admin view
- Available actions:
- Edit Report: Update the reason, is_generally_bad, or request_review flags
- Delete Report: Remove the user's own feedback (memory file remains unchanged)
API Endpoints
The feedback review system provides the following API endpoints:
Admin Endpoints (require memory_feedback:review permission):
| Endpoint | Method | Description |
|---|---|---|
/votes/review-summary | GET | Get counts for the welcome widget |
/votes/feedback-entries | GET | Get all feedback entries for review |
/votes/pending-reviews | GET | Get all RDCs pending review (grouped by file) |
/votes/pending-reviews/summary | GET | Lightweight summary for welcome widget |
/votes/{vote_id}/ignore | POST | Mark a feedback entry as ignored |
/memory/{file_path} | DELETE | Permanently delete a memory file |
User Endpoints (authenticated users, own reports only):
| Endpoint | Method | Description |
|---|---|---|
/votes/my-reports-summary | GET | Get counts for user's own reports |
/votes/my-reports | GET | Get user's own feedback entries |
/votes/report/{vote_id} | PUT | Update user's own report |
/votes/report/{vote_id} | DELETE | Delete user's own report |
Review Summary Response
{
"unhelpful_count": 3,
"review_requested_count": 5,
"total_feedback_count": 7,
"own_reports_only": false
}
The own_reports_only field indicates whether the counts are filtered to the current user's reports only (true for /votes/my-reports-summary).
Feedback Entry Response
{
"entries": [
{
"vote_id": "abc123",
"conversation_id": "conv456",
"event_id": "evt789",
"rdc_file_path": "my-repo/knowledge/cues/naming-history.md",
"vote_type": "dislike",
"reason": "This information is outdated",
"is_generally_bad": true,
"request_review": false,
"created_at": "2024-01-15T10:30:00Z",
"ignored": false,
"user_id": "user-uuid-123",
"user_display_name": "Jane Developer",
"rdc_content": "---\ntitle: Naming History\n---\n\nContent of the memory file...",
"query": "What is the billing module called?"
}
],
"own_reports_only": false
}
Response fields:
| Field | Description |
|---|---|
vote_id | Unique identifier for the vote |
conversation_id | ID of the conversation where feedback was given |
event_id | Plugin event ID containing the RDC |
rdc_file_path | Path to the memory file (may include repo name prefix) |
vote_type | Always "dislike" for feedback entries |
reason | User's explanation for the feedback |
is_generally_bad | Whether the memory is generally unhelpful (not just context-specific) |
request_review | Whether the user requested human review |
created_at | ISO timestamp of when feedback was submitted |
ignored | Whether this entry has been ignored by an admin |
user_id | UUID of the user who submitted the feedback |
user_display_name | Human-readable name of the user (if available) |
rdc_content | Full content of the memory file (for review) |
query | The search query that retrieved this RDC |
own_reports_only | (on response) Whether results are filtered to user's own reports |
Update Report Request
{
"reason": "Updated reason for feedback",
"is_generally_bad": true,
"request_review": false
}
All fields are optional; only provided fields are updated.
Delete Memory Behavior
When a memory file is deleted:
- The file is permanently removed from the knowledge base directory
- The deletion is committed to git
- All associated votes/feedback for that file are also deleted
- The feedback entry is removed from the review list
Security: The delete endpoint validates that the file path is within an allowed knowledge base directory to prevent directory traversal attacks.
Ignore Feedback Behavior
When feedback is ignored:
- The feedback entry is marked with
ignored=truein the database - The entry no longer appears in future review listings
- The memory file remains unchanged
- Counts in the welcome widget exclude ignored entries
Use "Ignore Feedback" when:
- The feedback was a mistake
- You've reviewed the memory and decided it should remain
- The issue has been addressed in another way
Configuration
The feedback review feature is enabled by default when the Agentic Memory plugin is active. No additional configuration is required.
To grant admin review access, assign the memory_feedback:review permission to users or roles in your RBAC configuration.
Workflow Examples
Admin Workflow:
- User provides feedback: During a conversation, user clicks thumbs down on an RDC and checks "This memory is generally unhelpful"
- Feedback recorded: The vote is stored with
is_generally_bad=true - Widget shows count: Welcome page widget shows "1 unhelpful"
- Admin reviews: Admin clicks "Review Feedback" to open the review page
- Context visible: Admin sees the search query, user name, and full memory content
- Action taken: Admin either: - Clicks "Delete Memory" to remove the file permanently - Clicks "Ignore Feedback" if the memory should remain
- Widget updates: Count decreases after action is taken
User Self-Service Workflow:
- User submits feedback: User marks an RDC as unhelpful with a reason
- User reviews own reports: User opens the review page (sees only their own reports)
- User can edit: If the reason was incomplete, user clicks "Edit Report" to update
- User can retract: If feedback was a mistake, user clicks "Delete Report"