Skip to content

fix(task-tool): sanitize zero-width-space and BOM from subagent_type - #28084

Closed
PeterPonyu wants to merge 1 commit into
anomalyco:devfrom
PeterPonyu:fix/opencode-24276-zwsp-subagent-type
Closed

fix(task-tool): sanitize zero-width-space and BOM from subagent_type#28084
PeterPonyu wants to merge 1 commit into
anomalyco:devfrom
PeterPonyu:fix/opencode-24276-zwsp-subagent-type

Conversation

@PeterPonyu

@PeterPonyu PeterPonyu commented May 18, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #24276

Type of change

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

What does this PR do?

Some skill emitters (e.g. oh-my-openagent's review-work) prefix subagent_type with a zero-width space (U+200B). agent.get(params.subagent_type) then returns undefined, and the call surfaces as ProviderModelNotFoundError with an unresolvable model id.

This PR strips U+200B, U+200C, U+200D, and U+FEFF and trims surrounding whitespace before the agent lookup in packages/opencode/src/tool/task.ts. The cleanup lives in a small helper sanitizeAgentTypeId() so it can be reused if other entry points need it.

How did you verify your code works?

cd packages/opencode && bun test test/tool/parameters.test.ts — 63 pass, 0 fail. 5 new assertions cover: ZWSP-prefix repro from the issue, clean-string passthrough, whitespace trimming, multi-character zero-width stripping, and mid-string embedded ZWSP.

Screenshots / recordings

N/A — no UI change.

Checklist

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

…nomalyco#24276)

Upstream skill emitters (e.g. oh-my-openagent review-work) can prefix the
subagent_type argument with a zero-width space (U+200B), causing the agent
lookup to return undefined and ultimately surfacing as a ProviderModelNotFoundError
with an unresolvable model ID.

Add a sanitizeAgentTypeId() helper that strips U+200B, U+200C, U+200D, and
U+FEFF (BOM/ZWNBSP) characters and trims surrounding whitespace. Apply it to
params.subagent_type immediately before the agent.get() lookup so opencode
handles dirty input defensively regardless of the caller.

Regression tests in test/tool/parameters.test.ts cover the ZWSP-prefixed
repro case from the issue, the no-op clean-string path, whitespace trimming,
multi-character stripping, and mid-string embedded ZWSP.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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 May 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@Rancheroo

Copy link
Copy Markdown

Still hitting this on v1.17.11 — task(subagent_type="hephaestus") fails with UnknownError due to the ZWSP prefix from oh-my-openagent. Was this addressed in another PR, or does the fix still need to land? Happy to help if reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/review command throws ProviderModelNotFoundError due to zero-width space in subagent_type

2 participants