Overview
The Context Q&A Agent specializes in answering questions about past conversations, user statements, and chat history. It uses a long-context model with history retrieval tools.Initialization
Model Configuration
Uses a configurable long-context model:Model Requirements
- Long context window: Must handle thousands of messages
- Low temperature: 0.3 for accurate fact retrieval
- High token limit: 8000 for comprehensive responses
Tools
1. HistoryTools
Providesread_chat_history function:
IMPORTANT: always fetch a minimum of 5000 messages on first try.The agent must:
- Call
read_chat_historybefore answering - Fetch at least 5000 messages initially
- Fetch more if needed for complete context
2. BioTools
Accesses user biographical information:- User profiles
- Stored preferences
- User metadata
Use Cases
Fromsystem_prompt.md:83:
Long-context chat history / thread analysis / who-said-what → delegate to context-qna-agent (requires Channel ID).
1. Message Attribution
Example queries:- “Who said they were working on the API?”
- “Did anyone mention the deadline?”
- “What did Alice say about the project?”
- Fetches history with
read_chat_history - Searches for relevant messages
- Attributes statements to specific users
- Includes timestamps
2. Topic Summaries
Example queries:- “Summarize the discussion about deployment”
- “What have we decided about the new feature?”
- “Recap the meeting from yesterday”
- Retrieves extensive message history
- Identifies topic-relevant messages
- Chronologically summarizes
- Notes key decisions and opinions
3. Timeline Tracking
Example queries:- “When was the bug first mentioned?”
- “How long ago did we discuss pricing?”
- “What was the last message about the release?”
- Scans timestamps in history
- Identifies first/last mentions
- Provides precise timing
- Shows evolution of discussion
4. Opinion Mining
Example queries:- “What’s Bob’s opinion on the redesign?”
- “Who supports the new approach?”
- “What concerns were raised?”
- Finds user-specific statements
- Extracts opinions and sentiments
- Provides context for each opinion
- Notes changes over time
Instructions
From the agent’s instructions:Context Awareness
system_prompt.md:48-73, the agent understands:
Temporal Context
The current date/time is provided at the start of the context in IST. Each message has a timestamp like[2h ago],[1d ago], or[Dec 15, 14:30]- all times are in IST.
Past vs Present
When someone says “I’m working on X” in a message from 2 hours ago, they were working on it THEN, not necessarily now.The agent:
- Uses phrases like “Earlier you mentioned…”
- Distinguishes past statements from current reality
- Calculates relative times (“yesterday”, “last week”)
Reply Context
If a user is replying to a specific message, you will see a [REPLY CONTEXT] block before their message.
The agent understands message threading and reply chains.
Channel ID Requirement
Fromsystem_prompt.md:83:
delegate to context-qna-agent (requires Channel ID)
The agent needs the Discord channel ID to:
- Scope history retrieval
- Access correct conversation thread
- Maintain context boundaries
Performance Characteristics
- Speed: Moderate (history fetch adds latency)
- Accuracy: High (low temperature, precise retrieval)
- Context limit: Determined by
CONTEXT_AGENT_MODEL - Minimum fetch: 5000 messages per query
Best Practices
1. Always Fetch History First
2. Fetch Sufficient Messages
3. Precise Attribution
4. Temporal Precision
Configuration
Environment variables:Delegation Strategy
When to Use Context Q&A Agent
✅ Use for:- Questions about past conversations
- “Who said” queries
- Topic summaries
- Timeline questions
- Opinion tracking
- Current web information (use Perplexity Agent)
- Code execution (use Code Agent)
- Math (use Team Leader)
- Real-time data (use Perplexity Agent)