Skip to content

Commit 14976f2

Browse files
declan-scaleclaude
andcommitted
docs(cli): mirror non-text content guard in sync README snippets
Update the illustrative handler snippets in the sync READMEs to use the same isinstance(content, TextContent) guard as the generated code, so the docs don't teach the crashing params.content.content pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4e9b7b2 commit 14976f2

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/agentex/lib/cli/templates/sync-openai-agents-local-sandbox/README.md.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ Add sophisticated response generation:
262262
@acp.on_message_send
263263
async def handle_message_send(params: SendMessageParams):
264264
# Analyze input
265-
user_message = params.content.content
265+
content = params.content
266+
if not isinstance(content, TextContent):
267+
return TextContent(author="agent", content="Sorry, I can only handle text messages right now.")
268+
user_message = content.content
266269

267270
# Generate response
268271
response = await generate_intelligent_response(user_message)

src/agentex/lib/cli/templates/sync-openai-agents/README.md.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ Add sophisticated response generation:
251251
@acp.on_message_send
252252
async def handle_message_send(params: SendMessageParams):
253253
# Analyze input
254-
user_message = params.content.content
254+
content = params.content
255+
if not isinstance(content, TextContent):
256+
return TextContent(author="agent", content="Sorry, I can only handle text messages right now.")
257+
user_message = content.content
255258

256259
# Generate response
257260
response = await generate_intelligent_response(user_message)

src/agentex/lib/cli/templates/sync-pydantic-ai/README.md.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ Add sophisticated response generation:
251251
@acp.on_message_send
252252
async def handle_message_send(params: SendMessageParams):
253253
# Analyze input
254-
user_message = params.content.content
254+
content = params.content
255+
if not isinstance(content, TextContent):
256+
return TextContent(author="agent", content="Sorry, I can only handle text messages right now.")
257+
user_message = content.content
255258

256259
# Generate response
257260
response = await generate_intelligent_response(user_message)

src/agentex/lib/cli/templates/sync/README.md.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ Add sophisticated response generation:
251251
@acp.on_message_send
252252
async def handle_message_send(params: SendMessageParams):
253253
# Analyze input
254-
user_message = params.content.content
254+
content = params.content
255+
if not isinstance(content, TextContent):
256+
return TextContent(author="agent", content="Sorry, I can only handle text messages right now.")
257+
user_message = content.content
255258

256259
# Generate response
257260
response = await generate_intelligent_response(user_message)

0 commit comments

Comments
 (0)