Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9494b91
feat(talon): add Telegram channel adapter, CLI wiring, and offset per…
Jun 20, 2026
3004cf1
fix(talon): harden Telegram channel media handling
Jun 20, 2026
acd9fed
fix(talon): process Telegram channel posts and allowlisted users
Jun 20, 2026
e346227
docs(talon): rename Docker example for Telegram
Jun 20, 2026
d2b727d
test(talon): wait for Telegram media dispatch
Jun 20, 2026
6ae8b69
fix(talon): address Telegram review feedback
Jun 20, 2026
b7f0b38
docs(talon): clarify local Talon commands
Jun 20, 2026
7a5781e
fix(talon): support `/new` command for channel threads
Jun 20, 2026
d9148d9
fix(talon): cap channel media size
Jun 20, 2026
0b6fe25
fix(talon): clamp WhatsApp media cap
Jun 20, 2026
7ea89d8
refactor(talon): share channel exposure and media helpers
Jun 20, 2026
4f3a6e4
refactor(talon): simplify Telegram outbound text
Jun 20, 2026
333e190
fix(talon): support multiple operator ids
Jun 20, 2026
1b20fd3
chore(talon): reduce Telegram adapter PR size
Jun 20, 2026
9e77d99
fix(talon): normalize Telegram voice suffixes
Jun 21, 2026
4eca0b7
refactor(talon): reduce duplicate code across channel adapters
Jun 21, 2026
776e6cb
fix(talon): resolve ty type errors and OpenSWE Telegram API error han…
Jun 21, 2026
f539d35
fix(talon): namespace channel conversation state
Jun 21, 2026
f806c15
fix(talon): share channel media roots
Jun 21, 2026
f507c9c
refactor(talon): remove dead and redundant
Jun 21, 2026
ddaab98
refactor(talon): move filter_capped_media_paths to whatsapp.py and in…
Jun 21, 2026
3fd15d2
refactor(talon): inline dispatch_message in telegram _dispatch and re…
Jun 21, 2026
d7bea1c
refactor(talon): deduplicate send_media, eliminate double stat, inlin…
Jun 21, 2026
42c54da
refactor(talon): unify conversation-root methods and prevent _convers…
Jun 21, 2026
a07ce15
refactor(talon): deduplicate parse_float/parse_int, hoist error messa…
Jun 21, 2026
877603e
fix(talon): remove dead bridge.js fallback and catch per-update netwo…
Jun 21, 2026
5b77d3f
style(talon): fix ruff lint errors in base.py and host.py
Jun 21, 2026
ea93a5f
style(talon): format logger.debug call in _message_values
Jun 21, 2026
511840e
fix(talon): fix conversation key mismatch, double stat, add sendVideo…
Jun 22, 2026
e6169c4
refactor(talon): deduplicate dispatch, validate_response, media keys,…
Jun 22, 2026
eed9125
refactor(talon): reduce over-engineering in channel adapters
Jun 22, 2026
bcbc5be
fix(talon): batch offset writes and harden Telegram parsing
Jun 22, 2026
26da2d5
fix(talon): update tests for refactored channel adapters
Jun 22, 2026
c1ecb1e
refactor(talon): add SendResult, promote send_typing, expand media_ty…
Jun 22, 2026
c5ab847
style(talon): fix ruff format in whatsapp, host, and media modules
Jun 22, 2026
09e772a
fix(talon): treat `None` return from legacy channel adapters as succe…
Jun 22, 2026
0c923e7
refactor(talon): make module-internal symbols private and unify media…
Jun 22, 2026
34868dd
fix(talon): catch transport exceptions in send_with_retry
Jun 22, 2026
2180ccd
reorg
Jun 22, 2026
05f3206
refactor(talon): generalize example for both WhatsApp and Telegram ch…
Jun 22, 2026
9168207
Update libs/talon/deepagents_talon/channels/base.py
jkennedyvz Jun 22, 2026
9abbc5f
refactor(talon): move dataclass Args blocks to attribute docstrings
Jun 22, 2026
8e4e076
fix(talon): preserve agent memory across container restarts
Jun 23, 2026
c42e9be
feat(talon): add Telegram video media handling
Jun 24, 2026
a23679c
chore(talon): consolidate optional media extra
Jun 24, 2026
5d6e30f
chore(talon): revert optional media extra
Jun 24, 2026
f104843
feat(talon): transcribe audio from video and audio document media
Jun 24, 2026
68961c5
refactor(talon): simplify audio/video media settings
Jun 24, 2026
6e3f3fa
Merge branch 'main' into jk/talon/telegram-channel-adapter
mdrxy Jun 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ services:
talon:
build:
context: ../..
dockerfile: examples/talon-whatsapp/Dockerfile
image: deepagents-talon-whatsapp:local
dockerfile: examples/talon/Dockerfile
image: deepagents-talon:local
working_dir: /workspace
env_file:
- .env
Expand All @@ -14,7 +14,7 @@ services:
DEEPAGENTS_TALON_VOICE_TRANSCRIPTION_ENABLED: ${DEEPAGENTS_TALON_VOICE_TRANSCRIPTION_ENABLED:-true}
DEEPAGENTS_TALON_VOICE_TRANSCRIPTION_DEVICE: ${DEEPAGENTS_TALON_VOICE_TRANSCRIPTION_DEVICE:-cpu}
volumes:
- ${HOME}/agent-workspace:/workspace
- ${HOME}/talon-workspace:/workspace
command: >
bash -c "
mkdir -p /workspace/.deepagents/$${AGENT_ASSISTANT_ID}/agent &&
Expand Down
42 changes: 38 additions & 4 deletions libs/talon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ Talon currently includes:

## Quickstart

Run the commands in this README from `libs/talon`. From the repository root,
prefix `uv` commands with `--directory libs/talon`.

```bash
cd libs/talon
uv sync --group test
AGENT_ASSISTANT_ID=local AGENT_MODEL=openai:gpt-5.2 uv run deepagents-talon --once
AGENT_ASSISTANT_ID=local AGENT_MODEL=<provider>:<model-id> uv run deepagents-talon --once
```

If `AGENT_MODEL` is unset, Talon starts with the echo runtime. This is useful for checking host lifecycle and channel wiring without provider credentials.
Expand Down Expand Up @@ -59,11 +63,11 @@ cd ../../..
DEEPAGENTS_TALON_WHATSAPP_ENABLED=true \
DEEPAGENTS_TALON_WHATSAPP_START_BRIDGE=true \
AGENT_ASSISTANT_ID=whatsapp-local \
AGENT_MODEL=openai:gpt-5.2 \
AGENT_MODEL=<provider>:<model-id> \
uv run deepagents-talon --whatsapp
```

The bridge prints a QR code during pairing. By default, inbound exposure is `self`, so only messages from the paired account trigger the agent. Configure `DEEPAGENTS_TALON_WHATSAPP_EXPOSURE=allowlist` with `DEEPAGENTS_TALON_WHATSAPP_ALLOWLIST_CHATS` or `DEEPAGENTS_TALON_WHATSAPP_MENTION_PATTERNS` to allow specific chats. Outbound WhatsApp messages include a `deepagents bot` header by default so self-message conversations clearly distinguish agent replies from operator messages. Set `DEEPAGENTS_TALON_WHATSAPP_BOT_HEADER` to customize that label. Markdown image/video references in assistant replies may attach files only when they are relative paths inside `DEEPAGENTS_TALON_OUTBOUND_MEDIA_DIR`, or inside `DEEPAGENTS_TALON_WORKSPACE` when no outbound media directory is configured.
The bridge prints a QR code during pairing. By default, inbound exposure is `self`, so only messages from the paired account trigger the agent. Configure `DEEPAGENTS_TALON_WHATSAPP_EXPOSURE=allowlist` with `DEEPAGENTS_TALON_WHATSAPP_ALLOWLIST_CHATS` or `DEEPAGENTS_TALON_WHATSAPP_MENTION_PATTERNS` to allow specific chats. `DEEPAGENTS_TALON_WHATSAPP_OPERATOR_ID` accepts one or more comma-separated operator IDs for `self` exposure. Outbound WhatsApp messages include a `deepagents bot` header by default so self-message conversations clearly distinguish agent replies from operator messages. Set `DEEPAGENTS_TALON_WHATSAPP_BOT_HEADER` to customize that label. Markdown image/video references in assistant replies may attach files only when they are relative paths inside `DEEPAGENTS_TALON_OUTBOUND_MEDIA_DIR`, or inside `DEEPAGENTS_TALON_WORKSPACE` when no outbound media directory is configured. `DEEPAGENTS_TALON_MAX_MEDIA_BYTES` caps inbound and outbound channel media across providers and defaults to `1073741824` (1 GiB), but WhatsApp is clamped to `67108864` (64 MiB) because the bridge library materializes downloads in memory before writing them.

Inbound voice transcription is opt-in:

Expand All @@ -82,6 +86,36 @@ DEEPAGENTS_TALON_WHATSAPP_OPEN_ACK=allow-arbitrary-senders

See `../../examples/talon-whatsapp/` for a runnable Docker Compose topology and `.env` reference.

## Telegram

The Telegram channel uses the Bot API with long polling. Provide a bot token from BotFather and either a model or Fleet export so Talon runs the real Deep Agents runtime instead of the echo runtime:

```bash
DEEPAGENTS_TALON_TELEGRAM_ENABLED=true \
DEEPAGENTS_TALON_TELEGRAM_BOT_TOKEN=... \
DEEPAGENTS_TALON_TELEGRAM_EXPOSURE=allowlist \
DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_USERS=123456789 \
DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_CHATS=-1001234567890 \
AGENT_ASSISTANT_ID=telegram-local \
AGENT_MODEL=<provider>:<model-id> \
uv run deepagents-talon --telegram
```

From the repository root, run the same host with:

```bash
DEEPAGENTS_TALON_TELEGRAM_ENABLED=true \
DEEPAGENTS_TALON_TELEGRAM_BOT_TOKEN=... \
DEEPAGENTS_TALON_TELEGRAM_EXPOSURE=allowlist \
DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_USERS=123456789 \
DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_CHATS=-1001234567890 \
AGENT_ASSISTANT_ID=telegram-local \
AGENT_MODEL=<provider>:<model-id> \
uv run --directory libs/talon deepagents-talon --telegram
```

In `allowlist` mode, `DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_USERS` allows private bot DMs from specific Telegram user IDs, while `DEEPAGENTS_TALON_TELEGRAM_ALLOWLIST_CHATS` allows channel posts from specific channel chat IDs. `DEEPAGENTS_TALON_TELEGRAM_OPERATOR_ID` accepts one or more comma-separated operator IDs for `self` exposure. `DEEPAGENTS_TALON_MAX_MEDIA_BYTES` caps inbound and outbound channel media across providers and defaults to `1073741824` (1 GiB); Telegram's smaller Bot API upload limits still apply. If `AGENT_MODEL`, `DEEPAGENTS_TALON_MODEL`, and `DEEPAGENTS_TALON_FLEET_DIR` are all unset, Talon uses the echo runtime and replies with the inbound text unchanged.

## Tracing

LangSmith tracing is opt-in. Set both values before starting the host:
Expand Down Expand Up @@ -143,7 +177,7 @@ Sensitive local state is stored under `~/.deepagents/<assistant_id>/` by default

- `cron/jobs.json` stores cron prompts, origin conversation ids, message ids, run status, and errors. Active jobs are retained while enabled. Completed jobs are deleted on startup after `DEEPAGENTS_TALON_CRON_RETENTION_DAYS`, default `30`.
- `channels/whatsapp/` stores WhatsApp `LocalAuth` credentials and Chromium profile state. These credentials are retained until the operator deletes the directory, because automatic deletion would silently unpair the channel.
- `media/inbound/` is reserved for downloaded inbound media. Files older than `DEEPAGENTS_TALON_INBOUND_MEDIA_RETENTION_HOURS`, default `24`, are deleted on startup. The WhatsApp bridge stores downloaded inbound media under the assistant's inbound media directory and passes local paths plus MIME metadata to the host.
- `media/inbound/` is reserved for downloaded inbound media. Files older than `DEEPAGENTS_TALON_INBOUND_MEDIA_RETENTION_HOURS`, default `24`, are deleted on startup. Inbound and outbound channel media are capped by `DEEPAGENTS_TALON_MAX_MEDIA_BYTES`, default `1073741824` (1 GiB); WhatsApp is further clamped to `67108864` (64 MiB). The WhatsApp bridge stores downloaded inbound media under the assistant's inbound media directory and passes local paths plus MIME metadata to the host.

Conversation persistence is intentionally not durable yet. Runtime conversation state is in-memory unless a future backend explicitly adds thread persistence.

Expand Down
2 changes: 2 additions & 0 deletions libs/talon/deepagents_talon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ChannelMessage,
ChannelStatus,
CronScheduler,
SendResult,
ToolApprovalDecision,
ToolApprovalHandler,
ToolApprovalRequest,
Expand Down Expand Up @@ -58,6 +59,7 @@
"OpenAIVoiceTranscriber",
"PersistentCronScheduler",
"RuntimeAgentComponents",
"SendResult",
"TalonConfig",
"TalonHost",
"ToolApprovalDecision",
Expand Down
43 changes: 33 additions & 10 deletions libs/talon/deepagents_talon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
from typing import TYPE_CHECKING

from deepagents_talon.channels.telegram import TelegramChannel, TelegramChannelConfig
from deepagents_talon.channels.whatsapp import WhatsAppChannel, WhatsAppChannelConfig
from deepagents_talon.config import TalonConfig
from deepagents_talon.cron import CronJobStore, PersistentCronScheduler
Expand All @@ -28,7 +29,7 @@
from deepagents_talon.speech import build_voice_transcriber

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Mapping, Sequence

from deepagents_talon.cron import CronJob
from deepagents_talon.interfaces import ChannelAdapter
Expand All @@ -49,6 +50,11 @@ def main() -> None:
action="store_true",
help="Attach the WhatsApp channel adapter.",
)
parser.add_argument(
"--telegram",
action="store_true",
help="Attach the Telegram channel adapter.",
)
subparsers = parser.add_subparsers(dest="command")
_add_mcp_parsers(subparsers)
args = parser.parse_args()
Expand All @@ -64,7 +70,7 @@ def main() -> None:
config.ensure_home()
cleanup_sensitive_state(config=config, cron_store=cron_store)

channels = _channels(config, enabled=args.whatsapp)
channels = _channels(config, whatsapp=args.whatsapp, telegram=args.telegram)
host = TalonHost(
config=config,
agent=asyncio.run(_agent_runtime(config, cron_store)),
Expand Down Expand Up @@ -186,14 +192,31 @@ async def _run_once(host: TalonHost) -> None:
await host.stop()


def _channels(config: TalonConfig, *, enabled: bool) -> tuple[ChannelAdapter, ...]:
if not enabled and config.env.get("DEEPAGENTS_TALON_WHATSAPP_ENABLED", "").lower() not in {
"1",
"true",
"yes",
}:
return ()
return (WhatsAppChannel(WhatsAppChannelConfig.from_talon_config(config)),)
def _channels(
config: TalonConfig,
*,
whatsapp: bool = False,
telegram: bool = False,
) -> tuple[ChannelAdapter, ...]:
channels: list[ChannelAdapter] = []
if whatsapp or _env_enabled(config.env, "DEEPAGENTS_TALON_WHATSAPP_ENABLED"):
channels.append(WhatsAppChannel(WhatsAppChannelConfig.from_talon_config(config)))
if telegram or _env_enabled(config.env, "DEEPAGENTS_TALON_TELEGRAM_ENABLED"):
channels.append(TelegramChannel(TelegramChannelConfig.from_talon_config(config)))
return tuple(channels)


def _env_enabled(env: Mapping[str, str], key: str) -> bool:
"""Check whether a boolean environment flag is truthy.

Args:
env: Environment variable mapping.
key: Environment variable name.

Returns:
`True` when the value is one of ``1``, ``true``, or ``yes``.
"""
return env.get(key, "").lower() in {"1", "true", "yes"}


def _runtime_env(config: TalonConfig) -> dict[str, str]:
Expand Down
8 changes: 8 additions & 0 deletions libs/talon/deepagents_talon/channels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@
ExposureMode,
chunk_text,
format_markdown_for_channel,
send_with_retry,
validate_media,
)
from deepagents_talon.channels.telegram import TelegramChannel, TelegramChannelConfig
from deepagents_talon.channels.whatsapp import WhatsAppChannel, WhatsAppChannelConfig

__all__ = [
"ChannelExposure",
"ChannelMediaError",
"ExposureMode",
"TelegramChannel",
"TelegramChannelConfig",
"WhatsAppChannel",
"WhatsAppChannelConfig",
"chunk_text",
"format_markdown_for_channel",
"send_with_retry",
"validate_media",
]
Loading