memory parameter uses in the Agent #2781
Unanswered
mallesh-sourcefuse
asked this question in
Q&A
Replies: 1 comment
-
|
The State-Based Memory Patternfrom crewai import Agent, Task, Crew
# External memory state
memory_state = {
"conversation_history": [],
"key_facts": {},
"context_window": [] # Last N interactions
}
def update_memory(agent_output, max_window=5):
memory_state["conversation_history"].append(agent_output)
memory_state["context_window"] = memory_state["conversation_history"][-max_window:]
return memory_state
# Inject memory into agent context
agent = Agent(
role="Assistant",
goal="Help user with context awareness",
backstory=f"""You have access to conversation history:
{memory_state["context_window"]}
Key facts remembered: {memory_state["key_facts"]}""",
memory=True # Enable built-in + your custom context
)Why This Works
For multi-agent scenarios where agents need shared memory, external state becomes essential - each agent reads/writes to the same memory store. More on state-based patterns: https://github.com/KeepALifeUS/autonomous-agents |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is the memory parameter in CrewAI's Agent class limited to a boolean option for default memory, or can it also accept a Langchain memory object for more advanced configurations?
research_agent = Agent( role="Researcher", goal="Gather relevant information.", backstory="Expert researcher.", llm=llm, memory=ConversationBufferWindowMemory(k=3, memory_key="chat_history", return_messages=True), verbose=True )By passing chat history to the agent to understand the conversation flow and respond more accurately. Does CrewAI support passing custom chat history through Langchain memory objects?
@lucasgomide Can you please check this ??
Beta Was this translation helpful? Give feedback.
All reactions