Team call runtime — call tokens, the call broker, the agent pool and cooldowns, call-tool admission. A repository rule for apps/daemon/src/v1/teams/**/call-broker*, apps/daemon/src/v1/teams/**/team-executor*, apps/daemon/src/v1/teams/**/pool-cooldowns*, apps/daemon/src/v1/teams/**/agent-pool*, apps/daemon/src/v1/teams/**/turn-semaphore*, apps/daemon/src/v1/teams/**/callee-*, apps/daemon/src/v1/teams/**/caller-key*, apps/daemon/src/v1/teams/**/open-call-work*, apps/daemon/src/v1/teams/teams.ty...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rule Daemon Team Calls?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/geniro-io-rule-daemon-team-calls)
---
name: rule-daemon-team-calls
description: "Team call runtime — call tokens, the call broker, the agent pool and cooldowns, call-tool admission. A repository rule for apps/daemon/src/v1/teams/**/call-broker*, apps/daemon/src/v1/teams/**/team-executor*, apps/daemon/src/v1/teams/**/pool-cooldowns*, apps/daemon/src/v1/teams/**/agent-pool*, apps/daemon/src/v1/teams/**/turn-semaphore*, apps/daemon/src/v1/teams/**/callee-*, apps/daemon/src/v1/teams/**/caller-key*, apps/daemon/src/v1/teams/**/open-call-work*, apps/daemon/src/v1/teams/teams.types*, apps/daemon/src/auth/call-token*, apps/daemon/src/v1/agents/**/call-seed*, apps/daemon/src/v1/mcp/tools/*-agent/**, apps/daemon/src/v1/mcp/tools/list-agent-threads/**; read it before editing a file there."
---
<!-- GENERATED by scripts/sync-agent-rules.mjs from .claude/rules/daemon-team-calls.md. DO NOT EDIT: edit the source, then run `pnpm sync:agent-rules`. -->
# Team call runtime
- The call token reaches a CLI in an HTTP header in `session/new` (ACP) or thread config (codex); claude's 0600 `--mcp-config` file is in `.claude/rules/agent-adapters.md`. Never argv, never a file in the worktree.
- Admission is "has another member to call" on a CLI whose call tools need no trust probe. Do not reintroduce a cursor trust probe, a `.cursor/mcp.json` merge or a `cursorCalls` capability.
- No cap on a run's total calls (depth cap only).
- Active-turn cap (`Team.maxActiveTurns`, never above `MAX_PARALLEL_AGENTS`, which `GET /v1/capabilities` serves as `maxActiveTurnsCeiling`): one gate per pass (`utils/turn-semaphore.ts`) counts callee turns at every depth. Only a FRESH call waits, writing a `queuedCall` system row (twin of the renderer's `CallBlockEntry.queued`; run state serves it over the whole run as `RunCallState.queued`, ended by the call's first `status` row or its settle); a cancel or Stop takes it out of the queue, and its silence watchdog is suspended while it waits (`CallBroker.noteCalleeQueued`). A turn blocked in `call_agent` / `await_agent`, on its own parked question or on a card stops counting (`RunCallCapability.turnBlocked`, reported by the broker off `waitingOwners` ∪ `blockedOwners`), and is counted again WITHOUT waiting when it unblocks; a wake (`startOwnerTurn`'s `wake`, a held call's wake) never waits either. Never make a blocked or returning turn re-acquire through the queue: a turn holding or awaiting a slot while waiting on turns that need one deadlocks the run, and a failed re-acquire after `handToWaiter` loses the question it delivered.
- Silence watchdog (`CALL_SILENCE_DEADLINE_MS`): surfaces, never settles. It writes one `stalledCall` system row with its text under `message`. Suspended while the callee has a tool call open, is parked, or is held. Cleared on settle and in `unregisterRun`.
- A callee's kept process is keyed by its CONVERSATION (`<runId>::call:<first call id>`). A continuation while a call on it is live is refused `THREAD_BUSY`. Install the process closer after `startTurn`; rebind the off-turn sink every turn.
- A conversation's live plane is written under one owner key at a time (`PartialStreamService.moveConversation`, run-scoped, so it holds across passes): a callee turn that takes the conversation under a new call's key closes the previous key (`closeOwner`) on the pass's write chain, behind the events its sink already queued, or a stretch the kept process opened off-turn under the old call stays open on every client and every join.
- A call may name a `folder`, a subfolder of the run's folder (`utils/call-folder.ts`): the broker takes only an existing directory whose real path is inside it (an absolute path written through a link to the folder counts; a link inside it leading out does not), before minting an id; the conversation keeps it (`ThreadRecord.folder`, written relative on every `call_started`, restored by `call-seed.ts`), a `thread` naming another is refused `FOLDER_MISMATCH`, and every callee turn re-checks it (`callTurnFolder`) into a turn-local cwd, never the pass's shared `cwd`. The pool's folder-gone test reads the call's folder; account pins stay on the run's.
- A parked question's 30-min TTL is suspended while its owner is blocked; blockers are a set of named cards, not a count. It is also suspended while its owner's own conversation stands on a user card it handed over (`RunCallCapability.standsOnUserCard`), and a question the owner was told about is not orphaned while that card stands.
- Call state survives a restart via the transcript (`v1/agents/utils/call-seed.ts`). Ids continue past the highest persisted; never re-mint `call-1`.
- A shutdown nobody asked for (`TeamExecutorService.shuttingDown` without a Stop, `RunCallCapability.leftForBoot`) writes no ending for an unfinished call: no `call_result` (neither the cancel's `CALLEE_CANCELLED` nor a closed process's `CALLEE_FAILED`), no member `cancelled`/`failed` row and no pool hand-on, so the boot finds it open. The turn's `turn_cancelled` row is still written, since it carries the turn's usage; when the UI's note for the stop under way (`peekStopCause`, read in `beforeApplicationShutdown`) says `quit`, `self-update` or `restart` (`resumesUnattended`), it is marked `continues: true`, and nothing reads a marked row as a Stop (`turnEndingOf`, the export). After a `quit`, `self-update` or `restart` — or a crash, once the user chooses to continue the run — it is continued under its own id (`CallBroker.resumeCall`: no new `call_started`, a `restartContinued` system row instead, the callee's saved session from `CallContextDao.sessionsByCall`, on the pool member its newest hand-off names (`openCalls` over `ItemDao.callHandOffRows`), which is whose profile `sessionResumable` is asked under — recorded as soon as its process starts when the adapter announces the id it spawned the CLI under (`session_assigned`, recorded for call turns only and never taken into memory), and resumed only when `AgentAdapter.sessionResumable` says the CLI wrote it with a prompt in it, else the call continues fresh with its transcript excerpt; a call on a thread asks with its conversation's call briefs up to its own (their `call_started` messages, `conversationBriefs` / `callBriefsOf`), and a session that saved the thread's earlier prompts but not that brief (`prompt-missing`) is resumed with the brief given again after the `[geniro]` note — a sync call filed for `await_agent` like one that outlived its wait); the seed reads that row (`continuedAfterRestart`). The stop that cuts it off again decides (user decision): a `quit`, or a crash the user chooses to continue, continues it again every time, since only the user's own relaunch or choice does; a `self-update` or `restart` (`continuesUnattended`) fails it `CALLEE_FAILED[daemon_restart]` naming its thread, its caller told in the continuation (`failedCalls`), so no loop runs with nobody acting.
- claude question-capable turns (callees and callers) spawn in ask mode with the daemon auto-approving plain permissions (bypass mode strips AskUserQuestion) — only for an `auto` member; an explicit `ask` member keeps the human card.
- cursor `cursor/ask_question` must never be declined `-32601` (cursor would replay it as permissions that `auto` approves). A free-text answer naming no option is sent as `skipped`.
- Waits: `await_agent` / sync `call_agent` are bounded at 80% of `mcp.toolCallDeadlineMs` and by `DEFAULT_AWAIT_TIMEOUT_MS`; never unbounded. A user message releases waits (`interruptWaits`); the daemon stopping releases every wait and refuses new ones (`beforeApplicationShutdown`, answered `pending` with nothing consumed), because the HTTP server closes only once every request has answered and the sessions that end a callee close after it. `awaitingCalls` counts only the message targets (`RunCallCapability.messageTargets`, the run's lead, in its own conversation) inside a wait or in the GAP after one: `AWAIT_GAP_GRACE_MS` after a wait returns, ended by main-thread reply text (`noteOwnerReplying`), a message the CLI took or the turn ending (`forgetUserMessage`); a wait a user message released or the CLI abandoned opens none, and teardown clears the timers. The gap is kept apart from `waitingOwners`, which still means "inside a wait" (`tellWorkingOwnerFinished` reads it). Unknown arguments are refused. Call tools carry `ALWAYS_LOADED_TOOL_META`.
- **Agent pool** (`TeamMember.pool`): calls and member turns can hand work to another pool member.
- Hand-on only on a limit, a lapsed sign-in, or a failure before any tool call — never a failure before work whose working folder is gone, nor a start `TurnFolderService` refused (`fallsThroughPool`'s `folderGone`; every member would meet it); never on cancel or an unclassified failure mid-work.
- A continued call follows the same rule as a member's conversation (`conversationStartMember`, below; the kept process asked through `RunCallCapability.conversationHoldsWork`). A `member` the caller names is a PREFERENCE, never a pin (user decision, 2026-11-16): the call starts on it unless a cooldown holds it spent (`preferredAttemptOrder` puts it first among the members sharing its standing), still hands on like any member, and a continuation moves back to it once it is proven again — or at once when this very call names it and it is unspent (`conversationStartMember`'s `requested`: the call is the attempt that proves it). For the call that names it, a member spent only for being signed out counts as unspent (`standingsForRequest`, new calls and continuations alike: a sign-in outside geniro is invisible), and a failure before any tool call hands on as usual; a usage limit still holds it. When another member runs the call, its envelope carries `preferred_member` and why in `preferred_member_note` (`preferredMemberSkipNote` when it was never tried, "tried and failed" when `pool_skipped` names it); the latest one named rides the thread (`ThreadRecord.preferredMember`, carried on `call_result` as `preferredMember` for a restart; an older row's `memberPinned: true` reads as a preference for its `member`), and naming another member on a thread changes the preference rather than refusing. A move is decided by the broker (`CalleePoolPlan.sessionMember` names whose session `resumeSessionId` is) and carried out by the executor: it retires the kept process, writes the same `callId` + `member` system row a hand-on does, and opens the new member with the transcript; a refusal before any tool call returns the call to the session's member, resuming its session. On hand-on, recent history from that conversation and its original brief go into a fresh session; another conversation's rows never do.
- Spent members are one daemon-wide record (`PoolCooldowns`, `teams/services/pool-cooldowns.store.ts`, a provider of the teams module held as `CallBroker.poolCooldowns`), keyed by the account a member runs on — `effectiveAccountKey`, the plan-limits ledger's key (folder pin first, then `configDir`, canonicalized) — plus model, never by run or member. The executor is its only writer (member turns and callee attempts, each attempt as it is handed on); the broker only reads it. A member is spent until the instant its limit names (`resetInstantFrom`), else `POOL_COOLDOWN_FALLBACK_MS`; answering clears it. `limit` (a limit or lapsed sign-in) is filed by account and seen by every run; `unavailable` (any other failure it was handed past, a turn that could not start included) is filed only for the run and member that met it (`PoolSite`). A sign-in geniro runs for a profile (`CliAuthService` → `AccountSignIns`) drops every `limit` that profile's lapsed sign-in filed and proves its account (`PoolCooldowns.signedIn`); a usage limit stays. In memory only.
- Order (`poolAttemptOrder`): unspent members, then `unavailable`, then `limit`, each in pool order. A new call and every member turn (first message, follow-up, new pass) start on the first; a conversation that has a session (`conversationStartMember`: a member's own, or a continued call's) moves only off a `limit`-spent member, or back to an earlier one PROVEN to work again (`PoolCooldowns.proven`: its account answered since the daemon started, or the reset instant its CLI named passed — never a guessed `POOL_COOLDOWN_FALLBACK_MS` lapsing, nor a member nothing is known about after a restart, either of which would meet the same limit on every message) while its process does not `holdsWorkFor` (a running command or a parked card would be stopped). A move writes the same `nodePoolHandOff` row a hand-on does (what later passes read) and carries the transcript into a fresh session; if the earlier member refuses again, the turn returns to the member it left and resumes that member's session (a fresh session with the transcript when the refusing attempt already made tool calls). With every member spent the member stays where it is. Transcript replays pass `redactSecrets`.
- The user picks a member's OWN conversation's pool member (`PUT /v1/teams/runs/:runId/members/:memberId/pool-member`, `TeamExecutorService.setOwnPoolMember`; 400 `NO_AGENT_POOL` / `UNKNOWN_POOL_MEMBER`, 404 `NODE_NOT_FOUND`, 409 `RUN_ARCHIVED`). It pins it: the hand-off row carries `pinnedByUser` (`nodePoolHandOffRow`, the one builder of that row), and a pinned conversation starts on its member with no `conversationStartMember`; a fall-through hand-on writes a row without the flag, which releases the pin (`readNodePoolPins`). A live pass applies it on its own write chain (`LiveRunControl.pinPoolMember`), so no turn of that conversation starts halfway through: idle moves at once (`now`), a running turn keeps going and the pick waits in memory (`poolChoices`, lost on a restart) until the next turn starts (`next_turn`); with no pass the row is written directly. A move leaves the session (the account it was opened on), and the next turn starts on the new member from a transcript excerpt — after a restart, every member pinned by a move with no session on its new member. The nodes route serves `poolMember`, `poolMemberPinned` and `poolMemberNext`.
- A handed-on attempt writes no terminal row and retires the kept process.
- `node_state` belongs to member 1; spend rows name their own member's agent and model.
- `calleeSummary` never names a member's config directory (it goes to the caller's provider).
- Prompt-cache keep-alive (`v1/agents/services/prompt-cache-keep-alive.service.ts`): when the LEAD's own conversation ends a completed turn on a CLI whose `promptCacheWarmupUnavailableReason` is null (claude) while the broker says it is owed (`CallBroker.owedACallOrMonitor`: an open call of its own, an uncollected async result, or `monitorsOwed`; never a usage-limit reset wake, never a card waiting on the user), the executor arms a warm-up from that turn's own `AgentTurnInput`, session id, `promptCacheTtlMs` and context reading. It fires at the TTL minus `max(90 s, 10%)`, is a one-shot `AgentAdapter.start()` with `promptCacheWarmup` (claude: `--resume … --fork-session --no-session-persistence --max-turns 1`, every tool blocked by a PreToolUse hook with `disableAllHooks: false` in the same `--settings` object, a throwaway cost ledger, list-priced), registered in `ProcessRegistry` and run-tagged, and writes no item. It stops at the conversation's next turn start (`retainConversation`), Stop (`cancel`), archive, delete, shutdown, when nothing is owed, after `PROMPT_CACHE_KEEP_ALIVE_MAX_WARMUPS`, after a warm-up that wrote more than `max(20k, 10%)` of the context, or when the cache has already lapsed; below `PROMPT_CACHE_KEEP_ALIVE_MIN_CONTEXT_TOKENS` it never arms. Callees and other members are never warmed. Spend: `daemon-stats.md`.
- `mcpDisabled` per member and pool member writes no CLI config and joins `sessionKey`; geniro's own server is never switched off.
- `mcpAllowed` per member and pool member (a project overlay replaces it, null = every server) is the ONLY set of the user's servers its turns load, beside geniro's own. The executor resolves each account connector's target through `AgentMcpService.connectorTargetsOf` — a CLI listing under the member's profile, any folder's, newest first, else this folder listed blocking; never the turn harvest, whose `system/init` names no target — writes one transcript warning per lane for a connector no listing gives one (`unreachableConnectorsNotice`), files no MCP harvest from an allow-listed turn (it reports only its list), and passes `AgentTurnInput.mcpAllowed` only to a CLI whose `AdapterConfig.mcp.allowListUnavailableReason` is null; claude writes it as `allowedMcpServers` in its `--settings` (ordinary servers by name, account connectors by URL, which a name never matches). It writes no CLI config and joins `sessionKey`.
- claude: `deniedMcpServers` in the turn's `--settings` (`CLAUDE_DENIED_MCP_SERVERS_KEY`: the CLI never starts the server), plus `--disallowedTools mcp__<normalized>` in the one variadic flag that always carries `Monitor` (`CLAUDE_WITHHELD_TOOLS`: geniro's `monitor` replaces claude's own, so every CLI has one mechanism).
- codex: overrides only for names its config defines (an unknown name fails `thread/start`).
- cursor: throwaway `CURSOR_DATA_DIR` with symlinks into the user's store.
- `CALLEE_FAILED[<class>]` (`rate_limited` / `auth_expired` / `daemon_restart` / `crashed`): the message passes through `redactSecrets`. `resetsAt` stays verbatim. Patterns are per-CLI config and must never carry the `g` flag.
- `cancel_agent`: no card, ownership enforced by the broker (`UNKNOWN_CALL` otherwise), reason required. It cascades to calls made inside; finished work is never stamped cancelled. After the turn ended it answers `already_finished` unless work is still owed. A call its caller stopped this way is collected by the broker as it settles: the caller is neither told nor woken about it, its `await_agent` answers `{state: 'cancelled', by: 'you', reason}` as an ok result, and `call_result` keeps the `CALLEE_CANCELLED` error. A message the caller sent to that call and never delivered reaches the caller at its next turn, not in a wake.
- `message_agent`: ownership as above; `CALLEE_PARKED` when parked; a message not yet takeable is queued, never refused. Undelivered messages are written as `outcome: 'undelivered'`.
- A call the asker owns that has already finished is refused `CALL_FINISHED` (`CallBroker.finishedCall`) by `message_agent`, `cancel_agent` and `answer_agent`, naming `await_agent` and `thread:` as the next moves; only ownership reads as `UNKNOWN_CALL`. A caller still working when its async call settles is told inside its turn (`tellWorkingOwnerFinished`), never while it waits on its own calls, and `told` stays false so `drainCaller` still wakes it. Its note, and the question twin's (`tellWorkingOwner`), carry the call that conversation answers (`inAnsweredCall`); without it the row is drawn in the run's own flow as a stray block. So does an orphaned question's note (`orphan`, `severity: 'info'`). The call each row is ABOUT rides nested keys, never the top-level `callId` (`CallNoticeRowWire` in `chat.types.ts`: `toldWorking`, `orphanQuestion`, and each `wake` entry's member, question or ending), twinned by the renderer's `agent-event-payload.ts` and `wake-payload.ts`. A finished call's answer reaches them through `noteCalleeSettling(runId, callId, outcome)`, which the executor calls before the broker writes `call_result`: its start (`cappedRowText`), only for a completed turn, is cached on the call and its `pendingAsync` entry (`makeCollectable` copies it), never on a reset wake (`persistedWake` keeps `WakeResult` only).
- Cache facts (`list_agent_threads`) are a tool answer, never part of the "May call" block (it is hashed into `sessionKey`). `CACHE_EXPIRED` refuses a cold, >50% resume unless `resume_cold`; geniro's own continuations are never refused.
- Reset wakes (`scheduleResetWake`) schedule only from an instant `resetInstantFrom` can place exactly. They are persisted on `Run.resetWakes` and re-armed at boot. A walk is taken only when it schedules exactly the promised agents; otherwise a note is written.
- Monitor output reaches a team conversation through `TeamExecutorService.wakeConversation`, installed by every pass whether or not the team can call (`wakeNode` exists only where it can): `busy` while the conversation's turn runs (held for `onConversationTurnEnded`), a member's own conversation continued as `continueNode` (reopening a finished run) with the monitor row as its opening row, never into a live turn — scheduled by `scheduleOwnTurn`, the pass's one copy of the bookkeeping `wakeNode` shares; a wake it took and then drops before its turn starts is handed back through `onDropped`: the delivery records its ends when the run was stopped, and holds the output again for that conversation's next turn end when a user's message started the run's next pass first. The team Stop (`cancel`) stops the run's monitors.
- A callee turn ending while its own calls run is HELD inside the same call (`holdCall`). The `heldCall` row is a twin of the renderer's `transcript-groups.ts`. Wakes for a held conversation go to the hold (`wakeOwner`). `MAX_CALL_WAKES` bounds it.
- A callee turn ending while its monitors still run, or while their output waits to be delivered, IS held inside the same call, like one whose own calls are out — a monitor is bounded (24 h at most), a detached command is not. `owesHold` and `reviewHold` read `RunCallCapability.monitorsOwed`. The output wakes the callee inside the call (`CallBroker.wakeHeldCallee`, a wake marked `monitor`), counted against its own `MAX_MONITOR_WAKES` (50), never `MAX_CALL_WAKES`; past it its monitors are stopped and the call settles on the answer it has. Output that waited for the turn to end goes out once the hold begins (`callHeld`). Cancelling the call stops its monitors, and so does a call that settles without being held.
- A callee turn ending while commands it detached still run is NOT held (a dev server never ends). The call settles, and its envelope counts them (`commands_still_running`), lists them (`running_commands`) and says in its `note`, as fact, never as an instruction, that the work may not be finished and where their output arrives. They are read from the CONVERSATION's shell rows (`shellsOutOfConversation`): an earlier call's on the same thread count and are tagged with that call (`CallBroker.recordedCallsOf`); another conversation's never do. Words come from the launching call (`launchingCallOf` — member, call and id, since ACP ids restart per session — then `shellCommandOf`) through `quotedCommand` (every env assignment's value shown as `…`, wherever it is set, then registered secrets masked; one line, `LEFT_RUNNING_COMMAND_MAX`). A held call re-reads them when it settles. A failed read is logged and names none, never costing the call its result. `nohup` servers are not CLI shells and are not listed.
- A caller is a conversation (`callerKey(nodeId, conversationId)`); everything the broker keys uses that pair. Never wake a node in a fresh process with no session.
- A superseded pass refuses calls `RUN_BUSY` before minting ids, and numbering continues.
- `rootsWorking` (what decides whether a team message queues) stops counting the run's lead (`leadIds`) while its own turn is HELD for background sub-agents (`turn_held` open > 0) and counts it again when the hold ends (`open: 0`): its reply is over, and a message delivered into it ends the hold.
- The capability's `calleesOf` is read live per call, so a run-only team change refills it in place (`liveRosters`, Teams and passes) rather than registering the run again; a departed member is nobody's callee from the change on.