ShadAI Framework
  1. guides
ShadAI Framework
  • Index
  • README
  • Pricing
    • Pricing Plan
  • advanced
    • Best Practices
    • Tool Orchestration
    • Performance Optimization
    • Custom Tools
  • examples
    • Advanced Patterns
    • Custom Agent Examples
    • Market Research Examples
    • Multi-Document Analysis
    • Basic Query Examples
  • api-reference
    • Exceptions Reference
    • Engine Tool API
    • Shadai Client API Reference
    • Query Tool API
    • Summarize Tool API
    • Agent Tool API
    • Web Search Tool API
  • use-cases
    • Knowledge Synthesis
    • Research Assistant
    • Custom Workflows
    • Document Q&A
  • core-concepts
    • Architecture
    • Intelligent Agent
    • RAG System
    • Tools Overview
  • guides
    • Memory & Context
    • Streaming Responses
    • File Ingestion
    • Error Handling
    • Session Management
  • getting-started
    • Authentication
    • Your First Query
    • Quick Start
    • Installation
  1. guides

Memory & Context

Shadai's memory system enables natural, context-aware conversations. This guide explains how memory works and how to control it effectively.

What is Memory?#

Memory allows Shadai to remember previous interactions within a session, enabling:
🔗 Follow-up questions without repeating context
💬 Natural conversations that flow logically
🧠 Context accumulation over multiple interactions
🎯 More accurate answers based on conversation history

Memory is Enabled by Default#

As of v0.1.29, all tools use memory by default:

How Memory Works#

Message Storage#

Every interaction is stored:
Behind the scenes:
1.
User question → Stored as "user" message
2.
AI answer → Stored as "assistant" message
3.
Next query → Retrieves recent messages for context
4.
Continues building conversation thread

Context Window#

Shadai maintains a sliding window of recent messages:
Recent messages have more influence on responses.

Controlling Memory#

Enable Memory (Default)#

Disable Memory#

Useful for independent queries:
When to disable memory:
Completely independent queries
Testing specific prompts
Avoiding context pollution
Privacy-sensitive queries

Memory Across Tools#

All tools support memory:

Query Tool#

Summarize Tool#

Web Search Tool#

Engine Tool#

Managing Conversation History#

View History#

Clear History#

Important: Clearing history doesn't delete ingested documents!

Practical Patterns#

Pattern 1: Conversational Q&A#

Each question builds on previous answers naturally.

Pattern 2: Topic Switching#

Pattern 3: Contextual Refinement#

Pattern 4: Memory-Less Batch Processing#

Advanced Memory Techniques#

Selective Memory#

Memory Pagination#

Periodic Memory Cleanup#

Best Practices#

✅ Do This#

❌ Don't Do This#

Memory and Performance#

Token Usage#

Memory increases token usage:
Optimization: Clear memory periodically to reduce token usage.

Response Quality vs. Cost#

Troubleshooting#

Memory Not Working#

Context Confusion#

If responses seem confused:

Memory Overflow#

If context becomes too large:

Next Steps#

Session Management - Organize your work
Streaming Responses - Handle real-time data
Error Handling - Robust applications
Performance Optimization - Scale efficiently

Pro Tip: Let memory work for you by default. Only disable it when you have a specific reason.
Modified at 2025-10-17 17:47:30
Previous
Tools Overview
Next
Streaming Responses
Built with