cloudflare / cloudflare/agentic-inbox

Expose auto-draft toggle and configurable agent model per mailbox

Open
#11 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.5k
Forks
964
PR merge metrics
No merged PRs in 30d

Description

## Problem

Two behaviors are currently hardcoded and require a code fork to change:

1. **Auto-drafting on inbound email is always on.** `workers/index.ts` unconditionally fires `agentStub.fetch("/onNewEmail", …)` for every incoming message:
https://github.com/cloudflare/agentic-inbox/blob/48039bb6785af34e592c2966f87cde2b255c4c80/workers/index.ts#L88-L94
There's no way to disable it per-mailbox (or globally) without editing source.

2. **The agent model is hardcoded** to `@cf/moonshotai/kimi-k2.5` in `workers/agent/index.ts` (both `streamText` in `onChatMessage` and `generateText` in `handleNewEmail`). The injection scanner and draft verifier in `workers/lib/ai.ts` are similarly pinned.

## Proposal

Extend the existing per-mailbox settings blob stored in R2 at `mailboxes/.json` (already read in `getSystemPrompt`, already written by `PUT /api/v1/mailboxes/:mailboxId`) with:

```jsonc
{
"autoDraft": { "enabled": true },
"agentModel": "@cf/moonshotai/kimi-k2.5"
}
```

### Changes
- `workers/index.ts`: gate the `onNewEmail` fetch on `settings.autoDraft.enabled` (default `true` for backward compat).
- `workers/agent/index.ts`: read `settings.agentModel` alongside `agentSystemPrompt` and pass it to `workersai(...)` in both call sites; fall back to the current default.
- `app/routes/settings.tsx`: add a toggle for auto-draft and a model selector (dropdown of Workers AI text-generation models, or free-text input).

### Out of scope (follow-ups)
- Non–Workers AI providers (Anthropic/OpenAI via AI SDK adapters).
- Per-mailbox override of the injection scanner / verifier models.

Happy to send a PR if the direction looks right.

— bchoor-claude

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.