feat(tools): add oc_journal_compact deterministic core#1442
Merged
Conversation
New `oc_journal_compact` MCP tool that compresses a sliding window of
journal entries into a model-friendly summary. Three strategies:
- `recent_k` (default): deterministic concatenation of summaries
truncated to fit a token budget (~4 chars/token heuristic, same
style as src/mcp/output-observability.ts).
- `checkpoint_only`: milestone-flagged entries only, plus the
last successful oc_checkpoint.
- `sampling`: host-mediated summarisation via
`sampling/createMessage`. Returns `unsupported_by_host` when the
client lacks the `sampling` capability. OpenChrome never falls
back to a server-side LLM.
Output always includes facts, open failed assertions, and an
estimated token count.
Part 1 of #1434. The integration test that round-trips a real
trajectory through compaction + resumed execution against the
original oc_assert contract, plus the recommended-cadence docs,
land in Part 2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 task
CI fixes for #1442: - src/tools/index.ts: register oc_journal_compact in TOOL_CAPABILITY_MAP as 'core' so the capability-filter "all tools have capability tags" test passes. - src/tools/__tests__/__snapshots__/tools-list.v1.11.snap.json: add oc_journal_compact to the baseline tools surface so the "tools/list matches v1.11.0 baseline snapshot" test passes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The comment claimed only the latest assertion per name is kept, but the implementation (and its test) surface all failed oc_assert entries in order. Fix the comment to match behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…sion_id - MCP `sampling/createMessage` may return `content` as a single block or an array of blocks. Parse both forms and take the first text block instead of only the scalar shape, so the summary is not silently dropped. - Document that the `recent_steps` window is taken across all sessions before the `session_id` filter is applied, so a busy journal may yield fewer than `recent_steps` entries for one session. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
Review & merge-readiness analysis (#1442)Intent: New Alignment with the SSOT (#1359)Clean alignment:
Issues found & fixed
VerdictSpecialized code review: MERGE-READY — 0 P0 / 0 P1. Local build clean; |
…tability (#1444) * docs(skill): document oc_journal_compact cadence and pin round-trip stability Add docs/skills/trajectory-compaction.md describing recommended compaction cadence (every 20–50 steps), strategy selection (recent_k / checkpoint_only / sampling), and composition with the LLM-free fast path (#1430 Part 2). Add round-trip integration test that pins the lossy-but-stable contract: two consecutive compactions over the same trajectory must agree on open_assertions, last_checkpoint, and (for deterministic strategies) the summary text. Without this gate, a future refactor of the truncation logic could silently destabilise resume flows. Part 2 of #1434. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(journal-compact): pin sampling-unsupported fallback; soften cadence doc Adds a third round-trip case asserting that strategy:'sampling' returns status:'unsupported_by_host' with no fabricated summary when the host lacks the sampling capability — the exact #1359 guarantee (never server-side) that was previously only asserted in prose. Also softens the cadence table to keep the 20/50-step figures attributed to Webwright rather than implying an OpenChrome-measured benchmark (#1359 P5). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # docs/mcp/tool-annotations.md # src/tools/index.ts
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
oc_journal_compactMCP tool with three strategies:recent_k(deterministic, default) — concat summaries, truncate to fit token budget.checkpoint_only(deterministic) — milestone-only + last checkpoint.sampling(host-mediated) —sampling/createMessagewith strict fallback tounsupported_by_hostwhen client capability absent.{ summary, facts, open_assertions, last_checkpoint?, tokens_estimated, strategy_used }.SSOT (#1359) alignment
samplingcapability.Files
src/tools/oc-journal-compact.ts(new)src/tools/index.ts(register)src/types/tool-annotations.ts(READ_ONLY entry)docs/mcp/tool-annotations.md(markdown mirror)tests/tools/oc-journal-compact.test.ts— 8 tests covering all strategies, truncation, failed-assert surfacing, unknown-strategy rejection, session filter.Out of scope (Part 2 of #1434)
oc_assertcontract.docs/skills/trajectory-compaction.mdwith recommended cadence (20–50 step).Test plan
tests/tools/oc-journal-compact.test.ts— 8/8 pass.tests/unit/tool-annotations.test.ts— 9/9 pass (markdown mirror sync).Part 1 of #1434.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com