← Home

Routing GitHub mentions to Codex and Claude draft plan

12 October 2026 · Revised 14 October and 11 November 2026 · Proposed implementation: smolpaws/apps/github

Grow the existing GitHub Worker; don't build a second one. enyst writes @smolpaws codex … or @smolpaws claude …. GitHub delivers that to SmolPaws as a notification, which the Worker already polls. One D1 ledger and the existing minute cron carry each request to a delivered reply posted as SmolPaws. Claude runs on Claude Managed Agents and Codex on the OpenAI Agents API: two API-key agents the Worker controls, neither visible in the providers' web apps.

The SmolPaws agent asks through a direct tool that writes the same ledger row, not through a GitHub comment. A first version returns findings as comments. Code proposals come later as branches on enyst's fork.

Revised proposal. The managed routes have not been implemented or activated.

What changed in this revision

A review on 11 November kept the correctness core and questioned the shape. These changes follow from it.

Keep hosted routing inside the GitHub app

smolpaws/apps/github already contains a Cloudflare Worker, a minute cron, an ALLOWED_ACTORS allowlist, notification polling with SmolPaws's user token, a queue and GitHub replies. Ordinary SmolPaws requests go through agentServerClient.ts to the local runner. The hosted routes are selected before that dispatch and handled by their own module. GitHub Worker source, Worker configuration, and local runner adapter.

apps/github/
  src/index.ts                  Worker wiring and route selection
  src/managedAgents/
    index.ts                    accept(request), tick(), status(runId)
    intake.ts                   Notification thread scan and mention parsing
    lifecycle.ts                Dispatch, observation and publication
    ledger.ts                   D1 requests, leases and reply outbox
    transcripts.ts              Session logs to R2 and the run viewer
    providers/claudeManaged.ts  Claude Managed Agents sessions
    providers/openaiAgents.ts   OpenAI Agents API sessions
  migrations/                   Shared durable intake and routing schema

This is a proposed layout. Keep the module free of imports from the agent server, coordinator, personal memory and local runner protocol. Pass its storage, clock, HTTP access and comment writer in explicitly. Provider-specific formats stay inside the two adapters. The SmolPaws ask_codex and ask_claude tools call accept(request) through the Worker's authenticated interface.

A recognized @smolpaws codex or @smolpaws claude command is consumed even if it is rejected; it must not also reach the local runner. A plain @smolpaws mention keeps going to SmolPaws itself.

Build the ledger once and let both paths use it. The Worker's current dedupe, wasGithubMentionEnqueued and wasNotificationEnqueued, lives in the Cloudflare Cache API, which is local to a data center and can be evicted at any time. Replace it with D1 receipts for ordinary SmolPaws mentions too, with a migration baseline so old mentions do not run again. Cache API storage properties.

Require two integration checks: hosted requests work with the local runner unavailable, and disabling hosted routes preserves ordinary SmolPaws requests. The shared Worker remains one deployment, so a release affects both paths.

The trigger is addressed to SmolPaws

Use @smolpaws codex … and @smolpaws claude …. The provider word is an argument to a mention of an account enyst controls.

@smolpaws codex review this change for cancellation and cleanup bugs
@smolpaws claude explain whether the proposed API preserves replay behavior

Bare @codex and @claude fail in three ways. @codex triggers OpenAI's Codex GitHub integration and @claude triggers Anthropic's Claude GitHub app and Action. If anyone connects either one to the target repository, a single comment would start the real product and the router, billing and posting twice. Each mention also pings whoever owns the handle. And because the mention is not addressed to an account enyst controls, finding it requires polling every comment in the repository.

A mention of @smolpaws creates a notification for SmolPaws on any repository where enyst can comment. The Worker already polls those notifications. The repository allowlist stays, starting with OpenHands/software-agent-sdk (repository ID 1043426082), but it is a policy check, not the intake mechanism. Store IDs, not names, so a rename cannot silently change which repository may receive work.

Who acts as whom

Only enyst's immutable GitHub author ID may request work through a comment. SmolPaws asks through its direct tool. Replies are posted as smolpaws, which makes the attribution obvious and lets loop prevention be a single rule: ignore comments whose author ID is SmolPaws's.

ActionWho performs itRequired access
Request Codex or Claude on GitHubenystAbility to comment on an allowed repository. The author ID check is the authorization.
Request Codex or Claude from SmolPawsSmolPaws agentThe direct tool's service credential. No GitHub comment.
Publish a result or status commentRouter as smolpawsSmolPaws's existing comment access.
Push a proposal branch, laterRouter as enystContents write access to enyst's fork only.
Open a draft PR, laterenyst, by hand at firstOrdinary PR access from the fork.
Label, approve, mergeOutside this planNot part of the comment route.

One durability owner: cron and D1

The D1 row drives a small state machine from the existing minute cron. No Workflows, no sweeper, no provider webhooks in V1. One mechanism owns the property that matters: every accepted request ends delivered or visibly failed. It is easy to inspect, to test locally and to reason about. Cron Triggers and D1.

Each tick claims due rows with expiring leases, performs bounded HTTP operations, saves progress and exits. The provider runs the agent while the controller is idle. A twenty-minute watchdog spans many ticks; the Worker never waits for a whole job inside one invocation. Cloudflare limits cron invocations to fifteen minutes; set a much smaller tick budget. Worker invocation limits.

Polling status once a minute for a twenty-minute job is a few dozen calls. That replaces public webhook endpoints, signature verification, event persistence and handling of duplicate, reordered or lost events. Webhooks can be added later if measured latency justifies them.

  1. @smolpaws codex|claude from enyst, or a direct SmolPaws tool callVerified author ID, explicit provider, allowed repository.
  2. The GitHub Worker accepts the requestNotification intake and the direct tool both call accept(request).
  3. D1 records a unique requestThe existing minute cron advances it.
  4. The selected backend works
    claudeClaude Managed Agents
    Managed Claude harness
    codexOpenAI Agents API
    Managed Codex harness
  5. SmolPaws publishes the resultProvider, model, assessed commit, findings, a link to the run log and a durable receipt.
Proposed request path. The local SmolPaws runner is needed only for ordinary SmolPaws conversations.

Backends: two managed agent APIs

Both providers host the agent loop and sandbox, and the Worker drives both the same way: create a session, poll its state, read the answer. Keys stay in the Worker, budgets are set per session, and nothing acts on GitHub except the router. The cost is that neither run appears in claude.ai/code or chatgpt.com/codex, so a result cannot be opened and continued in a web app. The plan accepts that trade and makes up for it with its own run logs.

Claude through Claude Managed Agents

Configure an agent and environment once, then create a session per request and send the request as a user event; initial_events can combine the two. Endpoints use anthropic-beta: managed-agents-2026-04-01 with the API's normal version header. Managed Agents is enabled by default for API accounts; the deployment still needs its own smoke test. Managed Agents overview and Starting a session.

Codex through the OpenAI Agents API

Start with POST /v1/agents/sessions, an openai_hosted environment and a pinned model. The beta header is OpenAI-Beta: agents=v1; the key needs api.agents.read, api.agents.write and api.responses.write and stays in the Worker. OpenAI Agents API overview and quickstart.

The two betas differ in session model, event names and budget fields. Keep those differences inside the two adapters, and give lifecycle.ts one shape: created, running, waiting, answered, failed.

Why not the web-visible routes

Claude Code scheduled task. A scheduled task (formerly a routine) with an API trigger turns each request into a claude.ai/code session that enyst could open and continue. Checked against its documentation on 11 November, it is the wrong fit for this router. Anything it does through connected GitHub access appears as enyst, who has push access to the target. The /fire call returns a session URL but not the answer, so results need a callback endpoint. A run cannot be stopped by the router, and the feature is a research preview under experimental-cc-routine-2026-04-01, limited to 30 fires per hour per task. Scheduled tasks and Trigger a routine through the API.

Codex web. codex cloud exec creates a Codex web task but depends on ChatGPT login. That is the same dependency that stopped the OpenHands Cloud Codex ACP canary on 12 October, when it required ChatGPT reauthentication.

Neither backend reads personal chats, desktop tasks or their memory. Supply the skills and instructions each needs explicitly.

Intake from notifications

GitHub notifications describe threads, not individual comments. A thread's mention reason can persist through later activity, and the Worker today reads only latest_comment_url, so two requests in one thread between ticks would lose one. GitHub notification semantics.

Treat a notification as a pointer to a thread, then scan that thread. For each mention notification on an allowed repository, list that issue's or PR's comments, review comments and review summaries since the thread's last scan, kept per thread in D1 with a short overlap. Parse each item for @smolpaws codex and @smolpaws claude, and mark the notification read only after the rows are written. The scan stays bounded to threads that mention SmolPaws, so repository-wide cursors, overlap windows across feeds, leases on scans and activation baselines per surface are no longer needed.

Review summaries and PR or issue descriptions that mention SmolPaws also produce notifications. They come with the same scan instead of a separate later intake path. At activation, ignore items created before the activation time so old requests do not run.

Authorization and mention parsing

Authorize by enyst's immutable GitHub author ID, read from the API. A copied name, a quoted request and author_association do not authorize work. Ignore every comment authored by SmolPaws.

Parse actual mention tokens in authored Markdown, ignoring code, blockquotes and URL destinations. Match @smolpaws case-insensitively with handle boundaries, followed by codex or claude as the next word. @smolpaws-example is not a match. Two commands in one comment create one request per provider.

Freeze the request, label the context

Freeze the first qualifying observed body. Before dispatch, fetch the source again: deletion, or removal of that provider's command, cancels work that has not started. Any other edit is ignored, and the frozen request runs. Editing an accepted comment never starts another paid job; ask again in a new comment.

Put the frozen request first. Follow it with a thread snapshot in which each comment is labeled with its author and source, marked as untrusted, and capped at twenty comments and 32 KiB, with a per-comment cap so one long comment cannot crowd out the rest. Say when context was truncated. Reject requests over 16 KiB rather than silently shortening them. Other authors' text can inform the analysis but cannot change the destination, the permissions or the provider.

Let SmolPaws ask directly

Give the SmolPaws agent ask_codex and ask_claude tools, plus a status tool. They call the Worker's authenticated endpoint with a dedicated service credential; the caller cannot pick another principal through its payload. Require a stable client request ID, an allowed repository and an explicit issue or PR destination. A retry returns the same durable request. Direct requests use the same ledger, adapters, budgets and reply outbox. There is no GitHub round trip and no reason for SmolPaws to comment a request for the poller to find a minute later.

A durable request and a durable reply

For GitHub intake, the request key is repository ID + surface + comment ID + provider. For direct intake, it is the authenticated principal, client request ID and provider; a repeated ID with different content is a conflict. Put uniqueness constraints on both. Store the frozen request, policy version, target commit, provider session ID, log key and cursor, next attempt time, lease version and publication receipt.

Admit the request and reserve its daily budget atomically, then let cron claim and advance due rows. Use conditional updates with a lease owner and version so an expired tick cannot overwrite newer progress. D1 batches are transactional, but a provider call or GitHub post remains a separate remote mutation. D1 batch transactions.

accepted → dispatching → running → result ready → publishing → delivered

Other outcomes: awaiting action · budget paused · failed · canceled
Ambiguous responses: dispatch unknown · delivery unknown

A timeout after creation is not proof that creation failed. If the provider accepted work but the response was lost, a blind retry starts another paid run. Put the request ID in session metadata where the API allows it, and check each provider's idempotency and listing support during preflight. When recovery cannot establish the outcome, park the request as dispatch unknown. Apply the same rule to GitHub publication.

Unknown states must reach enyst. Dispatch unknown, delivery unknown, budget pauses and watchdog expiries send a SmolPaws message to enyst with the request, thread link and session link. Known failures also get an attributed status comment on the thread. A delivery unknown row gets no further comment until its receipt is resolved.

Completion is checked against the request

Fetch session state and new events on each due tick. Idle can mean waiting for permission or input, and an unfinished run may stay open. Require the current request's answer and a compatible completion reason, and persist the event cursor and bounded result before marking it ready. A session that asks a question instead of answering is published as a question with an awaiting action status. OpenAI session lifecycle and Claude session operations.

Use one session per request in V1, and serialize work for the same thread and provider. Reusing one session per thread is a later enhancement: it needs per-request event ranges, head-change handling, and a policy for requests that arrive while the agent is running.

Publish through an outbox

Prepare the reply in D1 before calling GitHub. Its header names the provider, the configured model and the assessed commit SHA, and links the private run log. Follow with the source request, findings and actual test evidence. Write a stable hidden run marker into the comment and record its GitHub ID on success. After a lost acknowledgement, look for that marker among SmolPaws-authored comments in the fully paginated thread before another attempt. The marker exists for idempotent publication, not for loop filtering. Don't copy command tokens into replies.

Before publishing, recheck the target head. If the PR moved, say so beside the assessed SHA, or assess the new head.

Keep every run's log

Neither provider shows these runs in its web app, so the router keeps its own record of what each agent did. Without one, a reply is a claim nobody can check: which files the agent read, which commands and tests it ran, and what they printed.

Copy the whole session log, not just the answer. Both APIs expose saved history. Claude Managed Agents lists a session's full event history, including agent.tool_use and agent.tool_result events, and keeps it until the session is deleted. The OpenAI Agents API lists a session's saved items, messages and tool calls, at /v1/agents/sessions/{id}/items. Claude session events and OpenAI session items.

Keep the provider session too, rather than deleting it when the run ends. Its ID is stored on the request row, which leaves room for a later @smolpaws claude continue … that sends a follow-up into the same session.

Keep credentials out of the sandbox

The Worker holds SmolPaws's GitHub token and both provider keys as Worker secrets. None of them enter prompts, D1 payloads, logs or agent-visible files. Public source enters each sandbox as a commit-pinned archive or a public clone, with network access configured explicitly and the dependencies the SDK's real tests need. Anthropic supports GitHub repository mounts with a token; this public-repository plan does not need one. OpenAI hosted sandbox configuration and Claude GitHub access.

The agents produce findings and patch artifacts; deterministic router code controls publication. Repository instructions and other authors' text can guide analysis but cannot grant secrets, a new destination or extra write permissions.

Code changes through the fork

After the comment path is proven, @smolpaws codex implement … or @smolpaws claude implement … can return a patch against a pinned commit. The router checks that it applies, rejects paths outside its publication policy, and pushes a deterministic proposal branch to enyst's fork with a credential limited to that fork. enyst opens the PR by hand at first; automated draft PRs can follow. This avoids contributor-fork permissions in V1.

Use ordinary comments for reviews. Formal approvals and requests for changes affect repository gates and stay a separate decision. No pushes to the target's default branch and no merges.

Bound jobs and measure cost

Intake adds little to GitHub reads. The Worker already polls notifications every minute, and the thread scan runs only for mention notifications. Read the rate headers and back off on primary or secondary limits; SmolPaws's allowance is shared with its ordinary work.

Proposed starting limits are two concurrent jobs, one per thread and provider, twenty requests per day, and a twenty-minute watchdog. Reserve the daily admission budget atomically before launch. Claude sessions accept a budget at creation; they stop issuing model requests at the cap, though an in-flight request can go past it. Publish a paused status when it is reached. Verify OpenAI's controls separately instead of copying Claude's fields. Claude session budgets. Measure real usage on the fixture before settling the budget. Cloudflare pricing.

Roll out in three stages

  1. Ledger and intake in shadow mode. Move SmolPaws's Cache API dedupe to D1. Add notification thread scanning, parsing, the direct tool and cron progression. Prove author filtering, multiple requests per thread, missed-tick recovery, direct-call authorization and separation from the local runner. No provider calls and no new posts.
  2. Both backends on a controlled fixture. Check account access, sandbox dependencies, current endpoint behavior and cost for both APIs. Exercise restarts, lost responses, stale heads, questions instead of answers, budget pauses and the operator messages. Check that each run's log in R2 matches the provider's own history and renders in the viewer. Require one attributed current result per successful request and a visible status for every failure.
  3. Enable the allowed repository. Set the activation time and turn on replies. Keep intake, each provider and publication independently switchable. Check that ordinary SmolPaws requests still work.

Proposal branches on the fork and session continuation per thread follow as separate work.

Decisions to make at implementation time

Original draft: 12 October 2026. Worker source, reply identity, cron lifecycle and module placement revised on 14 October 2026. Trigger syntax, notification intake, direct SmolPaws requests and operator states revised on 11 November 2026 after review, with run logs added the same day; Claude Managed Agents kept over a Claude Code scheduled task after checking the scheduled task documentation that day. Provider API details are as linked and not re-verified in this revision. The module layout, limits and rollout are proposed design choices.