fix(task-tool): sanitize zero-width-space and BOM from subagent_type - #28084
fix(task-tool): sanitize zero-width-space and BOM from subagent_type#28084PeterPonyu wants to merge 1 commit into
Conversation
…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>
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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:
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. |
|
Still hitting this on v1.17.11 — |
Issue for this PR
Closes #24276
Type of change
What does this PR do?
Some skill emitters (e.g. oh-my-openagent's review-work) prefix
subagent_typewith a zero-width space (U+200B).agent.get(params.subagent_type)then returns undefined, and the call surfaces asProviderModelNotFoundErrorwith 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 helpersanitizeAgentTypeId()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