-
Notifications
You must be signed in to change notification settings - Fork 621
Description
Streaming responses don't respect MAX_MESSAGE_PAIRS_PER_AGENT configuration
Description
When using Agent Squad with streaming responses, the conversation history grows without limit because the processStreamInBackground
method doesn't pass the maxHistorySize
parameter to saveConversationExchange
. This is inconsistent with the non-streaming code path which correctly limits the history size.
Current Behavior
In src/orchestrator.ts
, the streaming code path (lines 487-489) calls:
await saveConversationExchange(
userInput,
fullResponse,
this.storage,
userId,
sessionId,
agent.id
// Missing: this.config.MAX_MESSAGE_PAIRS_PER_AGENT
);
While the non-streaming code path correctly includes all parameters.
Expected Behavior
Both streaming and non-streaming responses should respect the MAX_MESSAGE_PAIRS_PER_AGENT
configuration to limit conversation history size consistently.
Impact
- Memory Growth: Conversation history grows unbounded for streaming agents
- Performance: Large conversation histories can slow down agent responses
- Inconsistency: Different behavior between streaming and non-streaming modes
Steps to Reproduce
- Create an Agent Squad orchestrator with
MAX_MESSAGE_PAIRS_PER_AGENT: 5
- Create an agent that returns streaming responses with
saveChat: true
- Have multiple conversation turns (more than 5)
- Observe that all messages are retained in history instead of being limited to 5 pairs
Environment
- agent-squad version: 1.0.1
- Node.js version: Any
- TypeScript version: Any
Proposed Solution
Add the missing this.config.MAX_MESSAGE_PAIRS_PER_AGENT
parameter to the saveConversationExchange
call in the processStreamInBackground
method.
I have a fix ready with tests and will submit a PR once this issue is created.