Skip to content

feat(message): add external flag to ToolPart#21772

Open
micuintus wants to merge 3 commits intoanomalyco:devfrom
micuintus:feat/external-flag-toolpart
Open

feat(message): add external flag to ToolPart#21772
micuintus wants to merge 3 commits intoanomalyco:devfrom
micuintus:feat/external-flag-toolpart

Conversation

@micuintus
Copy link
Copy Markdown

@micuintus micuintus commented Apr 9, 2026

Issue for this PR

Closes #21766

Type of change

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

What does this PR do?

Adds an optional external: boolean flag to ToolPart in message-v2.ts. Plugins that inject tool results into sessions (e.g. via the server API) can mark them as externally produced so the model context builder skips them — the model never made the original tool call, so including the result would confuse it.

How did you verify your code works?

  • Unit tests in packages/opencode/test/session/message-v2.test.ts
  • bun turbo typecheck passes

Screenshots / recordings

No UI changes.

Checklist

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

Part of the plugin primitives work split from #21687 (tracking issue #20018).

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Hona and others added 3 commits April 10, 2026 10:00
…alls from model context

External tool parts are displayed in the TUI and persisted, but excluded
from toModelMessages() to prevent orphaned tool_use/tool_result pairs.
Plugins and HTTP endpoints can mark their tool executions as external.
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]: add external flag to ToolPart

2 participants