Conversation
83b5bfe to
c596f41
Compare
Add `jp conversation compact` command and `--compact` / `-k` flag across `query`, `fork`, and `compact` commands, implementing RFD 064 (non-destructive conversation compaction). The core idea is that compaction is additive: a `Compaction` overlay event is appended to the conversation stream rather than modifying or deleting any existing events. The projection layer applies overlays at request-build time (`Thread::into_parts()`), so the LLM sees a reduced view while the full raw history is preserved on disk. **What users can do now:** ```sh # Compact with workspace defaults (strip reasoning + tools) jp conversation compact # Strip reasoning, keep last 5 turns jp conversation compact --reasoning --keep-last 5 # Preview without applying jp conversation compact --dry-run # Remove all compaction events (undo) jp conversation compact --reset # Compact before querying (inline DSL, summarize all but last 3 turns) jp query -k s:..-3 -- "Continue the task" # Fork and compact in one step jp conversation fork --compact ``` **DSL (`--compact=SPEC`)** supports `r` (reasoning), `t` (tools), `s` (summarize) as policy letters, combined with `+`, and an optional range after `:`. Examples: `s:..-3`, `r+t`, `s:5..-3`. Bare `--compact` applies config rules; `--compact=SPEC` applies inline rules; both forms compose. **Summarization** calls the configured LLM and stores the result in the `Compaction` event as a `SummaryPolicy`. At projection time the covered turns are replaced with a synthetic request/response pair containing the summary text. Summary range auto-extension prevents partial overlaps with existing summary compactions. **Configuration** is under `conversation.compaction.rules` — a `MergedVec<CompactionRuleConfig>` where each rule produces one compaction event. The built-in default (strip reasoning + tools) uses `discard_when_merged: true` so it is replaced the moment any user rule is present. Alternative compaction configurations can be expressed as individual configuration files loaded with `--cfg`, consistent with JP's existing config layering. **`jp conversation print --compacted`** shows the projected (assistant) view of the conversation, making it easy to verify the effect of compaction. The `IntoPartialAppConfig` trait gains a `handles` parameter so commands can access resolved conversation targets when building their config overrides. Ref: #57 Signed-off-by: Jean Mertz <git@jeanmertz.com>
…tion Signed-off-by: Jean Mertz <git@jeanmertz.com>
…tion Signed-off-by: Jean Mertz <git@jeanmertz.com>
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.
Add
jp conversation compactcommand and--compact/-kflag acrossquery,fork, andcompactcommands, implementing RFD 064 (non-destructive conversation compaction).The core idea is that compaction is additive: a
Compactionoverlay event is appended to the conversation stream rather than modifying or deleting any existing events. The projection layer applies overlays at request-build time (Thread::into_parts()), so the LLM sees a reduced view while the full raw history is preserved on disk.What users can do now:
DSL (
--compact=SPEC) supportsr(reasoning),t(tools),s(summarize) as policy letters, combined with+, and an optional range after:. Examples:s:..-3,r+t,s:5..-3. Bare--compactapplies config rules;--compact=SPECapplies inline rules; both forms compose.Summarization calls the configured LLM and stores the result in the
Compactionevent as aSummaryPolicy. At projection time the covered turns are replaced with a synthetic request/response pair containing the summary text. Summary range auto-extension prevents partial overlaps with existing summary compactions.Configuration is under
conversation.compaction.rules— aMergedVec<CompactionRuleConfig>where each rule produces one compaction event. The built-in default (strip reasoning + tools) usesdiscard_when_merged: trueso it is replaced the moment any user rule is present. Alternative compaction configurations can be expressed as individual configuration files loaded with--cfg, consistent with JP's existing config layering.jp conversation print --compactedshows the projected (assistant) view of the conversation, making it easy to verify the effect of compaction.The
IntoPartialAppConfigtrait gains ahandlesparameter so commands can access resolved conversation targets when building their config overrides.Ref: #57