|
1 | 1 | # Experiments |
2 | 2 |
|
3 | | -Bolt for Python includes experimental features still under active development. These features may be fleeting, may not be perfectly polished, and should be thought of as available for use "at your own risk." |
| 3 | +Bolt for Python includes experimental features still under active development. These features may be fleeting, may not be perfectly polished, and should be thought of as available for use "at your own risk." |
4 | 4 |
|
5 | 5 | Experimental features are categorized as `semver:patch` until the experimental status is removed. |
6 | 6 |
|
7 | 7 | We love feedback from our community, so we encourage you to explore and interact with the [GitHub repo](https://github.com/slackapi/bolt-python). Contributions, bug reports, and any feedback are all helpful; let us nurture the Slack CLI together to help make building Slack apps more pleasant for everyone. |
8 | 8 |
|
9 | 9 | ## Available experiments |
10 | | -* [Agent listener argument](#agent) |
| 10 | +* [say_stream listener argument](#say-stream) |
11 | 11 |
|
12 | | -## Agent listener argument {#agent} |
| 12 | +## say_stream listener argument {#say-stream} |
13 | 13 |
|
14 | | -The `agent: BoltAgent` listener argument provides access to AI agent-related features. |
| 14 | +The `say_stream: SayStream` listener argument provides access to streaming chat for AI agents. |
15 | 15 |
|
16 | | -The `BoltAgent` and `AsyncBoltAgent` classes offer a `chat_stream()` method that comes pre-configured with event context defaults: `channel_id`, `thread_ts`, `team_id`, and `user_id` fields. |
17 | | - |
18 | | -The listener argument is wired into the Bolt `kwargs` injection system, so listeners can declare it as a parameter or access it via the `context.agent` property. |
| 16 | +`SayStream` and `AsyncSayStream` are callable context utilities pre-configured with event context defaults: `channel_id`, `thread_ts`, `team_id`, and `user_id`. |
19 | 17 |
|
20 | 18 | ### Example |
21 | 19 |
|
22 | 20 | ```python |
23 | | -from slack_bolt import BoltAgent |
| 21 | +from slack_bolt import SayStream |
24 | 22 |
|
25 | 23 | @app.event("app_mention") |
26 | | -def handle_mention(agent: BoltAgent): |
27 | | - stream = agent.chat_stream() |
| 24 | +def handle_mention(say_stream: SayStream): |
| 25 | + stream = say_stream() |
28 | 26 | stream.append(markdown_text="Hello!") |
29 | 27 | stream.stop() |
30 | 28 | ``` |
31 | 29 |
|
32 | 30 | ### Limitations |
33 | 31 |
|
34 | | -The `chat_stream()` method currently only works when the `thread_ts` field is available in the event context (DMs and threaded replies). Top-level channel messages do not have a `thread_ts` field, and the `ts` field is not yet provided to `BoltAgent`. |
| 32 | +`say_stream()` requires either `thread_ts` or `event.ts` in the event context. It works in DMs, threaded replies, and top-level messages with a `ts` field. |
0 commit comments