Skip to content

Commit 9593eed

Browse files
Fix typing: safely extract content from TaskMessageContent in hello_acp tutorial
1 parent b0c1b98 commit 9593eed

File tree

1 file changed

+6
-1
lines changed
  • examples/tutorials/00_sync/000_hello_acp/project

1 file changed

+6
-1
lines changed

examples/tutorials/00_sync/000_hello_acp/project/acp.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ async def handle_message_send(
2121
params: SendMessageParams
2222
) -> Union[TaskMessageContent, AsyncGenerator[TaskMessageUpdate, None]]:
2323
"""Default message handler with streaming support"""
24+
# Extract content safely from the message
25+
message_text = ""
26+
if hasattr(params.content, 'content') and isinstance(params.content.content, str):
27+
message_text = params.content.content
28+
2429
return TextContent(
2530
author="agent",
26-
content=f"Hello! I've received your message. Here's a generic response, but in future tutorials we'll see how you can get me to intelligently respond to your message. This is what I heard you say: {params.content.content}",
31+
content=f"Hello! I've received your message. Here's a generic response, but in future tutorials we'll see how you can get me to intelligently respond to your message. This is what I heard you say: {message_text}",
2732
)
2833

0 commit comments

Comments
 (0)