Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
OpenCode assembles the effective input sent to a model from multiple sources, including system instructions, project instruction files, skills, available tools, MCP schemas, plugin transformations, conversation history, and compaction.
When an agent's behavior changes unexpectedly between turns, inspecting the current system prompt alone does not necessarily explain why. A skill may have been added or removed, a tool definition may have changed, an instruction file may have been reloaded, or conversation history may have been compacted.
Today, diagnosing this kind of context drift can require manually comparing logs, configuration files, prompts, and session history. This makes it unnecessarily difficult to determine whether a behavioral change originated in the model or in the context OpenCode supplied to it.
Proposed solution
Introduce an opt-in context-diff inspector that compares the effective context of the current turn against the preceding turn in the same session.
For example, a command such as opencode debug context-diff could report:
- Instruction changes: instruction sources added, removed, or modified, including their paths where applicable.
- Skill changes: skills that entered or left the available context, including changes to their effective definitions.
- Tool changes: tools added or removed, and changes to their schemas or descriptions.
- Model configuration changes: changes to the active model, provider, relevant generation settings, or agent.
- Conversation changes: context compaction, summarized history, or other significant transformations of the conversation supplied to the model.
- Context budget changes: estimated token-count differences attributable to each category, where measurable.
The output should distinguish confirmed changes from estimates and unavailable information. It should not claim to reconstruct an exact historical request when the necessary data was not recorded.
Suggested interface
A compact report could look like this:
Context changes since the previous turn
Instructions
~ AGENTS.md modified
+ .opencode/skills/testing/SKILL.md added
Tools
~ filesystem.search schema changed
- example_mcp.delete_record unavailable
Conversation
! Context compaction occurred
Estimated context delta
Instructions +1,240 tokens
Tool definitions -380 tokens
The entries above illustrate the proposed interface, not actual OpenCode output.
The inspector should provide enough detail to investigate a change without requiring users to dump the entire model request into the terminal.
Privacy and storage
Context can contain proprietary source code, secrets, private instructions, and user data. The feature should therefore be opt-in, local by default, and careful about what it persists.
A minimal implementation could record source fingerprints, source identifiers, change events, and token estimates rather than storing complete prompts indefinitely. Full prompt inspection could remain a separate, explicitly requested operation.
Acceptance criteria
- Users can compare the effective context of two consecutive turns in the same session.
- The report identifies which context categories changed and provides source-level details where available.
- Context compaction and relevant model or configuration changes are distinguishable from ordinary conversation growth.
- Token-count changes are labeled as estimates unless exact measurements are available.
- The feature does not silently persist full prompts, credentials, or other sensitive context.
- If historical information is unavailable, the inspector clearly identifies that limitation instead of presenting an incomplete diff as authoritative.
Scope
This request is for context-drift diagnostics, not a replacement for prompt export, configuration validation, or general installation diagnostics.
The goal is to make changes to the effective model context observable across turns, so users can investigate unexpected behavioral changes without manually reconstructing the entire request.
Activity
opencode-agent commentedon Oct 23, 2026
Thanks for the detailed write-up! You're asking for an opt-in inspector that shows what changed in the context sent to the model between consecutive turns of a session: instructions, skills, tools and schemas, model/agent/settings, compaction and estimated token deltas. Maintainers will consider it.
These existing issues are closely related, though none asks for a turn-to-turn diff:
In the meantime, much of this can be done with a v2 plugin using the
sessioncontexthook, which runs right before each model call. The plugin below stores only fingerprints in memory, never prompt text. It appends a diff of each request against the previous one in the same session to~/.local/share/opencode/context-diff/<sessionID>.log. To install it, save it as.opencode/plugins/context-diff/index.tsin your project. It type-checks against the v2 plugin API, but I haven't run it inside OpenCode.The plugin has some limits compared to what you proposed:
AGENTS.mdor a specific skill file.debug context-diffCLI command.Dante-dan commentedon Oct 23, 2026
I’d like to take this through design review. I propose a small core inspector with opt-in, in-memory capture of two consecutive input turns, exposed through the running local service. A fresh CLI process cannot recover an ephemeral baseline.
I checked the current v2 path at
43868389223f3553c6786c2f1cfa70a657f8a8bf:SessionContextexposes model, agent, system, messages, options and tools, but no turn identifier or instruction/skill source mapping. A plugin can observe blocks, but cannot reliably label them as particular files.SessionModelRequest.preparechanges tools and normalizes media after the context hook. HTTP/WebSocket hooks can change transport data later. The inspector should summarize the prepared core request, explicitly label that boundary, and report transport-level changes as unavailable.Proposed first slice
unavailable; do not parse labels from prompt text. This also distinguishes available skill definitions from skills actually loaded into history.Acceptance checks: consecutive input turns versus multi-step/retry/steering flows; instruction/tool/model changes and block reordering; successful/failed compaction versus ordinary growth/revert; explicit estimate/unavailable output; capture disabled by default with no persistent sensitive payload; and restart/eviction/missing-provenance behavior. These are proposed checks, not executed results.
Could a maintainer approve this capture boundary and ephemeral scope, particularly the input-admission definition of a turn?
richie-rich90454 commentedon Oct 24, 2026
This seems consistent with what I had in mind for the feature, especially the distinction between primary input turns and intermediate requests, as well as the emphasis on privacy and explicitly acknowledging unavailable information.
I would be interested in hearing the maintainers' thoughts on the proposed capture boundary whenever they have a chance.