-
Notifications
You must be signed in to change notification settings - Fork 6
docs: Update messaging-bots for smart defaults + auto-approve behavioral changes #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ flowchart LR | |
|
|
||
| Run all your bots from one command. The Gateway Server manages multiple bot connections and routes messages to the right AI agent. | ||
|
|
||
| **Parity with Bot()**: `praisonai gateway start` now applies the same smart defaults as `praisonai bot start`, resolving the previous "zero tools in daemon mode" issue. Both entry points produce identical behavior with safe tools auto-injected and auto-approval enabled by default. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify whether gateway startup applies Bot smart defaults or channel-level defaults.
# Expected: the gateway agent initialization should call an equivalent of _apply_smart_defaults,
# or explicitly inject safe default tools and auto_approve_tools before registering agents.
rg -n -C10 'Agent\(|tools=agent_def\.get|auto_approve_tools|default_tools|_apply_smart_defaults' --iglob 'server.py'Repository: MervinPraison/PraisonAIDocs Length of output: 8570 🏁 Script executed: # First, check the actual content of line 29 in bot-gateway.mdx
head -n 40 docs/features/bot-gateway.mdx | tail -n 15Repository: MervinPraison/PraisonAIDocs Length of output: 641 🏁 Script executed: # Check full context of agent initialization in gateway server.py around line 1230-1290
sed -n '1230,1290p' praisonai/gateway/server.pyRepository: MervinPraison/PraisonAIDocs Length of output: 2927 🏁 Script executed: # Search for _apply_smart_defaults usage in gateway-related files
rg -n '_apply_smart_defaults' --glob '*gateway*' -A 3 -B 3Repository: MervinPraison/PraisonAIDocs Length of output: 53 🏁 Script executed: # Search for auto_approve_tools in gateway files
rg -n 'auto_approve_tools' --glob '*gateway*' -A 2 -B 2Repository: MervinPraison/PraisonAIDocs Length of output: 53 🏁 Script executed: # Check where agent_tools comes from in the agent creation context
sed -n '1200,1280p' praisonai/gateway/server.py | head -n 100Repository: MervinPraison/PraisonAIDocs Length of output: 4030 🏁 Script executed: # Search for Bot class and _apply_smart_defaults in the codebase
rg -n 'class Bot|def _apply_smart_defaults' -A 5 --glob '*.py'Repository: MervinPraison/PraisonAIDocs Length of output: 7560 🏁 Script executed: # Check what Bot() does for tools and auto_approve_tools
rg -n 'auto_approve_tools|safe.*tools|default.*tools' --glob 'bot.py' -A 2 -B 2Repository: MervinPraison/PraisonAIDocs Length of output: 3006 Remove or correct the smart defaults claim on line 29. Line 29 claims 🤖 Prompt for AI Agents |
||
|
|
||
| ## Quick Start | ||
|
|
||
| <Steps> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,6 +293,84 @@ The streaming bridge hooks into the same `StreamEventEmitter` used by the web ch | |
|
|
||
| --- | ||
|
|
||
| ## Smart Defaults | ||
|
|
||
| Bots ship with sensible defaults so you can start chatting immediately — no tool wiring required. | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| A[🤖 Agent<br/>tools=None] --> SD[⚙️ Smart Defaults] | ||
| SD --> T[🔍 search_web<br/>📅 schedule_*<br/>🧠 memory<br/>📚 learning] | ||
| SD --> AA[✅ auto-approve<br/>for safe tools] | ||
| SD --> H[💬 session history<br/>last 20 messages] | ||
|
|
||
| classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff | ||
| classDef config fill:#6366F1,stroke:#7C90A0,color:#fff | ||
| classDef tools fill:#189AB4,stroke:#7C90A0,color:#fff | ||
| classDef result fill:#10B981,stroke:#7C90A0,color:#fff | ||
|
|
||
| class A agent | ||
| class SD config | ||
| class T tools | ||
| class AA,H result | ||
| ``` | ||
|
|
||
| Both `praisonai bot start` and `praisonai gateway start` apply the same defaults: | ||
|
|
||
| | Default | Applied when | What you get | | ||
| |---------|--------------|--------------| | ||
| | Safe tools | Agent has no `tools` configured | `search_web`, `web_crawl`, `schedule_*`, `store_memory`/`search_memory`, `store_learning`/`search_learning` | | ||
| | Auto-approval | `auto_approve_tools=True` (default) | Tool calls run without CLI prompts — chat bots can't show them anyway | | ||
|
Comment on lines
+318
to
+323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify whether channel-level gateway config is parsed and applied to agent defaults.
# Expected: channel config fields auto_approve_tools/default_tools are read and passed into
# smart-default application before agent registration or bot/channel startup.
rg -n -C10 'auto_approve_tools|default_tools|channels|routes|routing|tools=agent_def\.get|_apply_smart_defaults' --iglob 'server.py' --iglob '*.py'Repository: MervinPraison/PraisonAIDocs Length of output: 50384 🏁 Script executed: #!/bin/bash
set -euo pipefail
# First, find the gateway/server.py file
fd -type f -name "server.py" | grep gateway
# Then examine the specific line ranges mentioned (1230-1280, 1279-1308)
if [ -f "praisonai/gateway/server.py" ]; then
echo "=== Lines 1230-1280 ==="
sed -n '1230,1280p' praisonai/gateway/server.py | cat -n
echo ""
echo "=== Lines 1279-1310 ==="
sed -n '1279,1310p' praisonai/gateway/server.py | cat -n
fiRepository: MervinPraison/PraisonAIDocs Length of output: 241 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Search for where agents are created in gateway and how config is applied
# Look for agent instantiation patterns and config handling
rg -n "agent_defs|channel.*config|auto_approve|default_tools|_apply_smart_defaults" praisonai/gateway/server.py | head -100Repository: MervinPraison/PraisonAIDocs Length of output: 320 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check file size first
wc -l praisonai/gateway/server.py || echo "File not found"Repository: MervinPraison/PraisonAIDocs Length of output: 103 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Read the specific lines mentioned in the review
echo "=== Lines 1230-1280 ==="
sed -n '1230,1280p' praisonai/gateway/server.py
echo ""
echo "=== Lines 1279-1320 ==="
sed -n '1279,1320p' praisonai/gateway/server.pyRepository: MervinPraison/PraisonAIDocs Length of output: 4079 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the _create_bot method to understand how agents are instantiated
rg -n "_create_bot" praisonai/gateway/server.py -A 30 | head -80Repository: MervinPraison/PraisonAIDocs Length of output: 2445 🏁 Script executed: #!/bin/bash
set -euo pivefail
# Search for Bot() instantiation to see what parameters are passed
rg -n "Bot\(" praisonai/gateway/server.py -B 3 -A 5 | head -100Repository: MervinPraison/PraisonAIDocs Length of output: 124 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Look for Bot() instantiation in bots module to see what parameters it accepts
rg -n "class.*Bot|def __init__" praisonai/bots/ -A 15 | grep -A 15 "auto_approve\|default_tools" | head -50Repository: MervinPraison/PraisonAIDocs Length of output: 53 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check what the config object passed to Bot() contains
# Search for how gateway config is structured and passed to bots
rg -n "self.config|config\.get|_apply_smart_defaults|auto_approve_tools|default_tools" praisonai/gateway/server.pyRepository: MervinPraison/PraisonAIDocs Length of output: 1475 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Look at the Bot class initialization to see what parameters it accepts
rg -n "class Bot" praisonai/bots/__init__.py -A 30 | head -60Repository: MervinPraison/PraisonAIDocs Length of output: 53 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find if there's any smart defaults application in the gateway initialization
rg -n "smart.*default|_apply_smart_defaults" praisonai/ -r 2>/dev/null | head -20Repository: MervinPraison/PraisonAIDocs Length of output: 53 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the Bot class definition to understand what parameters it accepts
find praisonai -name "*.py" -type f | xargs grep -l "^class Bot" | head -5Repository: MervinPraison/PraisonAIDocs Length of output: 204 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check the bots module structure
ls -la praisonai/bots/ 2>/dev/null || echo "Directory not found"
# Look for where auto_approve_tools might be defined
rg -n "auto_approve_tools|default_tools" praisonai/ --type py | head -30Repository: MervinPraison/PraisonAIDocs Length of output: 4615 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check if channel config in gateway.yaml gets passed to agent or bot
# Look at _create_bot signature and how ch_cfg (channel config) is used
sed -n '1413,1470p' praisonai/gateway/server.pyRepository: MervinPraison/PraisonAIDocs Length of output: 2723 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check the Bot class __init__ to see what it does with config parameter
sed -n '1,250p' praisonai/bots/bot.py | cat -nRepository: MervinPraison/PraisonAIDocs Length of output: 10852 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check how gateway config is constructed and whether channel config is merged in
# Look at the initialization of gateway config and how it's passed down
rg -n "GatewayConfig|self.config.*=" praisonai/gateway/server.py | head -40Repository: MervinPraison/PraisonAIDocs Length of output: 406 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check if channel config (ch_cfg) is ever merged with gateway config before Bot creation
sed -n '1300,1430p' praisonai/gateway/server.py | cat -nRepository: MervinPraison/PraisonAIDocs Length of output: 6704 Don't advertise gateway/channel-level smart defaults unless gateway config consumes them. The documentation claims that channel-level Also applies to: 1279-1308 🤖 Prompt for AI Agents |
||
| | Session history | Agent has no `memory` configured | Last 20 messages remembered per user, zero-dep | | ||
|
Comment on lines
+320
to
+324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ### Opting out | ||
|
|
||
| | Goal | How | | ||
| |------|-----| | ||
| | Run with **zero** tools | Set `tools: []` explicitly in YAML, or pass `tools=[]` to `Agent` | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation suggests that passing |
||
| | Require manual approval | Set `auto_approve_tools: false` in the channel config | | ||
| | Override the tool list | Set `default_tools: [...]` under the channel — destructive tools are still filtered | | ||
|
|
||
| <Warning> | ||
| Destructive tools (`execute_command`, `delete_file`, `write_file`, `shell_command`) are **never auto-injected**, even if you add them to `default_tools`. Wire them explicitly on the agent and add a chat-level approval flow. | ||
|
Comment on lines
+322
to
+335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify BotConfig defaults and smart-default semantics.
# Expected for these docs to be accurate:
# - auto_approve_tools defaults to True
# - default_tools excludes execute_command and other dangerous tools
# - _apply_smart_defaults distinguishes missing tools from explicit tools=[]
# - dangerous tools are filtered before auto-injection
rg -n -C4 'default_tools|auto_approve_tools' --iglob 'config.py'
rg -n -C8 'def _apply_smart_defaults|if not agent\.tools|agent\.tools\.extend|auto_approve_tools|DEFAULT_DANGEROUS_TOOLS' --iglob 'bot.py' --iglob 'registry.py'Repository: MervinPraison/PraisonAIDocs Length of output: 9242 🏁 Script executed: # See full _apply_smart_defaults method and related tool injection/filtering logic
rg -n -A30 'def _apply_smart_defaults' praisonai/bots/bot.py
# Check if tools are extended or filtered during smart defaults
rg -n -A20 'agent\.tools\s*=' praisonai/bots/bot.py
# Look for dangerous tool filtering logic
rg -n 'DANGEROUS_TOOLS|dangerous.*tool|filter.*tool' --iglob 'bot.py'Repository: MervinPraison/PraisonAIDocs Length of output: 3418 🏁 Script executed: sed -n '136,210p' praisonai/bots/bot.pyRepository: MervinPraison/PraisonAIDocs Length of output: 3833 🏁 Script executed: # Find tool profiles definition
rg -n -A20 'resolve_profiles|def resolve_profiles' --iglob 'profiles.py'
# Check all references to default_tools from BotConfig
rg -n 'default_tools' --iglob 'bot.py' --iglob 'adapter' --iglob 'gateway'
# Verify if BotConfig.default_tools is used in the channel config
rg -n -B5 -A5 'default_tools.*:' docs/features/messaging-bots.mdxRepository: MervinPraison/PraisonAIDocs Length of output: 6018 🏁 Script executed: # Find BUILTIN_PROFILES definition
rg -n -A100 'BUILTIN_PROFILES' praisonaiagents/tools/profiles.py | head -150Repository: MervinPraison/PraisonAIDocs Length of output: 5306 Update documented defaults and correct tool opt-out semantics. These lines document
Channel-level 🤖 Prompt for AI Agents |
||
| </Warning> | ||
|
|
||
| <Info> | ||
| Upgrading from an older release? `auto_approve_tools` used to default to `False`. If your bot relied on manual approval, set `auto_approve_tools: false` explicitly. | ||
| </Info> | ||
|
|
||
| ```python | ||
| from praisonaiagents import Agent | ||
| from praisonai.bots import Bot | ||
|
|
||
| # Zero config — gets search_web, schedule_*, memory, learning, and auto-approval | ||
| agent = Agent(name="assistant", instructions="Help the user") | ||
| bot = Bot("telegram", agent=agent) | ||
| bot.run() | ||
| ``` | ||
|
|
||
| ```bash | ||
| # Same result — no YAML tool list needed | ||
| praisonai bot telegram --token $TELEGRAM_BOT_TOKEN | ||
| ``` | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant U as 👤 User (Telegram) | ||
| participant B as 🤖 Bot | ||
| participant A as 🧠 Agent | ||
| participant T as 🔍 search_web | ||
|
|
||
| U->>B: "What's the latest on Llama 4?" | ||
| B->>A: Forward message (no tool prompt) | ||
| A->>T: auto-approved call | ||
| T-->>A: Results | ||
| A-->>B: Answer | ||
| B-->>U: 📰 Here's the latest... | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Socket Mode vs Webhook | ||
|
|
||
| PraisonAI bots support two connection modes: | ||
|
|
@@ -345,7 +423,7 @@ config = BotConfig( | |
| reply_in_thread=False, # Reply in threads (default: inline) | ||
| thread_threshold=500, # Auto-thread if response > N chars (0 = disabled) | ||
| group_policy="mention_only", # Group chat policy: respond_all, mention_only, command_only | ||
| auto_approve_tools=False, # Auto-approve tool executions (skip confirmation) | ||
| auto_approve_tools=True, # Auto-approve safe tool executions (default: True for chat bots) | ||
| ) | ||
| ``` | ||
|
|
||
|
|
@@ -363,8 +441,8 @@ config = BotConfig( | |
| | `reply_in_thread` | `bool` | `False` | Always reply in threads | | ||
| | `thread_threshold` | `int` | `500` | Auto-thread responses longer than N chars (0 = disabled) | | ||
| | `group_policy` | `str` | `"mention_only"` | Group chat behavior: `respond_all`, `mention_only`, or `command_only` | | ||
| | `default_tools` | `list` | `["execute_command", ...]` | Default tools enabled for all bots | | ||
| | `auto_approve_tools` | `bool` | `False` | Skip tool execution confirmation (for trusted environments) | | ||
| | `default_tools` | `list[str]` | `["search_web", "web_crawl", "schedule_add", "schedule_list", "schedule_remove", "store_memory", "search_memory", "store_learning", "search_learning"]` | Safe tools auto-injected when the agent has no tools configured. Destructive tools (`execute_command`, `delete_file`, `write_file`, `shell_command`) are excluded from auto-injection even if listed. | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a discrepancy between the |
||
| | `auto_approve_tools` | `bool` | `True` | Skip confirmation for safe tool execution. Chat bots can't show CLI approval prompts, so this defaults to `True`. Set `False` to require approval (only useful if you wire a chat-level approval flow). | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation states that |
||
| | `retry_attempts` | `int` | `3` | Number of retry attempts for failed operations | | ||
| | `polling_interval` | `float` | `1.0` | Interval for polling mode (seconds) | | ||
|
|
||
|
|
@@ -1198,6 +1276,10 @@ channels: | |
| slack: | ||
| token: "${SLACK_BOT_TOKEN}" | ||
| app_token: "${SLACK_APP_TOKEN}" | ||
| auto_approve_tools: true # NEW (default: true for chat bots) | ||
| # default_tools: # NEW — override the safe tool list per channel | ||
| # - search_web | ||
| # - store_memory | ||
| routing: | ||
| dm: "personal" | ||
| channel: "support" | ||
|
|
@@ -1223,6 +1305,8 @@ channels: | |
| praisonai gateway --config gateway.yaml | ||
| ``` | ||
|
|
||
| The gateway now produces identical results to `Bot()` — agents get the same safe tools and auto-approval in both entry points. | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| T[Telegram]:::platform --> GW[Gateway]:::tool | ||
|
|
@@ -1265,6 +1349,8 @@ agent: | |
| praisonai bot start --config bot.yaml | ||
| ``` | ||
|
|
||
| > **Tip:** You can omit `tools:` entirely — the bot auto-injects safe defaults (`search_web`, schedule, memory, learning). Keep `tools: []` only if you want the bot to run with zero tools. | ||
|
|
||
| <Tip> | ||
| The `.env` file in the current directory is auto-loaded, so you can store tokens there and reference them with `${VAR_NAME}` syntax. | ||
| </Tip> | ||
|
|
@@ -1345,6 +1431,14 @@ Web mode uses a reverse-engineered protocol. Your number may be banned by Meta. | |
| <Accordion title="Handle rate limits gracefully"> | ||
| Configure `retry_attempts` and implement exponential backoff for API rate limits. | ||
| </Accordion> | ||
|
|
||
| <Accordion title="Safe default tools only"> | ||
| The default tool list is intentionally safe (`search_web`, `schedule_*`, memory/learning). Tools like `execute_command` require explicit opt-in and should be paired with an approval backend. See [Approval Protocol](/features/approval-protocol). | ||
| </Accordion> | ||
|
|
||
| <Accordion title="Set approval flow for auto-approve disabled"> | ||
| Only set `auto_approve_tools: false` if you've wired a chat-level approval flow (e.g. `SlackApproval`). Otherwise tool calls will hang silently waiting for a CLI prompt the user cannot see. | ||
| </Accordion> | ||
| </AccordionGroup> | ||
|
|
||
| ## Multi-Agent Configuration | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The claim that
praisonai gateway startnow applies the same smart defaults asBot()is not reflected in the implementation ofpraisonai/gateway/server.py. The gateway server instantiates bots using platform-specific adapters (e.g.,TelegramBot) directly and does not appear to invoke the_apply_smart_defaultslogic found in theBotwrapper class. This means features like auto-injected safe tools and session history might be missing when running via the gateway.