From d072f67e6642a8244787611bff32541c04178665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fur=C3=B3=20Tam=C3=A1s-M=C3=A1rk?= Date: Fri, 21 Nov 2025 11:18:59 +0200 Subject: [PATCH 1/2] Refactor agent creation and conversation handling --- .../default/agents/how-to/migrate.md | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/articles/ai-foundry/default/agents/how-to/migrate.md b/articles/ai-foundry/default/agents/how-to/migrate.md index 81a6f1da3a..34257da413 100644 --- a/articles/ai-foundry/default/agents/how-to/migrate.md +++ b/articles/ai-foundry/default/agents/how-to/migrate.md @@ -390,21 +390,22 @@ for message in messages: **Current** ```python -agent = project_client.agents.create_version( - agent_name="my-agent", -    definition={ -    "kind": "prompt", -        "model": "gpt-4.1", -        "instructions": "You politely help with math questions. Use the Code Interpreter tool when asked to visualize numbers.", -        "tools": [{"type": "code_interpreter", "container": {"type": "auto"}}] -    } -) -conversation = openai_client.conversations.create( - items=[{"type": "message", "role": "user", "content": "Hi, Agent! Draw a graph for a line with a rate of change of 4 and y-intercept of 9."}], -) -response = openai_client.responses.create( - conversation=conversation.id, -    extra_body={"agent": {"type": "agent_reference", "name": agent.name, "version": agent.version}}, -    input = "Please address the user as Jane Doe. The user has a premium account" -) -``` \ No newline at end of file +with project_client.get_openai_client() as openai_client: + agent = project_client.agents.create_version( + agent_name="my-agent", +     definition={ +     "kind": "prompt", +         "model": "gpt-4.1", +         "instructions": "You politely help with math questions. Use the Code Interpreter tool when asked to visualize numbers.", +         "tools": [{"type": "code_interpreter", "container": {"type": "auto"}}] +     } + ) + conversation = openai_client.conversations.create( + items=[{"type": "message", "role": "user", "content": "Hi, Agent! Draw a graph for a line with a rate of change of 4 and y-intercept of 9."}], + ) + response = openai_client.responses.create( + conversation=conversation.id, +     extra_body={"agent": {"type": "agent_reference", "name": agent.name, "version": agent.version}}, +     input = "Please address the user as Jane Doe. The user has a premium account" + ) +``` From e9667d2f8077f9d3360a63339b24ae957556841a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fur=C3=B3=20Tam=C3=A1s-M=C3=A1rk?= Date: Tue, 9 Dec 2025 09:37:27 +0200 Subject: [PATCH 2/2] Update articles/ai-foundry/default/agents/how-to/migrate.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- articles/ai-foundry/default/agents/how-to/migrate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/articles/ai-foundry/default/agents/how-to/migrate.md b/articles/ai-foundry/default/agents/how-to/migrate.md index 34257da413..80809d7e69 100644 --- a/articles/ai-foundry/default/agents/how-to/migrate.md +++ b/articles/ai-foundry/default/agents/how-to/migrate.md @@ -406,6 +406,6 @@ with project_client.get_openai_client() as openai_client: response = openai_client.responses.create( conversation=conversation.id,     extra_body={"agent": {"type": "agent_reference", "name": agent.name, "version": agent.version}}, -     input = "Please address the user as Jane Doe. The user has a premium account" +     input="Please address the user as Jane Doe. The user has a premium account" ) ```