I’ve encountered a critical issue when using the asynchronous execution mode with the Team class - historical context is not being preserved between consecutive calls, and the database tables for user memories are not being created.
Observed Behavior
- When executing multiple
arun()
calls on a Team instance, each call appears to execute in isolation without access to the conversation history from previous calls. - Despite configuring a PostgreSQL database for memory storage, the
user_memories
table is not being created in the database.
Steps to Reproduce
# Setup memory with PostgreSQL backend
memory = Memory(
model=AzureOpenAI(
azure_deployment=deployment,
azure_endpoint=endpoint,
api_version=api_version,
api_key=key
),
db=PostgresMemoryDb(table_name="user_memories", db_url=db_url),
)
# Configure Team with the memory
agent_team = Team(
mode="coordinate",
members=[agent1, agent2],
memory=memory,
model=AzureOpenAI(...),
storage=PostgresStorage(
table_name="agent_sessions",
db_url=db_url,
auto_upgrade_schema=True
),
enable_team_history=True,
num_history_runs=1,
session_id="1"
)
# Run multiple async queries
async def run_multiple_queries():
# All queries use the same session_id and user_id
await agent_team.arun(message1, stream=True, stream_intermediate_steps=True, session_id="1", user_id="dreamer")
await agent_team.arun(message1, stream=True, stream_intermediate_steps=True, session_id="1", user_id="dreamer")
await agent_team.arun(message1, stream=True, stream_intermediate_steps=True, session_id="1", user_id="dreamer")
await agent_team.arun(message1, stream=True, stream_intermediate_steps=True, session_id="1", user_id="dreamer")
# Execute in a single event loop
asyncio.run(run_multiple_queries())
Expected Behavior
- Each subsequent
arun()
call should have access to the conversation history from previous calls. - The
user_memories
table should be automatically created in the PostgreSQL database. - The conversation history should be persisted between calls, allowing agents to reference previous interactions.
Actual Behavior
- Each
arun()
call executes as if it’s the first interaction in the session - no history is preserved. - The
user_memories
table is not created in the database. - Despite using the same
session_id
anduser_id
, conversation continuity is lost.