SHIFT — Multi-Identity Delegation Skill
One agent. Many specialists. One conversation.
⚠️ SECURITY AND PRIVACY — READ BEFORE ENABLING
What SHIFT Accesses
SHIFT reads from your OpenClaw workspace:
- -
~/.openclaw/workspace/MEMORY.md — excerpts attached to delegation context - INLINECODE1 — your persona and cost settings
- Session files it creates in INLINECODE2
SHIFT writes to:
- -
~/.openclaw/workspace/.shift/sessions/<runId>/ — per-delegation session files - INLINECODE4 — delegation cost tracking
- INLINECODE5 — your persona overrides
What SHIFT Transmits
When you enable delegation, the following are sent to whatever model providers you configure for each persona:
- - Your message content
- Conversation history (last N turns, controlled by
contextBridge.historyTurns) - Active file contents and MEMORY.md excerpts relevant to the task
- Delegation metadata (runId, timestamps, persona name)
You control which models are used. SHIFT does not ship with or store credentials — it uses the model providers configured in your OpenClaw agent config. Review your provider's data handling policy.
Data Exposure Risk
If your workspace files or MEMORY.md contain secrets (API keys, credentials, private data), and those files are referenced in a delegated task, that content will be transmitted to your configured model provider.
Mitigations:
- - Do not delegate tasks that reference sensitive file paths
- Set
contextBridge.historyTurns to a low number (e.g., 3) - Use
costManagement.trackOnly: true during evaluation to observe behavior without enforcement - Use trusted or self-hosted model providers for sensitive work
Setup Script
INLINECODE9 creates local directories only. It does NOT:
- - Make network calls
- Escalate privileges
- Modify system files
- Access credentials
Cost and Consultations
Consultations spawn additional model calls. Costs are tracked in cost-tracking.json per delegation. Set costManagement.trackOnly: true to monitor before enforcing limits.
Recommendations
- 1. Start with
costManagement.trackOnly: true to observe costs - Set
contextBridge.historyTurns to a small number (5 or less) - Set
contextBridge.archiveAfterMinutes: 30 for faster cleanup - Do not delegate tasks referencing sensitive file paths
- Review model providers' data policies before sensitive work
Triggers on: any message that might benefit from specialized handling — coding tasks, research, analysis, quick lookups, or anything that warrants delegating to a sub-identity.
When SHIFT triggers, you read and follows the procedures below to: classify the task, delegate to the right sub-identity, handle consultation between sub-identities, and synthesize the final response in his own voice.
SHIFT Procedures
Follow these steps for every message that triggers SHIFT.
STEP 1 — Fast Path Check
Before anything, check if this message is trivially handled by you directly.
Bypass delegation (return none) if message is ONLY:
- - Greetings:
hi, hey, hello, yo, INLINECODE20 - Acknowledgments:
thanks, thank you, ty, ok, sure, got it, makes sense, cool, INLINECODE29 - Meta:
that was fast, nice one, lol, INLINECODE33
If none of those match, proceed to STEP 2.
STEP 2 — Load Config
Read the SHIFT config at:
CODEBLOCK0
If the file doesn't exist, run the setup script first:
CODEBLOCK1
From config, extract:
- -
displayMode — hidden or INLINECODE36 - INLINECODE37 —
conservative or INLINECODE39 - INLINECODE40 ,
costManagement.costBudgetPerHour, INLINECODE42 - INLINECODE43 , INLINECODE44
- INLINECODE45 — enabled personas and their settings
STEP 3 — Cost Budget Check
If costManagement.enabled: true:
Read ~/.openclaw/workspace/.shift/cost-tracking.json:
CODEBLOCK2
If current UTC hour > hourStart (new hour):
→ Reset totalSpend: 0, update hourStart to current hour.
If totalSpend >= costBudgetPerHour:
→ You handle the task directly. Say: "Handling this one myself to stay within your cost budget."
Return budget_exceeded.
If totalSpend >= alertThreshold * costBudgetPerHour:
→ Send a quiet warning: "Approaching delegation budget limit for this hour."
STEP 4 — Route to Persona
Using the enabled personas from config, classify the user's message.
Keyword Scoring
For each enabled persona, count keyword matches in the user's message (case-insensitive, whole-word). Raw score = matches / total keywords.
If raw score >= minConfidence: Add to candidates.
Runner special case: Runner has requireExplicit: true. It only triggers if the message is predominantly a Runner task, not just containing a keyword. If the message has strong code/research keywords, Runner is NOT a match even if it has Runner keywords.
Tie-Breaking
If multiple personas score above threshold:
→ Higher score wins. If tied: codex > researcher > runner.
Default
If no persona scores above threshold → You handle directly. Return none.
STEP 5 — Prepare Delegation Context
Generate a unique runId:
CODEBLOCK3
Create the session folder:
CODEBLOCK4
Write INBOUND.json
CODEBLOCK5
Write CONTEXT.md
Pull from:
- -
~/.openclaw/workspace/MEMORY.md (keyword-matched relevant sections) - Any active file contents mentioned in the conversation
- Persona-specific context needs (from the persona definition in config)
Format:
# Context for {persona}
## Project/Memory (relevant)
...
## Active Files
...
## Persona Context Needs
...
STEP 6 — Build Task Prompt
Construct the prompt for the sub-agent:
CODEBLOCK7
STEP 7 — Spawn Sub-Agent
CODEBLOCK8
Track elapsed time. If elapsed > timeout * 0.7:
→ Send status to user: "{persona} is still working on this..."
STEP 8 — Wait and Read Result
Wait for sessions_spawn to complete.
Read OUTBOUND.md
From the session folder:
CODEBLOCK9
Parse:
- -
Status: complete | error | INLINECODE63 - INLINECODE64 : the actual response content
- INLINECODE65 : if sub-identity consulted another
- INLINECODE66 : token counts if available
Check for ESCALATE.md (Runner only)
If Status: escalation:
→ Runner detected the task was too complex. You take over directly.
→ Read reason, summary, partialAnswer from ESCALATE.md.
→ Incorporate any partial work Runner did.
STEP 9 — Update Cost Tracking
After successful delegation, update cost-tracking.json:
CODEBLOCK10
STEP 10 — Synthesize Response
Transform the sub-identity's output into your voice.
Detection
If ConsultationLog is present and non-empty:
→ Build consultation mention (ALWAYS shown):
CODEBLOCK11
Transformation Rules
| Sub-identity output | your transformation |
|---|
| Code | Explain what it does in plain English, highlight key parts, offer to add tests |
| Analysis/Research |
Pull 2-3 key insights, bullet-point them, note caveats |
| Quick answer (Runner) | Relay directly with warmth added |
Display Mode
Hidden (default):
CODEBLOCK12
Transparent:
CODEBLOCK13
Consultation mentions are ALWAYS shown in both modes.
STEP 11 — Handle Errors
| Scenario | Response |
|---|
| Sub-agent timeout | "Looks like this one is taking longer than expected — let me work through it directly." |
| Sub-agent error |
"Hit a snag with the specialist — let me handle this myself." |
| sessions_spawn fails | Fall back to your handling directly |
| OUTBOUND.md missing | Assume sub-agent failed, You handle directly |
| Model unavailable | Log warning, You handle directly |
Consultation Protocol (Master-Orchestrated)
Key insight: Sub-agent sessions cannot cleanly spawn child sessions and wait. The solution: You orchestrate the consultation from the master level.
Flow
CODEBLOCK14
Sub-Agent Side (Codex/Researcher)
When a sub-agent needs to consult another sub-identity:
- 1. Check: is target in my
consults list? Is target NOT in my consultsNever? - Write
CONSULT-INBOUND.md to the session folder with the question + context - Write
OUTBOUND.md with:
## Status: needs_consultation
## PartialResult
(what Codex has done/understood so far)
## ConsultationLog
- consulted: researcher
- question: "..."
- status: pending
- 4. End response with
[NEEDS_CONSULTATION] instead of INLINECODE78 - Stop — You will take over from here
Master Side
When reading OUTBOUND.md after a sub-agent returns:
STEP 8a — Detect Consultation Need
If Status: needs_consultation is present:
- 1. Read
ConsultationLog to get target and question - Read
CONSULT-INBOUND.md for full context - Send user update (transparent mode): INLINECODE82
- Proceed to STEP 8b
STEP 8b — Run Consultation
CODEBLOCK16
STEP 8c — Feed Result Back
After consultation completes:
- 1. Read INLINECODE83
- Append consultation answer to
CONTEXT.md:
## Consultation Answer from {target}
{answer from CONSULT-OUTBOUND.md}
- 3. Re-spawn the original sub-agent with enriched context:
CODEBLOCK18
STEP 8d — Final Result
When re-spawned sub-agent completes:
- 1. Read final INLINECODE85
- INLINECODE86 should now be INLINECODE87
- Proceed to STEP 10 (Synthesis)
Consultation is always mentioned to the user — not gated by display mode.
Depth Limit
Max consultation depth = 1. A sub-agent that was consulted CANNOT consult anyone else. This is enforced by: the consultation re-spawn prompt does NOT include the consultation protocol section. Only the first-level sub-agent has it.
Timeout Handling
- - If consultation times out: You fall back to Codex's partial result + own knowledge
- You warn: "{target} took too long — Codex will continue without that context."
- Partial result (if any) is still used
Commands
/shift status
Show current SHIFT status:
- - Which personas are enabled
- Current cost budget status
- Display mode
/shift mode hidden|transparent
Toggle display mode. Updates config.yaml.
/shift fastpath on|off
Toggle fast-path mode.
/delegate \ \
Explicitly delegate a task to a specific persona, ignoring keyword routing.
Config Reference
Full schema at: INLINECODE88
Key settings:
CODEBLOCK19
Session Files
All delegation session files live at:
CODEBLOCK20
Files:
- -
INBOUND.json — delegation input - INLINECODE90 — project context
- INLINECODE91 — sub-identity result
- INLINECODE92 — Runner escalation (if any)
- INLINECODE93 — consultation input
- INLINECODE94 — consultation result
Auto-archived after contextBridge.archiveAfterMinutes (default: 60min).
SHIFT — one brain, many specialists.
SHIFT — 多重身份委派技能
一个智能体。多个专家。一次对话。
⚠️ 安全与隐私 — 启用前请阅读
SHIFT 访问的内容
SHIFT 从您的 OpenClaw 工作区读取:
- - ~/.openclaw/workspace/MEMORY.md — 附加到委派上下文的摘录
- ~/.openclaw/workspace/.shift/config.yaml — 您的角色和成本设置
- 它在 ~/.openclaw/workspace/.shift/sessions/ 中创建的会话文件
SHIFT 写入:
- - ~/.openclaw/workspace/.shift/sessions// — 每次委派的会话文件
- ~/.openclaw/workspace/.shift/cost-tracking.json — 委派成本跟踪
- ~/.openclaw/workspace/.shift/personas/*.yaml — 您的角色覆盖设置
SHIFT 传输的内容
当您启用委派时,以下内容将发送给您为每个角色配置的任何模型提供商:
- - 您的消息内容
- 对话历史(最近 N 轮,由 contextBridge.historyTurns 控制)
- 与任务相关的活动文件内容和 MEMORY.md 摘录
- 委派元数据(runId、时间戳、角色名称)
您控制使用哪些模型。 SHIFT 不附带也不存储凭据——它使用您在 OpenClaw 智能体配置中配置的模型提供商。请查看您提供商的数据处理政策。
数据暴露风险
如果您的工作区文件或 MEMORY.md 包含机密信息(API 密钥、凭据、私人数据),并且这些文件在委派任务中被引用,那么这些内容将被传输给您配置的模型提供商。
缓解措施:
- - 不要委派引用敏感文件路径的任务
- 将 contextBridge.historyTurns 设置为较小的数字(例如 3)
- 在评估期间使用 costManagement.trackOnly: true 观察行为而不强制执行
- 对敏感工作使用受信任或自托管的模型提供商
设置脚本
scripts/setup.sh 仅创建本地目录。它不会:
成本与咨询
咨询会触发额外的模型调用。成本按每次委派记录在 cost-tracking.json 中。设置 costManagement.trackOnly: true 可在强制执行限制前进行监控。
建议
- 1. 从 costManagement.trackOnly: true 开始观察成本
- 将 contextBridge.historyTurns 设置为较小的数字(5 或更少)
- 设置 contextBridge.archiveAfterMinutes: 30 以加快清理
- 不要委派引用敏感文件路径的任务
- 在敏感工作前查看模型提供商的数据政策
触发条件:任何可能受益于专业处理的消息——编码任务、研究、分析、快速查询,或任何值得委派给子身份的任务。
当 SHIFT 触发时,您阅读并遵循以下程序:分类任务、委派给正确的子身份、处理子身份之间的咨询,并以自己的语气综合最终响应。
SHIFT 程序
对每条触发 SHIFT 的消息,请遵循以下步骤。
步骤 1 — 快速路径检查
在此之前,检查此消息是否可由您直接轻松处理。
如果消息仅为以下内容,则绕过委派(返回 none):
- - 问候语:hi、hey、hello、yo、sup
- 确认语:thanks、thank you、ty、ok、sure、got it、makes sense、cool、nice
- 元评论:that was fast、nice one、lol、haha
如果以上都不匹配,则继续执行步骤 2。
步骤 2 — 加载配置
读取 SHIFT 配置:
~/.openclaw/workspace/.shift/config.yaml
如果文件不存在,请先运行设置脚本:
bash
bash ~/.openclaw/workspace/skills/shift/scripts/setup.sh
从配置中提取:
- - displayMode — hidden 或 transparent
- fastPath — conservative 或 off
- costManagement.enabled、costManagement.costBudgetPerHour、costManagement.alertThreshold
- contextBridge.historyTurns、contextBridge.sessionFolder
- personas — 启用的角色及其设置
步骤 3 — 成本预算检查
如果 costManagement.enabled: true:
读取 ~/.openclaw/workspace/.shift/cost-tracking.json:
json
{
hourStart: 2026-03-18T15:00:00Z,
totalSpend: 0.87,
delegations: [...]
}
如果当前 UTC 小时 > hourStart(新的一小时):
→ 重置 totalSpend: 0,将 hourStart 更新为当前小时。
如果 totalSpend >= costBudgetPerHour:
→ 您直接处理任务。说:为了保持在您的成本预算内,我亲自处理这个。
返回 budget_exceeded。
如果 totalSpend >= alertThreshold * costBudgetPerHour:
→ 发送静默警告:即将达到本小时的委派预算限制。
步骤 4 — 路由到角色
使用配置中启用的角色,对用户的消息进行分类。
关键词评分
对于每个启用的角色,计算用户消息中关键词的匹配次数(不区分大小写,整词匹配)。原始分数 = 匹配数 / 总关键词数。
如果原始分数 >= minConfidence: 添加到候选列表。
Runner 特殊情况: Runner 有 requireExplicit: true。它仅在消息主要是 Runner 任务时触发,而不仅仅是包含关键词。如果消息有强烈的代码/研究关键词,即使包含 Runner 关键词,Runner 也不匹配。
平局处理
如果多个角色的分数超过阈值:
→ 分数高的获胜。如果平局:codex > researcher > runner。
默认
如果没有角色的分数超过阈值 → 您直接处理。返回 none。
步骤 5 — 准备委派上下文
生成唯一的 runId:
run-{YYYYMMDD}-{HHMM}-{persona}-{sequence}
示例:run-20260318-1551-codex-001
创建会话文件夹:
~/.openclaw/workspace/.shift/sessions/{runId}/
写入 INBOUND.json
json
{
runId: ,
timestamp: ,
persona: <匹配的角色>,
userMessage: <确切的用户消息>,
masterConversationHistory: <对话的最后 N 轮>,
activeFiles: <提到的文件>,
masterSummary: <到目前为止对话的简要总结>
}
写入 CONTEXT.md
从以下来源提取:
- - ~/.openclaw/workspace/MEMORY.md(关键词匹配的相关部分)
- 对话中提到的任何活动文件内容
- 角色特定的上下文需求(来自配置中的角色定义)
格式:
markdown
{persona} 的上下文
项目/记忆(相关)
...
活动文件
...
角色上下文需求
...
步骤 6 — 构建任务提示
为子智能体构建提示:
markdown
您是 {persona_name}
角色
{来自配置的角色声音、语气、优势、盲点}
您的任务
{用户的确切消息}
上下文
开始前,请阅读:
- - /path/to/INBOUND.json — 您的输入和对话历史
- /path/to/CONTEXT.md — 相关项目上下文
您的协议
- 1. 阅读 INBOUND.json 和 CONTEXT.md
- 执行您的任务
- 如果您需要咨询另一个子身份且您的角色允许:
- 将您的问题写入会话文件夹,命名为 CONSULT-INBOUND.md
- 设置超时:min(剩余时间 * 0.5, 您的 consultationTimeout)
- 使用 sessions_spawn 生成目标子身份
- 等待他们写入 CONSULT-OUTBOUND.md
- 读取他们的响应并在该上下文中继续
- 4. 将您的最终结果写入 /path/to/OUTBOUND.md
- 如果您咨询了任何人,请包含 ConsultationLog
- 以 [DONE] 结束您的响应
步骤 7 — 生成子智能体
javascript
sessions_spawn({
model: personaConfig.model,
task: taskPrompt,
label: shift-${person