-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Session Memory #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah fair feedback. Would love to discuss the interface in this issue and would even welcome a contribution once we are happy with it! |
Cool! I went ahead and submitted #752 after some experimentation. I'm more than happy to workshop the API -- I just found coding and documentation to be the best way to shape my thinking. Usagefrom agents import Agent, Runner, Session, SQLiteSession
agent = Agent(name="Assistant", instructions="Reply concisely.")
session: Session = SQLiteSession("convo_123")
messages = [
"Hi, I'm planning a trip to Japan",
"What's the best time to visit?",
"How about cherry blossom season?"
]
for message in messages:
response = Runner.run_sync(agent, message, session=session)
print(response.final_output) Session InterfaceThe basic idea is to have an interface ( class CustomSession:
session_id: str
async def get_messages(self, amount: int | None = None) -> List[dict]:
...
async def add_messages(self, messages: List[dict]) -> None:
...
async def pop_message(self) -> dict | None:
...
async def clear_session(self) -> None:
... |
Uh oh!
There was an error while loading. Please reload this page.
Please read this first
Describe the feature
I've noticed it greatly improves developer experience to have an interface with a default implementation (or two) to handle conversation memory.
The docs suggest the following to handle memory:
It's currently left to the user to explicitly manage session memory using
result.to_input_list()
Alternatives
A good example of what this could look like is Google's ADK.
Another such example from my own AI abstraction library, Promptic
The text was updated successfully, but these errors were encountered: