Skip to content

docs: Alignment analysis of .NET and Python context compaction vs. ADR-0019#4515

Draft
Copilot wants to merge 2 commits intocrickman/feature-compaction-deuxfrom
copilot/analyze-dotnet-python-compaction
Draft

docs: Alignment analysis of .NET and Python context compaction vs. ADR-0019#4515
Copilot wants to merge 2 commits intocrickman/feature-compaction-deuxfrom
copilot/analyze-dotnet-python-compaction

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

Motivation and Context

Adds a cross-implementation analysis of the in-progress Python (#4469) and .NET (#4496) compaction PRs against ADR-0019 to surface alignment gaps before either PR merges.

Description

Creates docs/design/alignment.md — no code changes.

Spec recap (ADR-0019 decision)

  • Option 1 (standalone CompactionStrategy) + Variant F2 (_-annotated messages, no sidecar)
  • Three required compaction points: in-run, pre-write, existing-storage
  • TokenBudgetComposedStrategy as the canonical composition pattern
  • Strategy-internal trigger guard (no separate trigger abstraction)

Python PR #4469

  • ✅ Closely follows spec: F2 model, Protocol interface, TokenBudgetComposedStrategy, strategy-internal triggers, all four built-in strategies
  • ⏳ Pre-write and existing-storage compaction deferred to Phase 2
  • ⚠️ Reasoning-message atomicity not yet handled in annotate_message_groups()

.NET PR #4496

  • ✅ Sound in-run compaction: CompactingChatClient (innermost in pipeline), MessageIndex with incremental Update(), state serialized into AgentSession.StateBag, streaming support
  • ⚠️ Uses F1 (sidecar MessageIndex) rather than spec-preferred F2 — intentional and acceptable per spec's own acknowledgement
  • TokenBudgetComposedStrategy absent; PipelineCompactionStrategy runs all strategies unconditionally with no budget-stop
  • ⚠️ Pre-write compaction via IChatReducer on InMemoryChatHistoryProvider — separate abstraction from CompactionStrategy, not unified as the spec intends
  • ❌ Reasoning-message atomicity not handled in MessageIndex.Create

Key gaps identified

Priority Gap Affects
High TokenBudgetCompactionStrategy missing .NET
High Pre-write uses IChatReducer, not CompactionStrategy .NET
High Pre-write/storage compaction not yet implemented Python (Phase 2)
Medium Reasoning-message (ReasoningContent) atomicity Both

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: crickman <66376200+crickman@users.noreply.github.com>
Copilot AI changed the title [WIP] Add analysis of .NET and Python compaction work docs: Alignment analysis of .NET and Python context compaction vs. ADR-0019 Mar 6, 2026
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.

2 participants