Skip to content

feat(opencode): add XML tool-call fallback via OPENCODE_XML_TOOL_FALLBACK - #52727

Closed
vector0902 wants to merge 1 commit into
anomalyco:devfrom
vector090-org1:pr-xml-tool-fallback
Closed

vector0902 wants to merge 1 commit into
anomalyco:devfrom
vector090-org1:pr-xml-tool-fallback

Conversation

@vector0902

@vector0902 vector0902 commented Oct 2, 2026 •

Copy link
Copy Markdown

Issue for this PR

Related to #43385 / #50206 (models emitting XML tool calls as plain text).

Type of change

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

What does this PR do?

Opt-in fallback for models that emit XML-style tool calls as plain text into the chat (e.g.
DeepSeek V4 flash outputting <invoke name="bash"><parameter name="command">… instead of
structured tool_calls), gated by env OPENCODE_XML_TOOL_FALLBACK=1 (default off).

  • New packages/opencode/src/session/tool-xml.ts parses <invoke> / <parameter> blocks.
  • processor.ts (text-end) synthesizes them into real tool-call parts via existing
    ensureToolCall / updateToolCall path, so the tool executes and XML no longer renders as raw
    text.
  • Flag added to packages/core/src/flag/flag.ts.

How did you verify your code works?

  • bun test: 8 parser tests pass (multi-block, invalid/unclosed, whitespace, angle brackets,
    cleanText removal).
  • typecheck (packages/opencode, packages/core) passes.
  • End-to-end: model echoing <invoke name="bash">… produced a real bash tool part and executed.

Screenshots / recordings

N/A

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

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

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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.

2 participants