feat: use BoltAgent for chat_stream in all implementations#16
Conversation
mwbrooks
left a comment
There was a problem hiding this comment.
Some comments for the reviewers learning Casey's code base!
| import re | ||
| from logging import Logger | ||
|
|
||
| from slack_bolt.agent.async_agent import AsyncBoltAgent |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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!
f4f1ab0 to
3910266
Compare
…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
Type of change
Summary
This pull request updates all 3 apps to use
agent.chat_stream().Unfortunately,
agent.chat_stream()wasn't able to resolve therecipient_team_idfor theapp_mentionevent. I think this is because the event usesevent["team"]instead ofevent["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.pyis 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 themessageevent 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 useagent.chat_streamin unexpected and creative ways.Requirements