Skip to content

Python: Multi-Turn example can't be reproduced #4447

@lisngt

Description

@lisngt

Hi all,

I tried to reproduce this example

https://github.com/microsoft/agent-framework/blob/main/python/samples/01-get-started/03_multi_turn.py

As I understand, in the second turn my agent should remember that I'm Alice but it's not the case.

Image

The agent said that he has no memory. I've tried with Azure Foundry (gpt-5-mini) and GitHub Models (gpt-4-mini). Both give me the same result.

import asyncio
from agent_framework.openai import OpenAIChatClient
from agent_framework import Agent
from agent_framework.azure import AzureOpenAIChatClient
from dotenv import load_dotenv
import os

load_dotenv()

async def main():
    # client = OpenAIChatClient(
    #     base_url="https://models.github.ai/inference",
    #     model_id="openai/gpt-4.1-mini",
    #     api_key=os.getenv("APIKEY"),
    # )

    client = AzureOpenAIChatClient(
        api_version="2024-12-01-preview",
        endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"),
        deployment_name=os.getenv("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"),
        api_key=os.getenv("FOUNDRY_APIKEY")
    )

    agent = client.as_agent(
       instructions="You are a friendly assistant. Keep your answers concise and helpful.", name="ConversationAgent"
    )

    session = agent.create_session()
    async for chunk in agent.run("My name is Alice and I love hiking.", session=session, stream=True):
        if chunk.text:
            print(chunk.text, end="", flush=True)
    
    print("\n\n")
    
    async for chunk in agent.run("What do you remember about me?", session=session, stream=True):
        if chunk.text:
            print(chunk.text, end="", flush=True)
    
if __name__ == "__main__":
    asyncio.run(main())

Do you have any idea why? I hope it's not because of the model.

Thank you.

Metadata

Metadata

Assignees

Labels

pythonsamplesIssue relates to the samplesv1.0Features being tracked for the version 1.0 GA

Type

No type

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions