Skip to content

docs: design for session state, compaction, and pluggable permissions#183

Open
rdwj wants to merge 2 commits into
mainfrom
docs/session-state-compaction-design
Open

docs: design for session state, compaction, and pluggable permissions#183
rdwj wants to merge 2 commits into
mainfrom
docs/session-state-compaction-design

Conversation

@rdwj
Copy link
Copy Markdown
Contributor

@rdwj rdwj commented May 7, 2026

Summary

Adds planning/session-state-compaction-design.md — the foundation design referenced by #163, #164, #166, #168, and the Phase 0 tracker #182.

These four issues share a contract surface (session row schema, pending-state lifecycle, compaction and permission layering). Without a shared design, we'd re-do the session schema two or three times as each feature discovers what it needs and ship incompatible pause/resume semantics. This doc pins the contract once. Mirrors the precedent set by planning/subagent-tool-design.md.

Notable decisions

  • Compaction is client-side. vLLM, llama.cpp, Bedrock, and Vertex do not support server-side compaction (Anthropic's compact_2026_01_12 does, but we target multiple endpoints). Framework owns it.
  • Marker-based rolling summary, frozen prefix, pinned tail — matches the dominant production shape across Anthropic, Claude Code, and Codex CLI per the research that informed this design.
  • Tool-call/tool-result pairs survive compaction together. Orphaned tool_use_ids are a documented LLM-failure class (LangChain #29637, n8n #7c1985e).
  • PermissionSource is pluggable. StaticPermissionSource (yaml) for vanilla RHOAI deployments, KagentiPermissionSource for Kagenti, OGXPermissionSource for LlamaStack-shielded deployments.
  • BaseAgent stays unaware of compaction, sessions, and permissions. These remain server-layer ABCs alongside SessionStore and TraceStore.

Phased rollout

Test plan

rdwj added 2 commits May 7, 2026 18:14
Foundation design for #163 (Question tool), #164 (per-tool permission
policy), #166 (auto-compaction), and #168 (session fork). These four
issues share a single contract surface — the shape of the session row,
the lifecycle of pending state (open tool calls, pending operator
questions, in-flight subagent invocations), and the layering of
compaction and permission resolution.

Pinning the contract once in a single doc (mirroring the precedent
set by planning/subagent-tool-design.md) so each downstream issue can
reference it instead of re-spec'ing locally. The Phase 0 tracker
issue (#182) is the implementation entry point.

Notable decisions captured:

- Compaction is client-side (vLLM, llama.cpp, Bedrock, Vertex generally
  do not support server-side compaction, so the framework owns it).
- Marker-based rolling summary with a frozen prefix and pinned tail —
  matches the dominant production shape (Anthropic compact_2026_01_12,
  Claude Code, Codex CLI).
- Tool-call/tool-result pairs survive compaction together; orphaned
  tool_use_ids are a documented LLM-failure class.
- PermissionSource is pluggable: StaticPermissionSource (yaml) for
  vanilla RHOAI deployments, KagentiPermissionSource for Kagenti, and
  OGXPermissionSource for LlamaStack-shielded deployments.
- BaseAgent stays unaware of compaction, sessions, and permissions —
  these remain server-layer ABCs alongside SessionStore and TraceStore.

Assisted-by: Claude Code (Opus 4.7)
Add an Architecture Decisions bullet for the new
planning/session-state-compaction-design.md so readers landing in
CLAUDE.md see the contract for #163/#164/#166/#168 alongside the
existing Subagent-as-tool entry it mirrors.

Also tack the v2 follow-up issues (#179 streaming, #180 kagenti
discovery, #181 remote depth enforcement) onto the Subagent-as-tool
bullet so the deferred-work pointers live next to the v1 scope cuts
that produced them.

Assisted-by: Claude Code (Opus 4.7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant