Skip to content

Add per-bot MCP servers, bot notes, start turns and durable routines - #15

Merged
nikuscs merged 11 commits into
nikuscs:mainfrom
sousavf:feature/claude-code-engine
Nov 6, 2026
Merged

nikuscs merged 11 commits into
nikuscs:mainfrom
sousavf:feature/claude-code-engine

Conversation

@sousavf

@sousavf sousavf commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Several Orbs features and fixes found while running a team of five bots: bots and the owner can add MCP servers per bot, files returned by MCP tools reach the bot, bots share short notes across their conversations, a new bot gets a first turn from its instructions, peer bots report to the owner themselves, messages to the owner are shorter, and routines keep running across daemon restarts.

Changes, by commit

MCP servers per bot

  • New mcp.add and mcp.remove RPCs, plus the bot tools bot_mcp_add, bot_mcp_list and bot_mcp_remove.
  • A bot-owned server is written to mcp/<botId>.json and is seen only by that bot. Headers and env take their values from stored secrets by name, and each secret must be allowed for the server's host. Removing a bot clears its derived credentials and its file.
  • bot_mcp_add always asks the owner first, even when "always allow" is on.
  • The MCP panel on web and mobile lists one-tap presets for Cloudflare, Linear, Notion and Sentry.

Bot start turn

  • When a bot is created with instructions, or first gets them on an update, it gets a start turn. It introduces itself, does the immediate work its instructions ask for, and creates enabled routines for recurring duties.
  • The chat shows a "Bot started" notice.

MCP files reach the bot

  • MCP results with embedded blobs or audio used to be dropped. They are now saved to agents/<botId>/downloads/, limited to allowed send types and 50 MB, with sanitized unique names.
  • The model is told where each file was saved, or why it was not.

Shared bot notes

  • Private chats with other bots and routine runs did not know what the owner had told the bot in its main chat.
  • bot_note keeps up to 30 short keyed notes in a session document, and a notes section shows them in every conversation of that bot.
  • Notes carry trust across chats, so bot_note always asks the owner first.

Peer bots report to the owner themselves

  • Private peer messages tell the recipient that the owner cannot see that chat and that it should report results in its own area with bot_notify_owner. Replies tell the sender not to repeat those details.
  • Fix: bot_message failed with Tx.createTask() requires options.conversationId. Deliveries are now created with their conversation.
  • The bot notes extension is registered for every bot.

Shorter messages to the owner

  • A new runtime instruction: lead with the result or the one decision needed, keep it to a few sentences or a short list, and leave out process and caveats unless asked.

Routines keep running across restarts

  • A routine's wait phase kept a live invocation for the whole interval. Every daemon restart or watch reload during it counted as a Pi restart without progress, and after five Pi parked the task (restart_limit). Routines stopped silently: on the dev daemon, all 7 routines across 4 bots were parked.
  • The wait now ends its phase in a stored sleep (status: 'sleeping').
  • Pi cannot wake a sleeping task early, so run-now and edits replace the routine's task in the same commit and then abort the old one. A task that is delivering is left alone and picks up the change when it finishes. An old task also ends itself if it is no longer the routine's task, so a run cannot happen twice.
  • Disabled routines and finished one-off routines now end their task. Re-enabling a routine creates a new one.
  • Opening a bot calls retryTask on routine tasks Pi has already parked.

Chore

  • bun.lock synced with the mobile app version.

Testing

  • bun run check (17/17) and bun run lint pass on the final tree.
  • Verified live on the dev daemon:
    • A bot_message delivery after the conversationId fix.
    • Routines: all 7 parked routine tasks were retried and moved to a stored sleep with their restart counts cleared. The overdue hourly review ran at once, the next daemon restart did not count against any routine, and the hourly routine kept firing through the night.
  • Not yet verified live: bot notes in a live turn, whether bots follow the new peer and reply prompts, the brevity rule (it needs a bot reconfigure), and run-now or edits replacing a sleeping routine task.
  • No automated tests were added.

Notes for review

  • Commits are grouped by topic. Commits in the middle of the series may not type-check on their own; the final tree does.
  • Secret rules are global, so every bot can use every secret. Scoping secrets per bot is a possible follow-up.
  • apps/web/worker-configuration.d.ts is generated by Wrangler and is left out on purpose.

@sousavf
sousavf requested a review from nikuscs as a code owner November 5, 2026 21:24
Add mcp.add and mcp.remove RPCs and the bot_mcp_add, bot_mcp_list and
bot_mcp_remove bot tools. A bot-owned server is written to
mcp/<botId>.json, headers and env take their values from stored secrets
by name, and the server's host must be allowed for each secret.
bot_mcp_add always asks the owner first. The MCP panel lists Cloudflare,
Linear, Notion and Sentry presets that add in one tap.
When a bot is created with instructions, or first receives them on an
update, it gets a start turn: it introduces itself, does work its
instructions clearly ask for now, and creates enabled routines for
recurring responsibilities. The chat shows a "Bot started" notice.
Embedded blob resources and audio in an MCP tool result were dropped
before reaching the model. They are now written to
agents/<botId>/downloads/ (allowed send types, up to 50 MB, sanitized
unique names) and the result tells the model the saved path, so the bot
can read or send the file.
Private chats with other bots and routine runs did not know what the
owner told the bot in its main chat. bot_note saves, replaces or removes
up to 30 short keyed notes in a session document, and a notes section
shows them in every conversation of that bot. Notes act as a trust
channel across chats, so bot_note always asks the owner first.
Private peer messages now tell the recipient that the owner cannot see
that chat and that it should report results in its own area to the
owner itself with bot_notify_owner. A reply tells the sender not to
repeat those details. bot_message deliveries are created with the
conversation they belong to, which Pi requires for conversation-owned
tasks. Register the bot notes extension for every bot.
Add a runtime instruction for every provider: lead with the result or
the one decision needed, use a few sentences or a short list, and leave
out process, unchanged checks and caveats unless asked.
A routine's wait phase held a live invocation for the whole interval.
Every daemon restart or watch reload during it counted as a Pi restart
without progress, and after five the task was parked: routines silently
stopped. The wait now ends the phase in a stored sleep. Pi cannot wake a
sleeping task early, so run-now and edits replace the routine's task
(left alone while it is delivering) and abort the old one, which also
ends itself when it is no longer the routine's task. Disabled and
finished one-off routines end their task. Opening a bot retries routine
tasks Pi has already parked.
@sousavf
sousavf force-pushed the feature/claude-code-engine branch from 7179fef to aa5b83d Compare November 6, 2026 08:50
@sousavf sousavf changed the title Run bots on the Claude subscription through Claude Code Add per-bot MCP servers, bot notes, start turns and durable routines Nov 6, 2026
Review fixes:
- bot_mcp_add can no longer pass env secrets to command servers; only the owner can.
- Embedded image resources from MCP tools reach the model again instead of being saved as files.
- Per-bot MCP servers live in data/bots/<botId>/mcp.json and are included in backups.
- Bot notes are carried over a history clear; bot_note replays as unsafe and has one schema.
- Owned servers are marked with an isOwned flag instead of a path check; add and remove run in the bot queue.
- api.md describes the stored routine sleep and the per-bot MCP file.

MCP settings on web and iOS:
- One list: an Add MCP server picker, then every server with its status, a switch for shared servers that saves at once, and Log in, Log out and Remove actions.
- Remove asks for confirmation on its own route. The separate shared-server picker and the iOS MCP picker screen are gone.
- The web bot form no longer sends the MCP selection, so saving another section cannot undo a switch.
- Log in and the actions menu, and a provider's sign-in buttons, sit in one button group.
…e-code-engine-1

# Conflicts:
#	.fallowrc.json
#	bun.lock
#	packages/runtime/src/services/collaboration/collaboration.utils.ts
@nikuscs
nikuscs merged commit a33286f into nikuscs:main Nov 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants