Repository navigation
Discord assistant: ask Factory about the codebase, then file issues or open PRs from a thread - #54
Merged
Merged
Conversation
…posals Maintainers mention the bot in a Discord thread to ask about the codebase. A Gateway Durable Object receives mentions from allowed roles; a per-thread coordinator runs jobs in order; a workflow keeps one sandbox per thread (sleeps after an hour, rebuilt on demand) and one durable agent conversation. The agent can propose an issue or a pull request; maintainers confirm with buttons on the HTTP interactions endpoint (signature and role checked). Trusted code files issues, or commits, pushes, and opens pull requests and hands them to the author and reviewer personas.
matthewp
marked this pull request as ready for review
October 7, 2026 20:54
This was referenced Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
@Astro Factory where does this get normalized?), and Factory answers using a checkout of the repository. A mention in a regular channel starts a thread from that message. Only members with a role inDISCORD_ALLOWED_ROLE_IDScan use it; everyone else is ignored silently, so the bot can't be used to burn tokens.DiscordGatewayis a single Durable Object holding that connection, with heartbeats and session resume. A one-minute cron trigger plus the object's own alarm reconnect it after deploys or drops. The protocol logic is ingateway-connection.ts, kept separate from the Durable Object so it can be tested.DiscordAssistantagent conversation and one sandbox. The sandbox reuses triage's checkout, install, and build; it sleeps after an hour idle and is rebuilt on the next mention.DiscordThreadCoordinatorruns a thread's jobs in order. Mentions that arrive while it's busy are answered together in the next turn; approved PRs are never dropped./channels/discord/interactions(@flue/discordverifies the signature), where the clicker's role is checked again. The proposal is claimed in the coordinator, so it's acted on only once. After approval, the agent implements the change onfactory/discord-<id>. Factory's own code then commits, pushes, and opens the PR, and hands it to the author and reviewer personas. The agent never holds GitHub or Discord credentials.discordsection infactory.yml(enabled,skill,model,thinkingLevel), on by default; the model defaults totriage.model. Worker settings live inwrangler.jsonc:DISCORD_GUILD_ID,DISCORD_ALLOWED_ROLE_IDS,DISCORD_REPOSITORY,DISCORD_PUBLIC_KEY, and optionallyDISCORD_ASSISTANT_CHANNEL_IDS. The assistant stays off until the server, roles, and repository are set. Draft until those IDs are filled in and the Message Content intent and interactions endpoint are configured in the developer portal.containers.max_instancesis 10, shared with every other capability. We may need to raise it.Testing
tests/discord-gateway.test.ts: covers identify and READY, heartbeats with the sequence number, reconnecting when heartbeats stop being acknowledged, resuming a persisted session, re-identifying after a session can't be resumed, stopping on fatal close codes, and thread naming.tests/discord-thread-coordinator.test.ts: covers jobs running in order, coalescing of waiting mentions, dedupe of redelivered and finished jobs, reconciling after a workflow dies without reporting back, a proposal being claimed only once, the read cursor only moving forward, and remembering linked issues.tests/discord-interactions.test.ts: covers the role check, queuing an approved PR with its buttons disabled, a double click acting once, dismissing, buttons that don't match their proposal, and filing an issue in the background.tests/discord-assistant.test.ts: covers settings parsing, mention decisions (role, server, bots, webhooks, reply-without-mention), transcript rendering, issue reference parsing, button custom ids, proposal formatting, the single check-in heartbeat, and the bundled skill.tests/config.test.ts: updated for the newdiscorddefaults, plus override parsing.Docs
discordconfig, and the Discord developer portal setup: Message Content intent, interactions endpoint, bot permissions, and thewrangler.jsoncvariables.