Skip to content

feat: add read_original and investigate tools for compressed blocks - #691

Open
jflowers wants to merge 1 commit into
Tarquinen:masterfrom
jflowers:feat/investigate-read-original
Open

jflowers wants to merge 1 commit into
Tarquinen:masterfrom
jflowers:feat/investigate-read-original

Conversation

@jflowers

Copy link
Copy Markdown

Closes #690

Adds two tools that let the agent get at the content behind a compressed block without decompressing it.

  • read_original(bN, maxTokens?) returns the original messages for block bN. If maxTokens is set, it keeps the most recent messages that fit and says the result was truncated.
  • investigate(bN, question) opens a child session with parentID set to the current session, prompts it with the original content and the question, returns only the answer, then deletes the child session.

Also adds /dcp read and /dcp investigate, a short system prompt section about the tools, and a hint line in the XML compressed block footer.

Both tools are added to primary_tools and get an allow permission unless the user already set one for read_original.

Scope

OpenCode V1 only. lib/v2/ isn't touched, so V2 sessions don't get the tools yet. I'd rather add V2 here than ship half, if you'd like it in one PR. Let me know which you prefer.

Questions for review

  • Should the tools stay always on, or sit behind a dcp.jsonc setting?
  • The footer hint only shows for the XML ID format. Want it for the other format too?
  • investigate sends the whole block to the child session with no token cap. Should it share maxTokens with read_original?

Testing

New tests in tests/read-original.test.ts and tests/investigate.test.ts cover block ID parsing, slice resolution, serialization, truncation, and the child session lifecycle (create, prompt, answer extraction with a fallback to reading messages, delete). Cleanup on a failed prompt is in a finally but isn't covered by a test yet.

On current master: npm test (137 DCP tests and 8 logger tests pass), npm run typecheck, npm run check:package, and Prettier on the changed files all pass.

🤖 Generated with Claude Code

… of compressed content

Add two always-on tools that let the agent resolve questions about
compressed/compacted sections without re-expanding them into the main
context:

- read_original(bN, maxTokens?) returns the raw slice of the original
  messages for a compression block.
- investigate(bN, question) spawns a child session (parentID = current
  session), prompts it with the raw slice + question, and returns only the
  synthesized answer, then deletes the child session.

Also adds /dcp read and /dcp investigate slash commands, a system-prompt
awareness section, and a hint line in the xml compressed-block footer.
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.

[Feature]: Let the agent read or question a compressed block without decompressing it

1 participant