Skip to content

feat(protocol,loop): agent-owned context, operator-owned record - #47

Merged
angel-manuel merged 1 commit into
masterfrom
feat/context-management
Apr 19, 2026
Merged

angel-manuel merged 1 commit into
masterfrom
feat/context-management

Conversation

@angel-manuel

Copy link
Copy Markdown
Contributor

Summary

  • Separate the agent's working context from the operator's canonical conversation record
  • turn/end.messages deprecated — agents send only usage; operators reconstruct from stream/* notifications
  • New context/compacted notification — emitted after auto-compaction with a prose summary and surviving canonical messages for the operator to persist
  • Compaction rewritten to return CompactionResult with working_messages (for LLM, includes <compacted_context> system scaffolding) and canonical_messages (for operator, no scaffolding)
  • Configurable thresholds via env vars: CONTEXT_WINDOW, COMPACTION_THRESHOLD, COMPACTION_KEEP_RECENT, MAX_COMPACTIONS
  • Per-session compaction cap (default 3)
  • New design doc: docs/design/context-management.md

Test plan

  • Protocol: round-trip fixtures for ContextCompactedParams and usage-only TurnEndParams
  • Compaction: tests for CompactionResult structure, canonical-excludes-scaffolding
  • ACP client: turn_end sends no messages, context_compacted round-trips correctly
  • Server dispatch: context/compacted passes through as notification
  • E2e: supervisor pipeline verifies via stream/* frames instead of turn/end.messages
  • All 421+ tests pass, clippy clean

🤖 Generated with Claude Code

Separate the agent's working context from the operator's canonical
conversation record. The agent is free to inject scaffolding
(<compacted_context>, turn markers, nudges) without polluting what
the operator persists.

Protocol changes:
- turn/end.messages deprecated (empty, omitted on wire)
- New context/compacted notification carries summary + surviving
  canonical messages after compaction

Compaction rewrite:
- Returns CompactionResult with working_messages (for LLM) and
  canonical_messages (for operator)
- Uses <compacted_context> system message instead of synthetic
  user/assistant pair
- Configurable thresholds via env vars (CONTEXT_WINDOW,
  COMPACTION_THRESHOLD, COMPACTION_KEEP_RECENT, MAX_COMPACTIONS)
- Per-session compaction cap (default 3)

Broker: context/compacted added to notification passthrough.

Docs: new docs/design/context-management.md; updated SPEC, protocol,
STATUS, TODO.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sentry

sentry Bot commented Apr 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.16352% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.62%. Comparing base (b37cb9e) to head (e687a42).

Files with missing lines Patch % Lines
loop/src/agentic_loop.rs 23.52% 13 Missing ⚠️
loop/src/compaction.rs 78.26% 5 Missing ⚠️
loop/src/main.rs 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
- Coverage   91.78%   91.62%   -0.17%     
==========================================
  Files          50       50              
  Lines        6857     6949      +92     
==========================================
+ Hits         6294     6367      +73     
- Misses        563      582      +19     
Files with missing lines Coverage Δ
loop/src/acp.rs 91.60% <100.00%> (+0.48%) ⬆️
loop/src/config.rs 100.00% <100.00%> (ø)
loop/src/observability/langfuse.rs 99.60% <100.00%> (+<0.01%) ⬆️
server/src/tunnel/dispatch.rs 100.00% <100.00%> (ø)
server/src/tunnel/run.rs 65.78% <100.00%> (+0.45%) ⬆️
loop/src/main.rs 0.00% <0.00%> (ø)
loop/src/compaction.rs 96.37% <78.26%> (-1.59%) ⬇️
loop/src/agentic_loop.rs 89.76% <23.52%> (-2.61%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@angel-manuel
angel-manuel merged commit bc76c1e into master Apr 19, 2026
8 checks passed
@angel-manuel
angel-manuel deleted the feat/context-management branch April 19, 2026 11:49
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