From 4a6dc8c3892a6881cf8ba2e46ea60d878c760cdc Mon Sep 17 00:00:00 2001 From: Giles Odigwe Date: Fri, 6 Mar 2026 11:23:28 -0800 Subject: [PATCH] Fix chat_response_cancellation sample to use Message objects 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