Skip to content

Commit 4e1de25

Browse files
authored
Merge branch 'main' into release/2.5.5
2 parents f8c5a62 + 5255049 commit 4e1de25

32 files changed

+3321
-566
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ agno_json_data/
7676
.claude/
7777
.cursor/
7878
.conductor/
79+
.context/
80+
.codex/
7981

8082
# Private design documents (symlinked)
8183
/specs

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Make sure all tests pass before submitting your pull request. If you add new fea
7575
2. Create a new directory under `libs/agno/agno/vectordb` for the new vector database.
7676
3. Create a Class for your VectorDb that implements the `VectorDb` interface
7777
- Your Class will be in the `libs/agno/agno/vectordb/<your_db>/<your_db>.py` file.
78-
- The `VectorDb` interface is defined in `libs/agno/agno/vectordb/base
78+
- The `VectorDb` interface is defined in `libs/agno/agno/vectordb/base.py`
7979
- Import your `VectorDb` Class in `libs/agno/agno/vectordb/<your_db>/__init__.py`.
8080
- Checkout the [`libs/agno/agno/vectordb/pgvector/pgvector`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/vectordb/pgvector/pgvector.py) file for an example.
8181
4. Add a recipe for using your `VectorDb` under `cookbook/07_knowledge/vector_db/<your_db>`.
@@ -91,7 +91,7 @@ Make sure all tests pass before submitting your pull request. If you add new fea
9191
- Create a Class for your LLM provider that inherits the `OpenAILike` Class from `libs/agno/agno/models/openai/like.py`.
9292
- Your Class will be in the `libs/agno/agno/models/<your_model>/<your_model>.py` file.
9393
- Import your Class in the `libs/agno/agno/models/<your_model>/__init__.py` file.
94-
- Checkout the [`agno/models/xai/xai.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/together/together.py) file for an example.
94+
- Checkout the [`agno/models/together/together.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/together/together.py) file for an example.
9595
4. If the Model provider does not support the OpenAI API spec:
9696
- Reach out to us on [Discord](https://discord.gg/4MtYHHrgA8) or open an issue to discuss the best way to integrate your LLM provider.
9797
- Checkout [`agno/models/anthropic/claude.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/anthropic/claude.py) or [`agno/models/cohere/chat.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/models/cohere/chat.py) for inspiration.
@@ -107,7 +107,7 @@ Make sure all tests pass before submitting your pull request. If you add new fea
107107
return YourModel(id=model_id)
108108
```
109109
6. Add a recipe for using your Model provider under `cookbook/models/<your_model>`.
110-
- Checkout [`agno/cookbook/models/aws/claude`](https://github.com/agno-agi/agno/tree/main/cookbook/models/aws/claude) for an example.
110+
- Checkout [`agno/cookbook/90_models/aws/claude`](https://github.com/agno-agi/agno/tree/main/cookbook/90_models/aws/claude) for an example.
111111
- Show both the model class and string syntax in your examples
112112
7. Important: Format and validate your code by running `./scripts/format.sh` and `./scripts/validate.sh`.
113113
8. Submit a pull request.
@@ -116,13 +116,13 @@ Make sure all tests pass before submitting your pull request. If you add new fea
116116

117117
1. Setup your local environment by following the [Development setup](#development-setup).
118118
2. Create a new directory under `libs/agno/agno/tools` for the new Tool.
119-
3. Create a Class for your Tool that inherits the `Toolkit` Class from `libs/agno/agno/tools/toolkit/.py`.
119+
3. Create a Class for your Tool that inherits the `Toolkit` Class from `libs/agno/agno/tools/toolkit/toolkit.py`.
120120
- Your Class will be in `libs/agno/agno/tools/<your_tool>.py`.
121121
- Make sure to register all functions in your class via a flag.
122122
- Checkout the [`agno/tools/youtube.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/youtube.py) file for an example.
123123
- If your tool requires an API key, checkout the [`agno/tools/serpapi_tools.py`](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/serpapi_tools.py) as well.
124124
4. Add a recipe for using your Tool under `cookbook/tools/<your_tool>`.
125-
- Checkout [`agno/cookbook/tools/youtube_tools`](https://github.com/agno-agi/agno/blob/main/cookbook/tools/youtube_tools.py) for an example.
125+
- Checkout [`agno/cookbook/91_tools/youtube_tools`](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/youtube_tools.py) for an example.
126126
5. Important: Format and validate your code by running `./scripts/format.sh` and `./scripts/validate.sh`.
127127
6. Submit a pull request.
128128

Lines changed: 147 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,149 @@
11
# Slack Cookbook
22

3-
Examples for `interfaces/slack` in AgentOS.
4-
5-
## Files
6-
- `agent_with_user_memory.py` — Agent With User Memory.
7-
- `basic.py` — Basic.
8-
- `basic_workflow.py` — Basic Workflow.
9-
- `channel_summarizer.py` — Channel Summarizer.
10-
- `file_analyst.py` — File Analyst.
11-
- `multiple_instances.py` — Multiple Instances.
12-
- `reasoning_agent.py` — Reasoning Agent.
13-
- `research_assistant.py` — Research Assistant.
14-
- `support_team.py` — Support Team.
15-
16-
## Prerequisites
17-
- Load environment variables with `direnv allow` (requires `.envrc`).
18-
- Run examples with `.venvs/demo/bin/python <path-to-file>.py`.
19-
- Some examples require local services (for example Postgres, Redis, Slack, or MCP servers).
3+
Examples for connecting Agno agents, teams, and workflows to Slack using the
4+
`Slack` interface in AgentOS. Supports both standard request/response and
5+
real-time streaming via Slack's `chat_stream` API.
6+
7+
**Requirements:** `slack_sdk >= 3.40.0` (streaming with plan-mode task cards).
8+
Install or upgrade with `pip install "slack_sdk>=3.40.0"`.
9+
10+
## Slack App Setup
11+
12+
Follow these steps to create and configure a Slack app for use with Agno.
13+
14+
### 1. Create the App
15+
16+
1. Go to https://api.slack.com/apps and click **Create New App**.
17+
2. Choose **From scratch**, give it a name, and select your workspace.
18+
3. On the **Basic Information** page, copy the **Signing Secret** — you'll need it later.
19+
20+
### 2. Enable Agents & AI Apps (required for streaming)
21+
22+
1. In the sidebar, click **Agents & AI Apps**.
23+
2. Toggle **Agent or Assistant** to **On**.
24+
3. Under **Suggested Prompts**, select **Dynamic** (lets the server set prompts via API).
25+
4. Click **Save**.
26+
27+
> Enabling this automatically adds the `assistant:write` scope.
28+
29+
### 3. Add OAuth Scopes
30+
31+
1. In the sidebar, click **OAuth & Permissions**.
32+
2. Scroll to **Scopes > Bot Token Scopes** and add:
33+
34+
| Scope | Purpose |
35+
|-------|---------|
36+
| `app_mentions:read` | Receive @mention events |
37+
| `assistant:write` | Streaming (startStream/appendStream/stopStream) |
38+
| `chat:write` | Send messages and stream responses |
39+
| `im:history` | Read DM history for thread context |
40+
| `channels:history` | Read public channel history |
41+
| `groups:history` | Read private channel history |
42+
| `files:read` | Download files users send to the bot |
43+
| `files:write` | Upload response files (images, docs) |
44+
| `users:read` | Look up user info (for channel_summarizer, etc.) |
45+
| `search:read` | Search workspace messages (research_assistant, support_team, etc.) |
46+
47+
Not all scopes are needed for every example — `app_mentions:read`, `assistant:write`,
48+
`chat:write`, and `im:history` are the minimum for streaming. Each cookbook's docstring
49+
lists the exact scopes it requires.
50+
51+
3. Scroll up and click **Install to Workspace** (or **Reinstall** if updating scopes).
52+
4. Copy the **Bot User OAuth Token** (`xoxb-...`).
53+
54+
### 4. Subscribe to Events
55+
56+
1. In the sidebar, click **Event Subscriptions**.
57+
2. Toggle **Enable Events** to **On**.
58+
3. Set **Request URL** to your tunnel URL + `/slack/events`:
59+
```
60+
https://<your-tunnel>/slack/events
61+
```
62+
Slack will send a challenge request — the server must be running to verify.
63+
4. Under **Subscribe to bot events**, add:
64+
65+
| Event | Purpose |
66+
|-------|---------|
67+
| `app_mention` | Respond to @mentions in channels |
68+
| `message.im` | Respond to direct messages |
69+
| `message.channels` | Respond to messages in public channels |
70+
| `message.groups` | Respond to messages in private channels |
71+
| `assistant_thread_started` | Set suggested prompts when a thread opens |
72+
| `assistant_thread_context_changed` | Update context when thread is moved |
73+
74+
5. Click **Save Changes**.
75+
6. Go to **Install App** and click **Reinstall to Workspace** to apply the new events.
76+
77+
### 5. Set Environment Variables
78+
79+
```bash
80+
export SLACK_TOKEN="xoxb-..." # Bot User OAuth Token from step 3
81+
export SLACK_SIGNING_SECRET="..." # Signing Secret from step 1
82+
export OPENAI_API_KEY="sk-..." # Or whichever model provider you use
83+
```
84+
85+
### 6. Start a Tunnel
86+
87+
Slack needs a public URL to deliver events. Use [ngrok](https://ngrok.com/)
88+
or [cloudflared](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/):
89+
90+
```bash
91+
ngrok http 7777
92+
# or: cloudflared tunnel --url http://localhost:7777
93+
```
94+
95+
Copy the public HTTPS URL and paste it into the Event Subscriptions Request URL
96+
(step 4.3). The free ngrok tier gives you a random subdomain that changes on
97+
restart — update the Request URL each time.
98+
99+
### 7. Run an Example
100+
101+
```bash
102+
.venvs/demo/bin/python cookbook/05_agent_os/interfaces/slack/basic.py
103+
```
104+
105+
DM the bot or @mention it in a channel to test.
106+
107+
## Examples
108+
109+
### Getting Started
110+
111+
- `basic.py` — Minimal agent that responds to @mentions with session history.
112+
- `basic_workflow.py` — Two-step research-then-write workflow.
113+
114+
### Streaming
115+
116+
Streaming is enabled by default. Tokens arrive in real-time and tool calls
117+
render as progress cards in Slack's plan display.
118+
119+
- `streaming_deep_research.py` — Deep research agent with 7 toolkits.
120+
- `reasoning_agent.py` — Agent with step-by-step reasoning display.
121+
122+
### Teams and Workflows
123+
124+
- `support_team.py` — Support team routing to Technical Support or Documentation Specialist.
125+
- `multimodal_team.py` — Team with GPT-4o vision input and DALL-E image output.
126+
- `multimodal_workflow.py` — Parallel visual analysis + web research, then creative synthesis.
127+
128+
### Tools and Features
129+
130+
- `agent_with_user_memory.py` — Agent with MemoryManager that learns about users.
131+
- `channel_summarizer.py` — Agent that reads channel history and summarizes threads.
132+
- `file_analyst.py` — Agent that downloads, analyzes, and uploads files.
133+
- `research_assistant.py` — Agent combining Slack search with web search.
134+
- `multi_bot.py` — Multiple bots with different models in one server.
135+
- `multiple_instances.py` — Two bots on one server with separate credentials.
136+
137+
## Troubleshooting
138+
139+
| Symptom | Cause | Fix |
140+
|---------|-------|-----|
141+
| Bot doesn't respond | Event URL not set or server not running | Check Event Subscriptions shows "Verified" |
142+
| `internal_error` on `chat.appendStream` | "Agents & AI Apps" not enabled, or missing `assistant:write` scope, or app not reinstalled after config changes | 1. Enable "Agents & AI Apps" (step 2). 2. Add `assistant:write` scope (step 3). 3. Reinstall the app to the workspace. |
143+
| Blank streaming bubble | Wrong `recipient_user_id` | Ensure you're using the human user's ID, not the bot's |
144+
| No plan-mode task cards | `slack_sdk` older than 3.40.0 | Run `pip install "slack_sdk>=3.40.0"` |
145+
| No suggested prompts | `assistant_thread_started` event missing | Add it in Event Subscriptions (step 4) |
146+
| Bot only responds to DMs, not channels | Missing `message.channels` event | Add channel events in Event Subscriptions |
147+
| `SLACK_SIGNING_SECRET is not set` | Missing env var | Export `SLACK_SIGNING_SECRET` before running |
148+
| 403 on event webhook | Invalid signing secret | Check the secret matches Basic Information page |
149+
| URL verification fails | Server not running or wrong signing secret | Start the server (step 7) before setting the Request URL |

cookbook/05_agent_os/interfaces/slack/TEST_LOG.md

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

cookbook/05_agent_os/interfaces/slack/agent_with_user_memory.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
Agent With User Memory
33
======================
44
5-
Demonstrates agent with user memory.
5+
A personal assistant that remembers users across conversations using
6+
``MemoryManager``. The agent captures names, hobbies, and preferences,
7+
then uses that context in future chats.
8+
9+
Key concepts:
10+
- ``MemoryManager`` extracts and stores user facts after each run.
11+
- ``update_memory_on_run=True`` triggers automatic memory capture.
12+
- ``memory_capture_instructions`` tell the manager what to look for.
13+
14+
Slack scopes: app_mentions:read, assistant:write, chat:write, im:history
615
"""
716

817
from textwrap import dedent
@@ -28,7 +37,7 @@
2837
Collect Information about the users likes and dislikes,
2938
Collect information about what the user is doing with their life right now
3039
""",
31-
model=Claude(id="claude-3-5-sonnet-20241022"),
40+
model=Claude(id="claude-sonnet-4-20250514"),
3241
)
3342

3443

@@ -44,12 +53,11 @@
4453
memory_manager=memory_manager,
4554
update_memory_on_run=True,
4655
instructions=dedent("""
47-
You are a personal AI friend in a slack chat, your purpose is to chat with the user about things and make them feel good.
48-
First introduce yourself and ask for their name then, ask about themeselves, their hobbies, what they like to do and what they like to talk about.
49-
Use DuckDuckGo search tool to find latest information about things in the conversations
50-
You may sometimes recieve messages prepenned with group message when that is the message then reply to whole group instead of treating them as from a single user
56+
You are a personal AI friend in a Slack chat. Your purpose is to chat with the user and make them feel good.
57+
First introduce yourself and ask for their name, then ask about themselves, their hobbies, what they like to do and what they like to talk about.
58+
Use the web search tool to find the latest information about things in the conversation.
59+
You may sometimes receive messages prepended with "group message" — when that happens, reply to the whole group instead of treating them as from a single user.
5160
"""),
52-
debug_mode=True,
5361
)
5462

5563

cookbook/05_agent_os/interfaces/slack/basic.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
"""
2-
Basic
3-
=====
2+
Basic Slack Agent
3+
=================
44
5-
Demonstrates basic.
5+
Minimal Slack bot that responds only when mentioned in a channel.
6+
Uses SQLite for session persistence so the agent remembers conversation
7+
history across restarts.
8+
9+
Key concepts:
10+
- ``reply_to_mentions_only=True`` ignores DMs and only responds to @mentions.
11+
- ``add_history_to_context=True`` feeds the last N runs back into the prompt.
12+
13+
Slack scopes: app_mentions:read, assistant:write, chat:write, im:history
614
"""
715

816
from agno.agent import Agent

0 commit comments

Comments
 (0)