Python: add agent-framework-hosting-discord channel#6081
Python: add agent-framework-hosting-discord channel#6081eavanvalkenburg wants to merge 2 commits into
Conversation
Add an alpha agent-framework-hosting-discord package backed by Discord HTTP Interactions. The channel verifies signed slash-command requests, registers commands, runs hosted agents and ChannelCommand handlers, supports originating response hooks, streams by editing the original interaction response, and can push through Discord channel ids. Factor standard channel response-hook context application into hosting core so both host fan-out and originating channel replies use one helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 87%
✓ Correctness
The Discord channel implementation is well-structured and the
apply_channel_response_hookhost refactoring is correct. One correctness issue found: during streaming, intermediate edits send accumulated text to Discord without respecting the 2000-character message limit, which will cause a RuntimeError crash when streaming responses exceed that threshold.
✓ Security Reliability
The Discord channel implementation is well-structured from a security perspective. Ed25519 signature verification is correctly applied before JSON parsing, body size limits are enforced, command names are validated with a strict regex, and secrets (bot_token) are not logged. The interaction token is used only in authenticated webhook paths. Resource lifecycle (httpx client, background tasks) is properly managed with startup/shutdown hooks. No significant security or reliability issues found.
✓ Test Coverage
The test suite for the new Discord channel is comprehensive, covering the main agent command flow, streaming, push, command registration, signature verification, validation, hooks, and chunking. The
apply_channel_response_hookhelper also has solid coverage. A few meaningful code paths lack test coverage: the DM-interaction identity extraction fallback (whereinteraction.useris used instead ofinteraction.member.user), the exception-handling path in_dispatch_application_commandthat edits an error message before re-raising, and the streaming edit throttle with a positiveedit_interval. None of these are blocking, but they represent real behavioral gaps.
✓ Design Approach
The overall shape looks sound, but the Discord transport currently applies its 200-character chunking strategy inconsistently. Long
/askfinal replies and proactive pushes are split correctly, while streamed intermediate edits andChannelCommandContext.reply()responses still send oversized single-message bodies, so those paths will fail once content grows past Discord's own limit.
Automated review by eavanvalkenburg's agents
Ensure Discord command replies are chunked and streaming preview edits stay under Discord's content limit while final streamed replies continue through the chunked reply path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Motivation and Context
Adds a Discord channel package for the Python hosting work, validating the shared Channel abstractions with a real HTTP Interactions transport, slash commands, identity/session extraction, push, response hooks, and streaming edits.
Description
Adds
agent-framework-hosting-discordas an alpha package. The channel:/discord/interactionstimestamp + raw_bodybefore JSON parsing/ask prompt:<text>to the hosted agent and maps configuredChannelCommands to Discord slash commandsdiscord:<guild-or-dm>:<channel_id>:<user_id>identity.attributes["channel_id"]Also factors the common channel response-hook context/application boilerplate into hosting core as
apply_channel_response_hook, so host fan-out and originating channel replies use the same helper.Stack
PR-8 of 10. Depends on #PR-2 (
feat/hosting-core). Independent of the other channel PRs; the samples PR remains the final PR in the stack.refactor/foundry-hosted-agent-history-providerfoundry_hosted_agent/feat/hosting-corefeat/hosting-channel-responsesfeat/hosting-channel-invocationsfoundry_hosted_agent/,local_identity_link/feat/hosting-channel-activity-protocollocal_identity_link/feat/hosting-channel-teamsfeat/hosting-channel-telegramlocal_telegram/,local_identity_link/feat/hosting-entra-helperslocal_identity_link/feat/hosting-channel-discordfeat/hosting-samplesContribution Checklist