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
Have you searched for related issues? Others may have had similar requests
yes
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:
asyncdefmain():
agent=Agent(name="Assistant", instructions="Reply very concisely.")
withtrace(workflow_name="Conversation", group_id=thread_id):
# First turnresult=awaitRunner.run(agent, "What city is the Golden Gate Bridge in?")
print(result.final_output)
# San Francisco# Second turnnew_input=result.to_input_list() + [{"role": "user", "content": "What state is it in?"}]
result=awaitRunner.run(agent, new_input)
print(result.final_output)
# California
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:
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.
Usage
fromagentsimportAgent, Runner, RunConfig, SQLiteSessionMemoryagent=Agent(name="Assistant", instructions="Reply concisely.")
memory=SQLiteSessionMemory()
config=RunConfig(memory=memory, session_id="conversation_123")
awaitRunner.run(agent, "Hi, I'm planning a trip to Japan", run_config=config)
awaitRunner.run(agent, "What's the best time to visit?", run_config=config)
awaitRunner.run(agent, "How about cherry blossom season?", run_config=config)
SessionMemory Interface
The basic idea is to have an interface (typing.Protocol) that describes how to manage conversation memory. That would be passed to RunConfig along with a session_id. I included a SQLiteSessionMemory implementation since that won't introduce any new dependencies. New backends could then be defined and used in the following way:
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: