Skip to content

feat(opencode): context_edit toolName targeting, privileged agents, /btw command#4

Closed
e6qu wants to merge 1 commit intodevfrom
feat/context-edit-improvements
Closed

feat(opencode): context_edit toolName targeting, privileged agents, /btw command#4
e6qu wants to merge 1 commit intodevfrom
feat/context-edit-improvements

Conversation

@e6qu
Copy link
Copy Markdown
Owner

@e6qu e6qu commented Mar 15, 2026

Issue for this PR

Fixes usability issues found during manual testing of context editing tools.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

1. context_edit toolName targeting

The agent couldn't use context_edit because it doesn't know the internal partID/messageID of its own tool results. Now it can target parts by tool name:

context_edit(operation: "externalize", toolName: "read", summary: "CAS module with SHA-256")

Parameters: toolName (match most recent result from that tool), nthFromEnd (1=latest, 2=second latest). Combine for "the 2nd most recent grep result". Falls back to exact partID/messageID if provided.

2. Privileged agents

Focus and compaction agents can now edit any message — user messages, other agents' output. Regular agents (build, plan) are still restricted to their own assistant messages only.

3. /btw command

Side conversation that doesn't pollute the main thread:

/btw why is this function async?

Forks into a @general subagent session, answers the question, returns the session ID for continuation.

How did you verify your code works?

Multi-turn CLI test (5 turns, same session):

  1. read file → 80 lines, 670 tokens
  2. context_edit(externalize, toolName: "read") → content moved to CAS, summary inline
  3. context_deref(hash) → full original content retrieved
  4. thread_park → side thread created
  5. context_history(log) + thread_list → edit chain and threads visible

All 1313 unit tests pass.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…btw command

- context_edit: resolve parts by toolName + nthFromEnd instead of requiring
  raw partID/messageID. Agent can say toolName:"read" to target the most
  recent read result.
- Focus and compaction agents are privileged: can edit any message including
  user messages and other agents' output.
- /btw command: side conversation that forks into a general subagent session
  without polluting the main thread. Returns session ID for continuation.
@e6qu
Copy link
Copy Markdown
Owner Author

e6qu commented Mar 15, 2026

Superseded by #5 which includes all these changes plus classifier, focus-rewrite-history, and query targeting.

@e6qu e6qu closed this Mar 15, 2026
@e6qu e6qu deleted the feat/context-edit-improvements branch March 15, 2026 16:26
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.

1 participant