Skip to content

Add Session Memory #745

Open
Open
@knowsuchagency

Description

@knowsuchagency

Please read this first

  • Have you read the docs?Agents SDK docs
    • yes
  • 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:
async def main():
    agent = Agent(name="Assistant", instructions="Reply very concisely.")

    with trace(workflow_name="Conversation", group_id=thread_id):
        # First turn
        result = await Runner.run(agent, "What city is the Golden Gate Bridge in?")
        print(result.final_output)
        # San Francisco

        # Second turn
        new_input = result.to_input_list() + [{"role": "user", "content": "What state is it in?"}]
        result = await Runner.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions