smithery/kbediako

delegation-usage

Use when operating the Codex delegation MCP server and tools (delegate.spawn, delegate.question.*, delegate.cancel, github.merge confirmation flow), or when configuring delegation mode/tool_profile with delegation MCP enabled by default.

Installation

$ npx skills add smithery/kbediako --skill delegation-usage

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/kbediako.

npx skills add smithery/kbediako

Browse all from smithery/kbediako

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

Declared agents codex

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 21,437 B
  • docs SUMMARY.md 261 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Delegation Usage

Overview

Use this skill to operate delegation MCP tools with delegation enabled by default (the only MCP on by default). Disable it only when required by safety constraints, and keep other MCPs off unless they are relevant to the task.

Global Adoption Defaults

For shipped CO usage, default to this command path unless task constraints say otherwise:

  • codex-orchestrator flow --task <task-id>
  • codex-orchestrator doctor --usage --window-days 30 --task <task-id>
  • codex-orchestrator rlm --multi-agent auto "<goal>"

delegation-usage is the canonical delegation workflow skill. If delegate-early is present, treat it as a compatibility alias that should redirect to this skill.

Multi-agent (collab tools) mode is separate from delegation. For symbolic RLM subcalls that use collab tools, set RLMSYMBOLICMULTIAGENT=1 (legacy alias: RLMSYMBOLICCOLLAB=1) and ensure your Codex CLI has features.multiagent=true (collab is a legacy alias/name in some keys); collab tool calls are recorded in manifest.collabtoolcalls. If collab tools are unavailable in your CLI build, skip collab steps; delegation still works independently.

Multi-agent (collab tools) realities in delegated runs (current behavior)

  • spawn_agent accepts one input style per call: either message (plain text) or items (structured input).
  • Do not send both message and items in the same spawn_agent call.
  • spawnagent falls back to default when agenttype is omitted; always set agent_type explicitly.
  • For auditable role routing, prefix spawned prompts with [agenttype:<role>] on the first line and keep it aligned with agenttype.
  • Keep forkcontext disabled by default for bounded streams; use forkcontext=true only when the child must inherit prior thread context.
  • Spawn returns an agent_id (thread id). Current TUI collab rendering is id-based; do not depend on custom visible agent names.
  • Subagents spawned through collab run with approval effectively set to never; design child tasks to avoid approval/escalation requirements.
  • Collab spawn depth is bounded. Near/at max depth, recursive delegation can fail or collab can be disabled in children; prefer shallow parent fan-out.
  • Lifecycle is mandatory: for every successful spawnagent, run wait and then closeagent for that same id before task completion.
  • Keep an openagentids ledger and append ids immediately after each successful spawn.
  • Remove ids from openagentids only after successful close_agent.
  • Run a final close-sweep before handoff: close every id still in openagentids, then clear the ledger.
  • On timeout/error paths, execute the same close-sweep before returning.
  • If spawn fails with agent thread limit reached, stop spawning, run close-sweep for known ids, retry once, and if still blocked surface a concise degraded-mode recovery note.
  • In a shared checkout, spawned subagents may produce file edits. Treat edits inside that stream's declared ownership as expected delegated output, not external interference.
  • Before spawning, capture a baseline (git status --porcelain). After wait, diff against baseline and classify file changes by stream ownership.
  • Escalate "unexpected local edits" only when changed files are outside all active stream scopes (or when no subagent was active).
  • If a generic safety prompt appears after delegation (for example "unexpected local edits"), run scope classification first; when edits are in-scope, keep them and continue without user escalation.
  • For scout/research streams, set an explicit no-write constraint and verify the post-run status matches baseline.
  • Prefer scripts/subagent-edit-guard.mjs for low-friction enforcement when the helper exists in the repo (start before spawn, finish after wait); canonical command examples live in docs/delegation-runner-workflow.md (section 3a). If the helper is absent, apply the same baseline/scope checks manually.

Quick-start workflow (canned)

Use this when delegation tools are missing in the current run (MCP disabled) and you want a background Codex run to handle delegation:

codex exec \
  -c 'mcp_servers.delegation.enabled=true' \
  "Use delegate.* tools to <task>. Return a short summary and any artifacts."

Optional (only if you need it):

  • Add --repo /path/to/repo only when you want to pin the server to a repo even if Codex is launched outside that repo (default uses cwd).
  • Add -c 'features.skills=false' for a minimal, deterministic background run.
  • Add -c 'delegate.mode=question_only' when the child only needs delegate.question.* (and optional delegate.status).
  • Add -c 'delegate.mode=full' when the child needs delegate.spawn/pause/cancel (nested delegation / run control).
  • If the task needs external docs or APIs, enable only the relevant MCP server for that environment.
  • If delegate.spawn is missing, re-register the MCP server with full mode (server config controls tool surface):

- codex mcp remove delegation - codex mcp add delegation --env 'CODEXMCPCONFIG_OVERRIDES=delegate.mode="full"' -- node /path/to/@kbediako/codex-orchestrator/dist/bin/codex-orchestrator.js delegate-server

  • To raise RLM budgets for delegated runs, re-register with an override (TOML-quoted):

- codex mcp add delegation --env 'CODEXMCPCONFIGOVERRIDES=rlm.maxsubcalldepth=8;rlm.wallclocktimeoutms=14400000' -- node /path/to/@kbediako/codex-orchestrator/dist/bin/codex-orchestrator.js delegate-server

For deeper background patterns and troubleshooting, see DELEGATION_GUIDE.md. For runner + delegation coordination (short --task flow), see docs/delegation-runner-workflow.md.

Delegation‑first policy

  • Default to delegation for top-level tasks and any non-trivial work.
  • Delegate when the work spans >1 domain, touches more than ~2 files, needs verification/research, or is likely to run >10 minutes.
  • Spawn one delegate per workstream with narrow scope and acceptance criteria.
  • Keep delegation MCP enabled by default; enable other MCPs only when relevant to the task.
  • For Playwright-heavy browser flows, use a dedicated child stream and keep parent context lean: artifact-first evidence, short summary in chat, no raw log dumps.
  • Use delegate.mode=question_only unless the child truly needs full tool access.
  • Ask delegates for short, structured summaries and to write details into files/artifacts instead of long chat dumps.
  • Use codex exec only for pre-task triage (no task id yet) or when delegation is unavailable; copy outcomes into the spec once it exists.

Workflow

0) One-time setup (register the MCP server)

  • Register the delegation server once:

- Preferred: codex-orchestrator setup --yes - One-shot bootstrap (installs bundled skills + configures delegation/DevTools wiring). - Optional low-friction MCP enable pass: codex-orchestrator mcp enable --yes - Enables disabled MCP servers from existing Codex config entries (plan mode redacts env/secret values in displayed command lines). - codex-orchestrator delegation setup --yes - Delegation-only setup (registers the direct dist transport and keeps wiring discoverable via codex-orchestrator doctor). - codex mcp add delegation -- node /path/to/@kbediako/codex-orchestrator/dist/bin/codex-orchestrator.js delegate-server - Optional: append --repo /path/to/repo to pin the server to one repo (not recommended if you work across repos). - delegate-server is the canonical name; delegation-server is supported as an alias. - codex-orchestrator delegation cleanup-stale --yes - Safe cleanup for orphaned delegate-server processes that are no longer rooted in a live Codex client.

  • Per-run -c 'mcp_servers.delegation.enabled=true' only works after registration.
  • If delegate.* tools are missing mid-task, start a new run with:

- codex -c 'mcp_servers.delegation.enabled=true' ... - Prefer using a background terminal (non-interactive) so you can continue without asking the user to relaunch.

  • If delegation is unavailable and the user asked to delegate, do not get stuck:

- Explain delegation is disabled or not registered in this run and give the enable command above. - Unless they explicitly want a delegation test, proceed locally using background tools (terminal commands or built-in tools) and deliver the result.

0a) Version guard (JSONL handshake)

  • Delegation MCP uses JSONL; keep codex-orchestrator aligned with the current CO compatibility or adoption target (codex-cli 0.135.0 for local ChatGPT-auth/appserver posture).
  • Current 0.135.0 CO-local posture keeps the onboarding-relevant behaviors from 0.124.0: codex exec accepts a prompt argument plus piped stdin, and codex login --device-auth is available for non-browser sign-in fallback.
  • App-server model/list evidence under ChatGPT auth can vary by account; keep gpt-5.4 only as the fallback packaged default because it may still appear as the app-server isDefault.
  • The bundled debug catalog can lag runtime posture briefly, and residual plugin warnings are local temporary plugin cache warnings rather than CO posture failures.

- Check installed version: codex-orchestrator --version - Preferred update path: npm i -g @kbediako/codex-orchestrator@latest - Deterministic pin path (for reproducible environments): npx -y @kbediako/codex-orchestrator@<version> delegate-server

  • Stock codex is the default path. If you use a custom Codex fork, fast-forward it regularly from upstream/main.
  • CO repo checkout only (helper is not shipped in npm): scripts/codex-cli-refresh.sh --repo /path/to/codex --align-only
  • CO repo checkout only (managed rebuild helper): scripts/codex-cli-refresh.sh --repo /path/to/codex --force-rebuild
  • Managed routing is explicit opt-in: export CODEXCLIUSE_MANAGED=1 (without this, stock/global codex stays active).
  • Add --no-push only when you intentionally want local-only alignment without updating origin/main.
  • npm-safe alternative (no repo helper): codex-orchestrator codex setup --source /path/to/codex --yes --force

0a.1) Agent role guard (avoid stale built-in defaults)

  • Built-in roles are default, explorer, worker, and awaiter. researcher is user-defined.
  • spawnagent omission defaults to default; require explicit agenttype for every spawn.
  • For symbolic collab runs, include a first-line role tag in spawned prompts: [agent_type:<role>].
  • Multi-turn subagent loops are supported (spawnagent -> sendinput -> wait/resumeagent -> closeagent).
  • In Codex CLI 0.135.0, built-in explorer continues to inherit top-level model defaults unless a role config_file overrides it.
  • Current model posture is gpt-5.5 / xhigh when available in ChatGPT-auth Codex sessions.
  • Portable generated config keeps gpt-5.4 / xhigh as fallback values.
  • Recommended packaged baseline in ~/.codex/config.toml:

- model = "gpt-5.4" - reviewmodel = "gpt-5.4" - modelreasoningeffort = "xhigh" - For normal features.multiagent=true and older Codex behavior, [agents] maxthreads = 12 is the seeded baseline. For Codex CLI 0.125+ with features.multiagentv2=true, do not write or recommend agents.maxthreads; upstream rejects the key, so doctor/default setup must omit it. For Codex CLI 0.128+, the v2-specific cap features.multiagentv2.maxconcurrentthreadspersession is user-owned tuning and CO does not seed it by default. Keep explicit maxdepth = 4 only when your local Codex parser accepts it, and treat maxspawndepth as a legacy local override rather than current baseline guidance - Leave [agents.explorer] undefined unless you intentionally want to override built-in explorer behavior - Optional [agents.explorerfast] -> ~/.codex/agents/explorer-fast.toml (gpt-5.3-codex-spark, file/codebase search only) - Optional [agents.awaiter] override -> ~/.codex/agents/awaiter-high.toml when you want awaiter at gpt-5.4 + high while preserving awaiter instructions - [agents.worker_complex] -> ~/.codex/agents/worker-complex.toml (gpt-5.4, xhigh)

  • Use gpt-5.5 for delegated/review surfaces when access smoke validates current ChatGPT-auth/appserver availability; otherwise use the portable gpt-5.4 fallback defaults.
  • Caveat: app-server isDefault may still report gpt-5.4 even when newer local models are available.
  • Fallback posture is contingency-only and applies only to v1/older configs that still accept thread/depth caps: 8/2 for constrained/high-risk lanes, legacy 6/1/1 as break-glass when an older parser/runtime still consumes spawn-depth caps.
  • Downstream users should converge on this baseline via codex-orchestrator init codex; when features.multiagentv2=true, init/default setup must omit agents.maxthreads and leave any features.multiagentv2.maxconcurrentthreadsper_session cap to explicit user-owned configuration.
  • If native codex startup fails with invalid type: integer ... expected struct AgentRoleToml under [agents], remove only the live maxdepth and maxspawn_depth keys from ~/.codex/config.toml and leave the role subtables unchanged.

0b) Background terminal bootstrap (required when MCP is disabled)

When delegate.* is missing in the current session, immediately spawn a background Codex run with delegation enabled and hand it the narrow task. Use codex exec so it completes without interaction and you can capture output:

codex exec \
  -c mcp_servers.delegation.enabled=true \
  "Use delegate.* tools to <task>. Return a short summary and any artifacts."

Guidance for background runs:

  • codex exec streams progress to stderr and prints the final message to stdout, so you can pipe or redirect safely.
  • Use --json for JSONL events, or -o <path> to write the final message to a file while still printing to stdout.
  • If you need a multi-step run, use codex exec resume --last "<follow-up>" to continue the same session.
  • Non-interactive runs can still hit confirmation_required; approvals happen via the UI/TUI and the run resumes after approval.
  • Use this only for non-manifest evidence; for manifest-required workflows, use codex-orchestrator start ....
  • codex exec does not create an orchestrator manifest. If the child must call delegate.question.* or delegate.status/pause/cancel, pass a real .runs/<task>/cli/<run>/manifest.json via parentmanifestpath/manifestpath (e.g., run codex-orch start diagnostics --format json --task <task-id> to get one; or use export MCPRUNNERTASKID=<task-id> if you prefer env vars).
  • Setting MCPRUNNERTASK_ID does not cause codex exec to emit .runs/** manifests; use codex-orchestrator start <pipeline> --task <id> when manifest evidence is required.

1) Keep delegation enabled by default

  • Set mcp_servers.delegation.enabled = true in ~/.codex/config.toml (only MCP on by default).
  • Disable delegation only when required by safety or environment constraints; re-enable per run with:

- codex -c 'mcp_servers.delegation.enabled=true' ...

  • Prefer codex-orch start <pipeline> --format json --task <task-id> over export MCPRUNNERTASK_ID=... for a shorter, explicit task id.

2) Spawn a delegate run (delegate.spawn)

  • Use delegate.spawn when you want a child run with a reduced tool surface.
  • Set delegate.mode explicitly: question_only or full.

- questiononly: only constrains the delegate. namespace (question queue + optional status). - full: enables the full delegate tool surface, including nested delegation. - Use full only when the child needs delegate.spawn/pause/cancel (nested delegation or run control). Other tools (shell/web/filesystem/etc) are governed by delegate.toolprofile + repo allowlists and can be available in question_only. - Note: github. registration is independent of delegate.mode and may still be available if repo-allowed.

  • Set delegate.tool_profile separately to the minimum necessary tools.

- Effective tool profile = intersection with repo delegate.allowedtoolservers. - If the repo omits delegate.allowedtoolservers, the cap defaults to [] and extra tools are ignored. - Names must match ^[A-Za-z0-9-]+$; invalid entries (e.g., ;, /, \n, =) are ignored. - github.* tools are not gated by delegate.toolprofile; they are controlled by repo GitHub allowlists.

  • If the child cannot access expected tools, recheck repo delegate.allowedtoolservers (it may have changed).
  • Keep delegate.tool_profile minimal; avoid networked tools unless required.
  • Nested delegation is off by default; only use full when delegate.allow_nested=true and you intend recursion.
  • Important: delegate.mode (server tool surface) is different from delegate_mode (input to delegate.spawn for the child run).
  • Note: delegate.spawn defaults to startonly=true and returns once a new manifest is detected; set startonly=false for legacy synchronous behavior (waits for child exit), which is subject to tool-call timeouts.

Minimal-context delegate instruction template

Goal: <one sentence>
Scope: <files/areas to touch>
Allowed tools: <tool_profile list>
Constraints: <must/ must-not>
Output: <patch + short summary>
Evidence: write detailed notes to artifacts/<name>.md (no long logs in chat)
Acceptance: <3-5 bullets>

3) Ask the parent a question (delegate.question.enqueue / poll)

  • Child calls delegate.question.enqueue to send an escalation to the parent run.
  • The parent/human answers via the UI/approval channel.
  • Child calls delegate.question.poll to fetch status/answer. wait_ms is capped to 10s per call. If you need longer waits, loop with brief pauses:
repeat:
  poll(wait_ms=10000)
  if status in {answered, expired, dismissed}: stop
  sleep/backoff briefly (e.g., 250–500ms, with jitter)
  • On expired, check fallbackaction (from delegate.question.expiryfallback) and follow it; default is pause.

4) Confirm‑to‑act behavior (delegate.cancel, github.merge)

  • Do not supply confirm_nonce. The runner injects it after approval.
  • If confirmation is required, you’ll receive confirmation_required and the run may pause.
  • Confirmations are only retried on confirmation‑specific error codes; generic errors are surfaced directly.
  • On confirmation_required, do not retry the action; wait for approval/resume. If it expires, re‑request with a fresh tool call.

5) Run identifiers (manifest paths)

  • Stateful calls require manifest_path (delegate.status/pause/cancel) to locate the run.
  • Question queue calls require parentmanifestpath for the same reason.

Common pitfalls

  • Long waits: wait_ms never blocks longer than 10s per call; use polling.
  • Long-running delegate.spawn: Prefer startonly=true (default) to avoid tool-call timeouts. If you must use startonly=false, keep runs short or run long jobs outside delegation (no question queue).
  • Cloud run branch mismatch: cloud-mode orchestration against a local-only branch can fail with couldn't find remote ref ...; set CODEXCLOUDBRANCH to a pushed branch (typically main) before cloud execution.
  • Cloud fallback dependence: fallback should be a safety net, not the default path; for fail-fast cloud lanes, set CODEXORCHESTRATORCLOUD_FALLBACK=deny.
  • Tool profile mismatch: child tool profile must be allowed by repo policy; invalid or unsafe names are ignored.
  • Confirmation misuse: never pass confirm_nonce from model/tool input; it is runner‑injected only.
  • Secrets exposure: never include secrets/tokens/PII in delegate prompts or files.
  • Missing control files: delegate tools rely on control_endpoint.json in the run directory; older runs may not have it.
  • Collab payload mismatch: spawn_agent rejects calls that include both message and items.
  • Collab role routing drift: if symbolic collab lifecycle validation reports missing/disallowed spawn roles, set explicit agenttype and add first-line [agenttype:<role>] tags.
  • Collab UI assumptions: agent rows/records are id-based today; use explicit stream role text in prompts/artifacts for operator clarity.
  • Collab lifecycle leaks: missing closeagent calls accumulate open threads and can trigger agent thread limit reached; always finish spawn -> wait -> closeagent per id.
  • False "unexpected edits" stops: when a live subagent owns the touched files, treat those edits as expected output and continue with scope-aware review.

Related skills

  • collab-subagents-first: for stream decomposition and parent/subagent ownership discipline.
  • collab-deliberation: for option generation before implementation when decisions are ambiguous/high-impact.
  • standalone-review: for checkpoint reviews after delegated implementation streams.
  • long-poll-wait: for patience-first monitoring of long-running delegated/cloud jobs.