XysqAgent— a turn-based wrapper that handles memory retrieval and capture automatically on everychat()call- Tool calling integrations — expose xysq operations as LLM tools (function-calling), letting the model decide when to capture and recall
XysqAgent
XysqAgent wraps any LiteLLM-compatible model. On every chat() call it:
- Runs the configured context strategy to fetch relevant memories
- Injects retrieved context into the system prompt
- Calls the LLM
- Optionally captures the exchange
XysqAgent in a new session will have access to everything captured by previous sessions.
Context strategies
A context strategy controls what memory context is injected into each turn’s system prompt.| Strategy | Behaviour |
|---|---|
"surface" | Retrieves raw memory items relevant to the current message |
"synthesize" | Runs a synthesis query and injects the answer |
"both" | Runs both and injects both |
"none" | No automatic context injection |
| Custom callable | Any object matching the ContextStrategy protocol |
Custom strategy
Implement theContextStrategy protocol — any callable with this signature:
XysqAgent parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
client | Xysq | required | Sync xysq client |
model | str | required | LiteLLM model string (e.g. "gpt-4o-mini", "claude-sonnet-4-20250514") |
api_key | str | None | LLM provider API key |
system_prompt | str | default | Base system prompt |
context_strategy | str | callable | "surface" | Context injection strategy |
capture_strategy | str | "auto" | "auto" | "manual" | "both" | "none" |
surface_budget | str | "mid" | Budget for surface/synthesize calls |
team_id | str | None | Scope memory operations to a team vault |
Tool calling integrations
Tool calling lets the LLM decide when to invoke memory operations — you pass the tool definitions to your LLM call, execute any tool calls the model returns, and feed results back.LiteLLM
Anthropic
Available tools
Both integrations expose the same seven tools to the LLM:| Tool name | Operation |
|---|---|
xysq_capture | Store a memory |
xysq_surface | Retrieve relevant memories |
xysq_synthesize | Ask a question from memory |
xysq_list_memories | List recent memories |
xysq_delete_memory | Delete a memory by ID |
xysq_add_knowledge | Add a knowledge source |
xysq_list_knowledge | List knowledge sources |
Examples
| File | What it demonstrates |
|---|---|
02_chatbot_with_memory.py | Multi-turn chatbot with LiteLLM and memory injection |
05_agent_with_tools.py | LLM-driven tool-calling loop |
06_xysq_agent.py | XysqAgent with surface, synthesize, and custom strategies |
Related
Memory operations
Full reference for capture, surface, and synthesize
Team Vaults
Scope agent memory to a shared team vault