You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!!
I've set memory_enabled=True to true in the agent, but it's not saving previous messages; it has no context for them. Is there some extra step I'm missing?
example code:
`python
import asyncio
import os
import mcp_use
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
from mcp_use import MCPAgent, MCPClient
mcp_use.set_debug(0)
async def main():
"""Run the example using a configuration file."""
# Load environment variables
load_dotenv()
# Create MCPClient from config file
config = {
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"],
"env": {
"DISPLAY": ":1"
}
}
}
}
client = MCPClient.from_dict(config)
# Create LLM
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", api_key="....")
# Create agent with the client
agent = MCPAgent(llm=llm, client=client, max_steps=30,memory_enabled=True)
# Run the query
async for step in agent.stream(
"""
Que pregunte anteriormente?
""",
max_steps=30,
):
if isinstance(step, str):
print(f"\n✅ Final Result:\n{step}")
if name == "main":
# Run the appropriate example
asyncio.run(main())`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!!
I've set memory_enabled=True to true in the agent, but it's not saving previous messages; it has no context for them. Is there some extra step I'm missing?
example code:
`python
import asyncio
import os
import mcp_use
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
from mcp_use import MCPAgent, MCPClient
mcp_use.set_debug(0)
async def main():
"""Run the example using a configuration file."""
# Load environment variables
load_dotenv()
# Create MCPClient from config file
config = {
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"],
"env": {
"DISPLAY": ":1"
}
}
}
}
client = MCPClient.from_dict(config)
# Create LLM
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", api_key="....")
# Create agent with the client
agent = MCPAgent(llm=llm, client=client, max_steps=30,memory_enabled=True)
# Run the query
async for step in agent.stream(
"""
Que pregunte anteriormente?
""",
max_steps=30,
):
if isinstance(step, str):
print(f"\n✅ Final Result:\n{step}")
if name == "main":
# Run the appropriate example
asyncio.run(main())`
Beta Was this translation helpful? Give feedback.
All reactions