In-product agent
Every namespace ships with an AI assistant baked into the console.
Open it from the sidebar Ask AI button or press ⌘K (Ctrl+K on
Windows/Linux). It runs on Cloudflare Workers AI with the
@cf/moonshotai/kimi-k2.5 model and inherits your namespace role on
every action.
What it can do
Section titled “What it can do”The agent has tools at two levels.
Namespace-level
Section titled “Namespace-level”| Tool | Effect |
|---|---|
list_databases | Enumerate every database in the namespace |
propose_create_database | Stage a new database (always asks before creating) |
list_members | Members and their roles |
propose_invite_member | Stage an invitation by email + role |
list_tokens | List API tokens (without secrets) |
propose_create_token | Stage a new API token |
get_usage_summary | Last-N-day request / row counts |
Database-scoped (every tool takes a database slug)
Section titled “Database-scoped (every tool takes a database slug)”| Tool | Effect |
|---|---|
list_tables | Schema dump for a database |
describe_table | Columns, types, constraints |
run_select | Execute a single read-only SELECT (capped at 200 rows) |
ask | NL → SQL → answer for the database’s data |
read_docs | Stored table/column descriptions |
list_endpoints | Published endpoints for the database |
recent_endpoint_logs | Last invocations from analytics |
propose_create_table | Stage a CREATE TABLE |
propose_create_endpoint | Stage an endpoint spec |
propose_scaffold_crud | Stage list / get / create / update / delete endpoints for a table |
propose_generate_docs | Stage auto-docs for selected tables |
Anything starting with propose_ is a two-step flow — the first call
returns the plan, you see it in the chat, and only after you say
something like “yes, do it” does the agent re-call with confirmed: true
to actually apply.
Limits
Section titled “Limits”There is no per-tier message cap and no per-token throughput cap. Agent usage drains the same prepaid balance as everything else; when the balance runs out you’ll get a 402 with a top-up hint.
Each turn is bounded to 5 recursive tool calls so the agent can’t loop forever.
How it works
Section titled “How it works”- The console POSTs to
/api/namespaces/:slug/agent/chatwith your message. - The API worker assembles your last 50 turns of history, the system prompt (which embeds your namespace slug + role), and the tool definitions.
runWithToolsfrom@cloudflare/ai-utilsdrives the model loop on Workers AI. Tool invocations execute as you, with your namespace role.- The response streams back as SSE: a leading
event: traceframe listing every tool call, then the model’s tokens, then[DONE]. - The assistant turn is persisted to D1 so reconnecting clients see the same conversation.
History is per (user × namespace). Clear it from the chat panel —
that hits DELETE /api/namespaces/:slug/agent/history.
Prompting tips
Section titled “Prompting tips”- Be concrete. “Show me last week’s signups” beats “tell me about my data”.
- Reference databases by slug. With one database the agent picks it automatically; with several, name it.
- Approve
propose_*actions explicitly. “Yes, create it” or “go ahead” works. The agent won’t mutate without that. - Greetings get conversational replies. Saying “hi” won’t trigger any tools.