from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage
from upsonic.tools import tool
@tool
def get_weather(city: str) -> str:
"""Get weather for a city."""
return f"Weather in {city}: 72°F, Sunny"
storage = SqliteStorage(db_file="tools.db")
memory = Memory(
storage=storage,
session_id="session_001",
full_session_memory=True,
feed_tool_call_results=True # Include tool outputs in history
)
agent = Agent("openai/gpt-4o", tools=[get_weather], memory=memory)
result1 = agent.do(Task("What's the weather in NYC?"))
result2 = agent.do(Task("What was the weather you just told me?"))
print(result2) # Can reference previous tool results