feat(channel): add message send retry mechanism with exponential backoff

- Add send_max_retries config option (default: 3, range: 0-10)
- Implement _send_with_retry in ChannelManager with 1s/2s/4s backoff
- Propagate CancelledError for graceful shutdown
- Fix telegram send_delta to raise exceptions for Manager retry
- Add comprehensive tests for retry logic
- Document channel settings in README
This commit is contained in:
chengyongru
2026-03-25 22:37:11 +08:00
committed by Xubin Ren
parent 3f71014b7c
commit 5e9fa28ff2
6 changed files with 707 additions and 12 deletions
+32
View File
@@ -1157,6 +1157,38 @@ That's it! Environment variables, model routing, config matching, and `nanobot s
</details>
### Channel Settings
Global settings that apply to all channels. Configure under the `channels` section in `~/.nanobot/config.json`:
```json
{
"channels": {
"sendProgress": true,
"sendToolHints": false,
"sendMaxRetries": 3,
"telegram": { ... }
}
}
```
| Setting | Default | Description |
|---------|---------|-------------|
| `sendProgress` | `true` | Stream agent's text progress to the channel |
| `sendToolHints` | `false` | Stream tool-call hints (e.g. `read_file("…")`) |
| `sendMaxRetries` | `3` | Max retry attempts for message send failures (0-10) |
#### Retry Behavior
When a message fails to send, nanobot will automatically retry with exponential backoff:
- **Attempts 1-3**: Retry delays are 1s, 2s, 4s
- **Attempts 4+**: Retry delay caps at 4s
- **Transient failures** (network hiccups, temporary API limits): Retry usually succeeds
- **Permanent failures** (invalid token, channel banned): All retries fail
> [!NOTE]
> When a channel is completely unavailable, there's no way to notify the user since we cannot reach them through that channel. Monitor logs for "Failed to send to {channel} after N attempts" to detect persistent delivery failures.
### Web Search