| name | gam-agentic-memory |
| description | Build structured hierarchical memory systems for LLM agents using GAM (General Agentic Memory) with support for text, video, and agent trajectories |
| triggers | ["how do I create a memory system for my agent","set up GAM for long document processing","build hierarchical memory with general agentic memory","add video memory to my AI agent","use GAM to handle long context","implement agent trajectory compression","query GAM memory with natural language","integrate agentic memory into my workflow"] |
GAM (General Agentic Memory) Skill
Skill by ara.so — AI Agent Skills collection.
GAM is a modular agentic file system framework that provides structured memory and operating environments for Large Language Models. It automatically chunks content, generates memory summaries, and organizes them hierarchically. Supports text documents, long videos, and agent trajectories with access via Python SDK, CLI, REST API, and Web interface.
Installation
pip install -e ".[all]"
pip install -e .
pip install -e ".[video]"
pip install -e ".[api]"
pip install -e ".[web]"
Configuration
GAM uses environment variables for LLM configuration. Set these to avoid passing API keys in code:
export GAM_API_KEY="sk-your-api-key"
export GAM_MODEL="gpt-4o-mini"
export GAM_API_BASE="https://api.openai.com/v1"
export GAM_CHAT_API_KEY="sk-your-chat-api-key"
export GAM_CHAT_MODEL="gpt-4o"
export GAM_CHAT_API_BASE="https://api.openai.com/v1"
Python SDK Usage
Basic Workflow API
The Workflow class is the primary high-level interface:
from gam import Workflow
wf = Workflow(
task_type="text",
gam_dir="./my_gam",
model="gpt-4o-mini",
api_key=None
)
wf.add(input_file="research_paper.pdf")
result = wf.request("What is the main conclusion of this paper?")
print(result.answer)
print(result.context)
Incremental Memory Building
Add new content to existing GAM without rebuilding:
from gam import Workflow
wf = Workflow("text", gam_dir="./knowledge_base")
wf.add(input_file="doc1.pdf")
wf.add(input_file="doc2.pdf")
wf.add(input_file="doc3.txt")
result = wf.request("Summarize the key points from all documents")
Video Memory Workflow
from gam import Workflow
wf = Workflow(
task_type="video",
gam_dir="./video_gam",
model="gpt-4o-mini"
)
wf.add(input_file="lecture.mp4")
result = wf.request("What topics were covered in the first 10 minutes?")
print(result.answer)
Long-Horizon Agent Trajectory
from gam import Workflow
wf = Workflow(
task_type="long-horizon",
gam_dir="./agent_memory",
model="gpt-4o-mini"
)
wf.add(input_file="agent_trace.jsonl")
result = wf.request("What tool was used to solve the math problem?")
Advanced Component Usage
For more control, use individual components:
from gam.text.core import TextGAM
from gam.text.chat import TextChatAgent
gam = TextGAM(
gam_dir="./custom_gam",
model="gpt-4o-mini",
api_key=None,
chunk_size=2000,
max_workers=4
)
gam.add(input_file="document.pdf")
chat_agent = TextChatAgent(
gam_dir="./custom_gam",
model="gpt-4o",
api_key=None,
top_k=10,
rerank=True
)
response = chat_agent.chat("What are the main findings?")
print(response)
CLI Usage
Adding Content to GAM
gam-add --type text --gam-dir ./my_gam --input paper.pdf
gam-add --type text --gam-dir ./my_gam --input paper.pdf --model gpt-4o
gam-add --type video --gam-dir ./video_gam --input lecture.mp4
gam-add --type long-horizon --gam-dir ./agent_gam --input trace.jsonl
Querying GAM
gam-request --type text --gam-dir ./my_gam --question "What is the main conclusion?"
gam-request --type text --gam-dir ./my_gam --question "Explain the methodology" \
--model gpt-4o --top-k 15
gam-request --type video --gam-dir ./video_gam --question "Summarize the lecture"
gam-request --type long-horizon --gam-dir ./agent_gam --question "What actions were taken?"
CLI with Environment Variables
export GAM_API_KEY="sk-your-key"
export GAM_MODEL="gpt-4o-mini"
gam-add --type text --gam-dir ./my_gam --input doc.pdf
gam-request --type text --gam-dir ./my_gam --question "Summary?"
REST API Usage
Starting the API Server
from gam.api import create_app
import uvicorn
app = create_app()
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=5001)
python examples/run_api.py --port 5001
REST API Client Example
import requests
BASE_URL = "http://localhost:5001"
add_response = requests.post(
f"{BASE_URL}/add",
json={
"task_type": "text",
"gam_dir": "./api_gam",
"input_file": "document.pdf",
"model": "gpt-4o-mini"
}
)
print(add_response.json())
query_response = requests.post(
f"{BASE_URL}/request",
json={
"task_type": "text",
"gam_dir": "./api_gam",
"question": "What are the key findings?",
"model": "gpt-4o",
"top_k": 10
}
)
result = query_response.json()
print(result["answer"])
print(result["context"])
REST API Endpoints
POST /add - Add content to GAM
POST /request - Query GAM memory
GET /health - Health check
GET /docs - Interactive API documentation
Web Interface Usage
Starting the Web Platform
from gam.web import app
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
export GAM_MODEL="gpt-4o-mini"
export GAM_API_KEY="sk-your-key"
python examples/run_web.py
python examples/run_web.py --model gpt-4o-mini --api-key sk-your-key --port 5000
Access at http://localhost:5000 for visual GAM management and querying.
Common Patterns
Multi-Document Knowledge Base
from gam import Workflow
kb = Workflow("text", gam_dir="./knowledge_base")
documents = ["finance.pdf", "legal.pdf", "tech.pdf"]
for doc in documents:
kb.add(input_file=doc)
result = kb.request("What are the legal implications mentioned in any document?")
Video Analysis Pipeline
from gam import Workflow
wf = Workflow("video", gam_dir="./lectures")
wf.add(input_file="lecture1.mp4")
wf.add(input_file="lecture2.mp4")
topics = wf.request("What are all the topics covered?")
timeline = wf.request("When was machine learning discussed?")
Agent Memory with Search/Recall
from gam import Workflow
agent_mem = Workflow("long-horizon", gam_dir="./agent_traces")
agent_mem.add(input_file="execution_log.jsonl")
result = agent_mem.request("What was the sequence of tool calls for solving the problem?")
patterns = agent_mem.request("How many times did the agent retry failed operations?")
Custom Memory Configuration
from gam.text.core import TextGAM
from gam.text.chat import TextChatAgent
gam = TextGAM(
gam_dir="./optimized_gam",
model="gpt-4o-mini",
chunk_size=3000,
max_workers=8,
embedding_model="text-embedding-3-large"
)
gam.add(input_file="large_corpus.txt")
chat = TextChatAgent(
gam_dir="./optimized_gam",
model="gpt-4o",
top_k=20,
rerank=True,
temperature=0.0
)
response = chat.chat("Find all mentions of quantum computing")
Docker Workspace Support
from gam import Workflow
wf = Workflow(
task_type="text",
gam_dir="/workspace/gam",
model="gpt-4o-mini"
)
wf.add(input_file="/workspace/data/document.pdf")
result = wf.request("Summarize the document")
Troubleshooting
API Key Issues
If you get authentication errors:
import os
print(os.getenv("GAM_API_KEY"))
print(os.getenv("GAM_MODEL"))
wf = Workflow("text", gam_dir="./gam", model="gpt-4o-mini", api_key="sk-your-key")
Missing Dependencies
pip install -e ".[video]"
pip install -e ".[api]"
pip install -e ".[web]"
pip install -e ".[all]"
Memory Not Found
import os
gam_dir = "./my_gam"
if not os.path.exists(gam_dir):
print("GAM directory not found. Run add() first.")
if not os.path.exists(f"{gam_dir}/chunks"):
print("No chunks found. GAM may be empty.")
Slow Performance
from gam.text.core import TextGAM
gam = TextGAM(
gam_dir="./gam",
max_workers=16,
chunk_size=2500
)
gam = TextGAM(gam_dir="./gam", model="gpt-4o-mini")
from gam.text.chat import TextChatAgent
chat = TextChatAgent(gam_dir="./gam", model="gpt-4o")
Model Configuration
from gam import Workflow
wf = Workflow("text", gam_dir="./gam", model="gpt-4o-mini")
wf.add(input_file="doc.pdf")
from gam.text.chat import TextChatAgent
chat = TextChatAgent(gam_dir="./gam", model="gpt-4o")
response = chat.chat("Complex analytical question?")
Directory Structure
After building a GAM, the structure looks like:
./my_gam/
├── chunks/ # Segmented content chunks
├── memories/ # Generated memory summaries
├── taxonomy/ # Hierarchical organization
├── embeddings/ # Vector embeddings for retrieval
└── metadata.json # GAM configuration
Research Codebase
For academic research and benchmarking:
cd research
pip install -e .
from gam_research import MemoryAgent, ResearchAgent
memorizer = MemoryAgent(gam_dir="./research_gam")
researcher = ResearchAgent(gam_dir="./research_gam")
Key Concepts
- GAM Directory: File system location where memory is stored
- Chunks: Semantically segmented pieces of content
- Memories: LLM-generated summaries with TLDR for each chunk
- Taxonomy: Hierarchical directory structure organizing memories
- Workflow: High-level API combining add and request operations
- Incremental Addition: Add new content without rebuilding existing memory