From sidekick
Canonical Kay delegation workflow for the Kay sidekick. Use when activating Kay mode before delegated implementation work.
How this agent operates — its isolation, permissions, and tool access model
Agent reference
sidekick:agents/codex/kay-delegate/skillThe summary Claude sees when deciding whether to delegate to this agent
Kay is the implementation sidekick. The host AI plans, explains, and verifies. Kay writes files, runs tests, and executes implementation work. ``` Host AI = Brain Kay = Hands ``` - Claude Code, Codex, and Cursor hosts all follow STEP 0 through STEP 3. - When the active host is Codex, treat Kay as a child execution process launched through `kay exec`; do not confuse host Codex planning work ...
Kay is the implementation sidekick. The host AI plans, explains, and verifies. Kay writes files, runs tests, and executes implementation work.
Host AI = Brain
Kay = Hands
kay exec; do not confuse host Codex planning work with delegated Kay implementation work.kay exec; Cursor's sessionStart hook binds SIDEKICK_SESSION_ID before activation, and sessionEnd clears session-scoped delegation markers.While Kay mode is active, the host AI remains the user-interactor, orchestrator, verifier, advisor, and mentor. Kay is the primary implementation executor.
The host keeps freedom to:
git status, git diff, bash tests/*.bash, and similar).planning/ and site/Sidekick hooks narrow enforcement to implementation ownership: direct Write/Edit/Delete on implementation files is denied on Claude/Codex hosts and surfaced as an advisory on Cursor via postToolUse. Delegate implementation through kay exec --full-auto.
The stop workflow lives canonically in kay-stop/SKILL.md in this generated codex skill root (agents/codex/kay-stop/SKILL.md in the repository).
Kay readiness is checked when delegation starts for the current session. SessionStart does not update or repair the Kay runtime; if the health check fails, guide the user through the Kay setup or login path below.
Before delegating, verify the runtime is available:
for candidate in kay code coder; do
if command -v "$candidate" >/dev/null 2>&1 \
&& "$candidate" --version 2>/dev/null | grep -qiE '^kay([[:space:]]|$)' \
&& "$candidate" exec --help >/dev/null 2>&1; then
KAY_RUNTIME="$candidate"
break
fi
done
test -n "${KAY_RUNTIME:-}" || { echo "No Kay-compatible runtime found"; exit 1; }
Then verify Kay config:
$CODE_HOME/config.toml defaults to ~/.kay/config.toml~/.code/config.toml and ~/.codex/config.toml are compatibility-onlyocg or opencode-go -> OpenCode Go routingxiaomi -> Xiaomi routingopencode-go. SIDEKICK_KAY_PROVIDER and SIDEKICK_KAY_MODEL_PROVIDER remain supported as environment overrides.opencode-go keeps the existing task-based routing:
mimo-v2.5-promimo-v2.5minimax-m2.7deepseek-v4-flashxiaomi uses provider-specific routing:
mimo-v2.5mimo-v2.5-proIf login is missing, guide the user to:
kay login --provider opencode-go --with-api-key
For Xiaomi-backed sessions, use:
kay login --provider xiaomi --with-api-key
and configure Xiaomi's OpenAI-compatible base URL plus API key in Kay before launching.
If kay is unavailable, install or repair Kay. The code and coder names are compatibility aliases only. The codex binary name is reserved for the real OpenAI Codex CLI.
Create the current-session Kay marker before delegating so Sidekick hooks can enforce direct-edit denial, inject --full-auto, surface bounded redacted Kay output with [KAY] and [KAY-SUMMARY] markers, and maintain .kay/conversations.idx.
Provider argument handling:
xiaomi, set SIDEKICK_KAY_PROVIDER_ARG=xiaomi before running the activation block.ocg or opencode-go, set SIDEKICK_KAY_PROVIDER_ARG=ocg before running the activation block.SIDEKICK_KAY_PROVIDER_ARG unset and use the default OpenCode Go routing.SIDEKICK_SESSION="${SIDEKICK_SESSION_ID:-${CODEX_THREAD_ID:-${SESSION_ID:-}}}"
test -n "${SIDEKICK_SESSION}" || { echo "No host session id found for Kay mode"; exit 1; }
KAY_PROVIDER_INPUT="${SIDEKICK_KAY_PROVIDER_ARG:-${SIDEKICK_KAY_PROVIDER:-${SIDEKICK_KAY_MODEL_PROVIDER:-opencode-go}}}"
case "${KAY_PROVIDER_INPUT}" in
""|ocg|opencode-go)
KAY_PROVIDER="opencode-go"
;;
xiaomi)
KAY_PROVIDER="xiaomi"
;;
*)
echo "Unsupported Kay provider: ${KAY_PROVIDER_INPUT}. Use ocg or xiaomi."; exit 1
;;
esac
KAY_STATE_ROOT="${HOME}/.kay"
CODEX_STATE_ROOT="${HOME}/.codex"
mkdir -p "${KAY_STATE_ROOT}/sessions/${SIDEKICK_SESSION}" \
"${HOME}/.sidekick/sessions/${SIDEKICK_SESSION}"
rm -f "${CODEX_STATE_ROOT}/sessions/${SIDEKICK_SESSION}/.codex-delegation-active"
printf '%s\n' "kay" > "${HOME}/.sidekick/sessions/${SIDEKICK_SESSION}/active-sidekick"
printf '%s\n' "${KAY_PROVIDER}" > "${HOME}/.sidekick/sessions/${SIDEKICK_SESSION}/kay-provider"
: > "${KAY_STATE_ROOT}/sessions/${SIDEKICK_SESSION}/.kay-delegation-active"
Session-scoped markers only:
~/.sidekick/sessions/<session>/active-sidekick — shared selector (kay or codex)~/.kay/sessions/<session>/.kay-delegation-active — Kay enforcement marker~/.sidekick/sessions/<session>/kay-provider — optional provider persistenceDelegation ends when the host session ends (Cursor sessionEnd hook clears markers) or when /sidekick:kay-stop runs. Do not use project-level or repo-root activation markers.
Kay and Codex are mutually exclusive per host session. Kay activation clears any current-session Codex marker and writes active-sidekick=kay, so the Codex hook becomes a no-op before Kay commands start.
Confirm: "Kay sidekick mode activated for this session using <provider>. Delegating implementation work to Kay."
To stop: /sidekick:kay-stop
Child runtime command used after Kay mode is active:
kay exec --full-auto "<task description>"
Compatibility aliases (code, codex, coder) accept the same arguments when an older environment only exposes them.
Sidekick injects the selected provider and task-specific model automatically when Kay mode is active. Do not hand-add -c model_provider=... or -c model=... unless you are debugging the routing layer.
Useful options:
--json for machine-readable progress--output-last-message for final-response-only outputresume --last to continue prior non-interactive sessionskay exec automation for file changes, tests, and commits.AGENTS.md instructions.Use this loop after every sidekick task or subtask before reporting completion, starting dependent work, or accepting a sidekick STATUS: SUCCESS. Treat STATUS: SUCCESS as a claim to audit, not proof.
Verification checklist:
MISSED_REQUIREMENT, INTEGRATION_ERROR, REGRESSION, WRONG_LOGIC, SYNTAX_ERROR, WRONG_FILE, UNVERIFIED_ASSUMPTION, KNOWLEDGE_GAP, MISUNDERSTOOD_TASK, TRIAL_INCOMPLETE, API_FAILURE, EXECUTION_ERROR_EXTERNAL.Recovery protocol:
TRIAL_INCOMPLETE, API_FAILURE, or EXECUTION_ERROR_EXTERNAL, do not treat partial output as complete; retry after the model provider or environment is usable, or report the external blocker with evidence.The host AI only reports completion after its own verification evidence supports the result.
npx claudepluginhub alo-exp/sidekick --plugin sidekickVerifies open-source forks are fully sanitized by scanning for leaked secrets, PII, internal references, and dangerous files. Generates a PASS/FAIL/WARNINGS report. Read-only.