Skip to content

feat: use BoltAgent for chat_stream in all implementations#16

Merged
mwbrooks merged 3 commits intomainfrom
mwbrooks-agent-chat-stream
Mar 30, 2026
Merged

feat: use BoltAgent for chat_stream in all implementations#16
mwbrooks merged 3 commits intomainfrom
mwbrooks-agent-chat-stream

Conversation

@mwbrooks
Copy link
Copy Markdown
Member

Type of change

  • New feature
  • Bug fix
  • Documentation

Summary

This pull request updates all 3 apps to use agent.chat_stream().

Unfortunately, agent.chat_stream() wasn't able to resolve the recipient_team_id for the app_mention event. I think this is because the event uses event["team"] instead of event["team_id"]. So, I had to manually provide all of the arguments (because we require setting all or none). This is an area that we should improve in Bolt Python.

Related, the issue_modal.py is a poor implementation. Inside the App Home, the bot responds to the message posted from clicking a button. This code needs to be refactored to allow the message event to handle those instead. That is out-of-scope of this PR, so I wouldn't stress that we have to manually provide all arguments here - in some ways it's doing what it should, which is allow developers to use agent.chat_stream in unexpected and creative ways.

Requirements

  • I have ensured the changes I am contributing align with existing patterns and have tested and linted my code
  • I've read and agree to the Code of Conduct

@mwbrooks mwbrooks requested review from srtaalej and zimeg February 21, 2026 04:11
@mwbrooks mwbrooks self-assigned this Feb 21, 2026
@mwbrooks mwbrooks added the enhancement New feature or request label Feb 21, 2026
Copy link
Copy Markdown
Member Author

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for the reviewers learning Casey's code base!

import re
from logging import Logger

from slack_bolt.agent.async_agent import AsyncBoltAgent
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Good news, AsyncBoltAgent works!

streamer = await agent.chat_stream(
channel=channel_id,
recipient_team_id=team_id,
recipient_team_id=team_id, # chat_stream helper cannot infer event["team"] from client
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: In Bolt Python, we should fix the helper to resolveevent["team"].


# Stream the response in thread with feedback buttons
streamer = await client.chat_stream(
streamer = await agent.chat_stream(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: issue_modal.py is a poor implementation.

When a user presses a button on the App Home and submit the modal, a DM is sent with the message.

Ideally, the message event handler should stream a response.

However, currently the response is handled inside the issue_modal.py (here) because the message event filters out all bot messages. Since we're in the App Home / Issue Modal Submission, there is no channel or thread. So, chat_stream() has no hope of resolving it.

The good news is that we can still provide the arguments required to customize it. So that's working well!

@mwbrooks mwbrooks force-pushed the mwbrooks-agent-chat-stream branch from f4f1ab0 to 3910266 Compare March 30, 2026 21:08
…tream

# Conflicts:
#	claude-agent-sdk/listeners/events/app_mentioned.py
#	claude-agent-sdk/listeners/events/message.py
#	claude-agent-sdk/listeners/views/issue_modal.py
#	openai-agents-sdk/listeners/events/app_mentioned.py
#	openai-agents-sdk/listeners/events/message.py
#	openai-agents-sdk/listeners/views/issue_modal.py
#	pydantic-ai/listeners/events/app_mentioned.py
#	pydantic-ai/listeners/events/message.py
#	pydantic-ai/listeners/views/issue_modal.py
Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks So appreciate the revisiting of these changes and what's soon ahead 🚢 ✨

@mwbrooks mwbrooks merged commit 23f83a9 into main Mar 30, 2026
4 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-agent-chat-stream branch March 30, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants