knowledge-session-state-and-context-active-turn-interactions-and-recovery

knowledge-session-state-and-context-active-turn-interactions-and-recovery is a skill for Claude Code, Codex from echoVic/blade-code. It costs 161 tokens per session (2,789 once invoked), scanned A, original, MIT.

A session runtime component that coordinates the current task, user input, permissions, questions, and recovery after a crash or restart.

In plain words
What is it for?
It is for managing one active turn, safely resuming interrupted sessions, handling user prompts, and running bounded shell commands owned by a session.
Why use it?
It prevents overlapping work and preserves pending interactions when the process stops unexpectedly. It also keeps side questions and shell commands from corrupting the main conversation.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents.

Good fit It is for managing one active turn, safely resuming interrupted sessions, handling user prompts, and running bounded shell commands owned by a session.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/echovic/blade-code/active-turn-interactions-and-recovery
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add echoVic/blade-code --skill active-turn-interactions-and-recovery
Clone the repo
git clone --depth 1 https://github.com/echoVic/blade-code

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for knowledge-session-state-and-context-active-turn-interactions-and-recovery

README.md
[![agentmods](https://agentmods.dev/badge/skills/echovic/blade-code/active-turn-interactions-and-recovery.svg)](https://agentmods.dev/skills/echovic/blade-code/active-turn-interactions-and-recovery)
Your own site
<a href="https://agentmods.dev/skills/echovic/blade-code/active-turn-interactions-and-recovery"><img src="https://agentmods.dev/badge/skills/echovic/blade-code/active-turn-interactions-and-recovery.svg" alt="Measured on agentmods" height="20"></a>
Per session 161 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00161 $0.02789
Opus 5 $0.00081 $0.01394
Sonnet 5 $0.00032 $0.00558
Haiku 4.5 $0.00016 $0.00279

Measured 4d ago against content hash 21ec31e691d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

knowledge-session-state-and-context-active-turn-interactions-and-recovery scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.trae/knowledges/session-state-and-context/active-turn-interactions-and-recovery/SKILL.md · 75 lines

How it starts

The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Module Structure

该节点管理“当前 Session 此刻能做什么”以及进程退出后如何继续。内存 mailbox 负责原子状态转换,sidecar 保存未确认输入,JSONL 保存 turn/tool/interaction receipt,SessionRuntime 在持有 lease 后协调恢复。

Directory Layout

  • packages/cli/src/agent/runtime/ActiveTurnMailbox.ts:单活动 turn、claim/seal/ack 与输入容量
  • packages/cli/src/agent/runtime/DurableSteeringInbox.ts:crash-safe pending input sidecar
  • packages/cli/src/agent/runtime/SessionLease.ts:跨进程 Session owner 锁
  • packages/cli/src/agent/runtime/ActiveOperationGate.ts:关闭时停止接纳、取消并排空活动操作
  • packages/cli/src/agent/runtime/UserPromptArtifactStore.ts:大型用户请求的私有内容寻址存储
  • packages/cli/src/agent/runtime/SessionRuntime.ts:初始化、turn 终态、恢复和辅助交互编排
  • packages/cli/src/context/interactions.ts:interaction request/response/recovery projector
  • packages/cli/src/services/SessionInteractionService.ts:durable 交互协议
  • packages/cli/src/services/SideConversationService.ts:不改变主历史的一次性旁路问答
  • packages/cli/src/services/UserShellCommandService.ts:Session-owned 用户命令执行与有界输出

Key Entry Points

  • SessionRuntime.initialize() in packages/cli/src/agent/runtime/SessionRuntime.ts:获取 lease 并修复 orphan 状态
  • ActiveTurnMailbox.prepareInputTurn() / enqueue() in packages/cli/src/agent/runtime/ActiveTurnMailbox.ts:原子接纳首轮输入或 steering
  • PersistentStore.recoverInterruptedTurn() in packages/cli/src/context/storage/PersistentStore.ts:关闭 orphan tool call 与未终止 turn
  • SessionInteractionService.resolvePendingWithHandler() in packages/cli/src/services/SessionInteractionService.ts:重放未回答交互
  • SessionRuntime.executeUserShellCommand() in packages/cli/src/agent/runtime/SessionRuntime.ts:执行、持久化并安全注入用户命令结果

Gotchas

  • isActive() 在 turn sealed 后返回 false,但 hasTurnOwner() 仍为 true;切模型、reload inbox、fork/rewind 等互斥判断必须选择正确谓词,不能把“不能再接当前 turn steering”误当作“没有 owner” (packages/cli/src/agent/runtime/ActiveTurnMailbox.ts, packages/cli/src/agent/runtime/SessionRuntime.ts)
  • drainOrSeal() 在同一个 mutex 临界区内“发现新消息或封口”,封口后到达的输入必须标记 next_turn;拆开检查与 seal 会丢失边界竞态 (packages/cli/src/agent/runtime/ActiveTurnMailbox.ts)
  • claimed 只代表当前 turn 已取走,并不代表 durable 完成;正常终态先原子提交 inbox acknowledgement 与 turn_completed,成功后才从 sidecar 删除 (packages/cli/src/agent/runtime/SessionRuntime.ts, packages/cli/src/context/storage/PersistentStore.ts)
  • abort 默认不确认输入,使进程故障、取消和暂态失败可在冷启动重放;只有显式 acknowledgeInput 或 terminal queue-full 等确定性边界才能消费对应 ID (packages/cli/src/agent/runtime/SessionRuntime.ts, packages/cli/src/context/storage/PersistentStore.ts)
  • prepareInputTurn() 总是先把输入持久到 inbox 再建立 owner;若已有旧 pending input,新 prompt 排在其后且返回 mode: pending,不能越过恢复输入直接执行 (packages/cli/src/agent/runtime/ActiveTurnMailbox.ts)
  • user steering 上限为 20 条且受内容/schema/metadata 合并预算约束;background completion 独立使用 100 条与约 7 MiB 预算,但所有来源最终还共享 8 MiB inbox 文件硬上限 (packages/cli/src/agent/runtime/ActiveTurnMailbox.ts, packages/cli/src/agent/runtime/DurableSteeringInbox.ts)
  • 指定相同 message ID 的重复 enqueue 被视为幂等成功;调用方必须复用 durable identity,不能在 retry 时生成新 ID 导致重复 follow-up (packages/cli/src/agent/runtime/ActiveTurnMailbox.ts)
  • inbox 打开时会用 JSONL acknowledgement 和已应用的 abort receipt 过滤消息,并把剩余项标记 recovered;损坏或超 8 MiB 的 sidecar 直接 fail closed (packages/cli/src/agent/runtime/DurableSteeringInbox.ts)
  • Session lease 只有在 PID 存活且进程启动身份仍匹配时才阻止新 owner;PID 被复用会回收旧锁,release 也会核对 ownerId 以免删除后来 owner 的锁 (packages/cli/src/agent/runtime/SessionLease.ts)
  • Runtime 必须先取得 Session lease,再依次修复 foreground/background 进程、patch、subagent、mailbox、orphan tool/turn 和 Goal receipt;初始化中途失败会调用 dispose 释放部分资源 (packages/cli/src/agent/runtime/SessionRuntime.ts, git:8cd32a8a)
  • 通用 interrupted-turn recovery 不处理仍有 pending durable interaction 的 tool call,该调用必须留给专用 interaction recovery,避免先写 uncertain result 再重放问题 (packages/cli/src/context/storage/PersistentStore.ts, docs/reference/durable-pending-interactions.md)
  • interaction request 只有在所属 tool call 已 durable commit 后才能展示,且 request/response 各自不得超过 128 KiB;否则 UI 不应看到不可恢复的问题 (packages/cli/src/services/SessionInteractionService.ts)
  • interaction 恢复不会重放原工具:它先用原 toolCallId 写带 provenance 的关闭结果,再把用户决定写入 inbox,最后提交 interaction_recovered (packages/cli/src/services/SessionInteractionService.ts)
  • MCP elicitation 的 durable response 只保留 action、reason 与是否打开 URL,不保存表单 content;重启后若仍需要敏感字段必须重新请求 (packages/cli/src/services/SessionInteractionService.ts, docs/reference/durable-pending-interactions.md)
  • 大 prompt 超过内联阈值后,JSONL/inbox 仅保存有界头尾、图片布局和 SHA-256 引用;artifact 缺失、被篡改、权限不为私有或 layout 不一致时必须在 Provider 前失败 (packages/cli/src/agent/runtime/UserPromptArtifactStore.ts)
  • 旁路问答复制当前 messages 并使用独立 provider session ID,返回中的任何 tool call 都被拒绝;问题和答案都不进入主 transcript,也不能驱动主任务 (packages/cli/src/services/SideConversationService.ts, git:761e85e9)
  • 用户 Shell 在活动 turn 中必须“先保存 JSONL,再以 persisted auxiliary steering 入队”;若 turn 已封口则进入下一 turn,不能发布完成事件后再补持久化 (packages/cli/src/agent/runtime/SessionRuntime.ts, docs/reference/session-user-shell-command.md)
  • user shell 的 live stream 与最终 capture 是独立预算;binary 检测后只保留字节摘要,completed 事件还必须等待异步 output callback 全部 drain (packages/cli/src/services/UserShellCommandService.ts)

Read the full file on GitHub · 75 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 75 lines · 161 tokens per session scan A 21ec31e691d9

Subscribe to this mod's changes

knowledge-session-state-and-context-active-turn-interactions-and-recovery is a skill published in the GitHub repository echoVic/blade-code (178 stars, last pushed yesterday), licensed MIT. It adds 161 tokens to every session and 2,789 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright…

alleneee/skill-agent · 62 tokens

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external agents through well-designed tools. Use when building MCP servers to integrate external APIs or agents, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

alleneee/skill-agent · 61 tokens

slack-gif-creator

Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives. This skill applies when users request animated GIFs or emoji animations for Slack from descriptions like "make me a GIF for Slack of X doing Y".

alleneee/skill-agent · 57 tokens

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

alleneee/skill-agent · 59 tokens

self-improvement

A process for recording useful lessons from unexpected failures, user corrections, missing abilities, and reusable project patterns.

alleneee/skill-agent · 60 tokens

travel-planner

Creates comprehensive travel itineraries with destination analysis, budget planning, transportation, accommodation, and local insights. Use when planning trips, organizing travel schedules, or seeking destination recommendations.

alleneee/skill-agent · 38 tokens