Skip to content

Conversation

@Tarquinen
Copy link
Collaborator

@Tarquinen Tarquinen commented Dec 21, 2025

Summary

  • Split prune tool into discard and extract tools for more granular context management
  • Refactored to use assistant role for prunable-tools injection with reasoning model support
  • Restructured config schema to consolidate tool settings
  • Added debug context logging for session messages
  • Fixed edit tool pruning to correctly handle oldString/newString
  • Added prettier for consistent code formatting
  • Added turn-based tool protection and prune cooldown features

Full Changelog: v1.0.3...v1.1.1-beta.1

Tarquinen and others added 30 commits December 18, 2025 16:21
- Add protectedTurns config option to protect recent tools from pruning
- Track currentTurn in session state using step-start parts
- Store turn number on each cached tool parameter entry
- Skip caching tools that are within the protected turn window
- Exclude turn-protected tools from nudge counter
Reject prune requests for IDs not found in the tool cache, which catches
both hallucinated IDs and turn-protected tools that aren't shown in the
<prunable-tools> list.
When the last tool used was prune, inject a cooldown message instead
of the full prunable-tools list. This prevents the model from
repeatedly invoking the prune tool in successive turns.

Also refactors magic strings into named constants for better
maintainability.
- Note that some tools in context may not appear in the list (expected)
- Clarify that the list is only injected when tools are available
Renames the flat protectedTurns config to a nested turnProtection
object matching the structure of nudge. Now has:
- enabled: boolean to toggle the feature
- turns: number of turns to protect tools after use
Refactor prompt loading and rename pruning prompt files
- Replace reason-as-first-id pattern with structured metadata object
- metadata.reason: 'completion' | 'noise' | 'consolidation'
- metadata.distillation: optional object for consolidation findings
- Update prompts to clarify distillation rules per reason type
- Add docs/ to gitignore
Implement hidden distillation in prune tool
Update prune distillation guidelines for high fidelity
- Splits system and nudge prompts into separate files for discard, extract, or both.
- Updates  to load the appropriate system prompt based on configuration.
- Updates  to dynamically select the nudge string.
- Deletes the previous monolithic prompt files.
- Remove cross-references between discard/extract tools so each works independently
- Add decision hierarchy in both-mode: discard as default, extract for preservation
- Consolidate redundant 'WHEN TO X' scenarios with trigger lists
- Change trigger lists to focus on timing ('evaluate when') vs prescriptive action
- Remove confusing 'minimal distillation for cleanup' concept from extract prompts
- Standardize structure across all system prompts and nudges
…rd-and-extract

Split prune tool into discard and extract
@zackleman
Copy link

After tool calls are discarded does the oc side bar which shows percent of context window used accurately reflect the current state with discarded tools?
It would be nice if we could have a session viewer that could show at each snapshot in time what messages the llm saw and used to generate its next turn output. Will make it easier to reason about i think.

Yes the OC side bar shows the most accurate state of your current context usage and percentage, It's more accurate than the UI from dcp because we just run the removed stuff through an openai tokenizer to see how many tokens are removed and display that. The OC counter gets a usage report from each LLM fetch from the model itself.

I could add a session viewer, thats easy, but I don't think there's any nice way to integrate it into opencodes UI. It would basically be a log file of the json that is sent to the model each fetch, is that what you want?

Yes, just something simple like a log file is fine. I can easily have a little tool make it easier to visualize.

Tarquinen and others added 27 commits December 21, 2025 18:55
- Move turnProtection from per-tool to top-level
- Consolidate nudge and protectedTools into tools.settings
- Simplify tools.discard and tools.extract to just enabled flags
- Rename pruningSummary to pruneNotification
- Remove strategies.discardTool and strategies.extractTool
Refactor config schema to consolidate tool settings
Fix edit tool pruning to use correct field names
- add .prettierrc with project style rules
- add format and format:check scripts to package.json
- add format check step to PR workflow
chore: add prettier for code formatting
- Add saveContext method to Logger that saves transformed messages as JSON
- Save to ~/.config/opencode/logs/dcp/context/{sessionId}/{timestamp}.json
- Only logs when debug.enabled is true in config
- Minimize output by stripping unnecessary metadata (IDs, summary, path, etc.)
- Keep essential fields: role, time, tokens, text/tool parts
Add debug context logging for session messages
Switch from user role to assistant role message for injecting
prunable-tools context. This reduces the likelihood of the model
directly addressing the injected content as if responding to
user input, improving the conversational experience.
Reasoning models expect their encrypted reasoning parts in assistant messages,
which we cannot generate. This adds detection via chat.params hook and appends
a synthetic user message (<system-context-injection/>) to close the assistant
turn properly when a reasoning model is active.
…nt messages

- Nudge prompts now use 'I must/I will' instead of 'You must/You should'
- Prunable tools wrapper and cooldown message use first-person
- System prompts updated to correctly describe injection as assistant message
…olete injected_context_handling instructions
Use assistant role for prunable-tools injection
…istillation

Simplify extract distillation to array format
@Tarquinen Tarquinen changed the title merge dev into master v1.1.1-beta.1 - Split prune into discard/extract, assistant-role injection, config restructure Dec 23, 2025
@Tarquinen Tarquinen merged commit 896a669 into master Dec 23, 2025
1 check passed
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.

3 participants