Skip to content

Commit 19120d1

Browse files
feat: flatten the agents into injected kwargs
1 parent 72a90d2 commit 19120d1

33 files changed

Lines changed: 914 additions & 1183 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ slack_bolt/adapter/flask/handler.py # sync-only (no async Flask a
123123

124124
### AI Agents & Assistants
125125

126-
`BoltAgent` (`slack_bolt/agent/`) provides `chat_stream()`, `set_status()`, and `set_suggested_prompts()` for AI-powered agents. `Assistant` middleware (`slack_bolt/middleware/assistant/`) handles assistant thread events.
126+
`SayStream` (`slack_bolt/context/say_stream/`) provides `chat_stream()` for AI-powered agents (experimental). `Assistant` middleware (`slack_bolt/middleware/assistant/`) handles assistant thread events. `set_status` and `set_suggested_prompts` are available as context utilities for assistant events.
127127

128128
## Key Development Patterns
129129

docs/english/experiments.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
# Experiments
22

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."
44

55
Experimental features are categorized as `semver:patch` until the experimental status is removed.
66

77
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.
88

99
## Available experiments
10-
* [Agent listener argument](#agent)
10+
* [say_stream listener argument](#say-stream)
1111

12-
## Agent listener argument {#agent}
12+
## say_stream listener argument {#say-stream}
1313

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.
1515

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`.
1917

2018
### Example
2119

2220
```python
23-
from slack_bolt import BoltAgent
21+
from slack_bolt import SayStream
2422

2523
@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()
2826
stream.append(markdown_text="Hello!")
2927
stream.stop()
3028
```
3129

3230
### Limitations
3331

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.

slack_bolt/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .response import BoltResponse
2222

2323
# AI Agents & Assistants
24-
from .agent import BoltAgent
24+
from .context.say_stream import SayStream
2525
from .middleware.assistant.assistant import (
2626
Assistant,
2727
)
@@ -47,7 +47,7 @@
4747
"CustomListenerMatcher",
4848
"BoltRequest",
4949
"BoltResponse",
50-
"BoltAgent",
50+
"SayStream",
5151
"Assistant",
5252
"AssistantThreadContext",
5353
"AssistantThreadContextStore",

slack_bolt/agent/__init__.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

slack_bolt/agent/agent.py

Lines changed: 0 additions & 139 deletions
This file was deleted.

slack_bolt/agent/async_agent.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)