From e2f0bc814eceb300bcad1010c03c6a563ce9f0f4 Mon Sep 17 00:00:00 2001 From: Giles Odigwe <79032838+giles17@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:59:41 -0700 Subject: [PATCH] Fix chat_response_cancellation sample to use Message objects (#4532) The sample was passing raw strings in a list to get_response(), which expects Message objects. This caused an AttributeError since strings don't have a 'role' attribute. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../02-agents/chat_client/chat_response_cancellation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/samples/02-agents/chat_client/chat_response_cancellation.py b/python/samples/02-agents/chat_client/chat_response_cancellation.py index db292786ce..dd32379443 100644 --- a/python/samples/02-agents/chat_client/chat_response_cancellation.py +++ b/python/samples/02-agents/chat_client/chat_response_cancellation.py @@ -2,6 +2,7 @@ import asyncio +from agent_framework import Message from agent_framework.openai import OpenAIChatClient from dotenv import load_dotenv @@ -28,7 +29,7 @@ async def main() -> None: client = OpenAIChatClient() try: - task = asyncio.create_task(client.get_response(messages=["Tell me a fantasy story."])) + task = asyncio.create_task(client.get_response(messages=[Message(role="user", text="Tell me a fantasy story.")])) await asyncio.sleep(1) task.cancel() await task