Skip to content

fix(agent-key): remove ZWSP from config object keys for RFC 7230 compliance#3378

Closed
code-yeongyu wants to merge 2 commits intodevfrom
fix/issue-3220-zwsp-clean
Closed

fix(agent-key): remove ZWSP from config object keys for RFC 7230 compliance#3378
code-yeongyu wants to merge 2 commits intodevfrom
fix/issue-3220-zwsp-clean

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Apr 13, 2026

Summary

Removes ZWSP (U+200B) characters from config object keys to comply with RFC 7230 header value requirements.

Changes

  • Use getAgentDisplayName() instead of getAgentListDisplayName() for config object keys
  • Keep ZWSP only in agent name field (user-facing display for UI sorting)
  • Add RFC 7230 compliance tests verifying no ZWSP in object keys
  • Fix stale comments referencing non-existent x-opencode-agent-name header

Why This Matters

Object keys in plugin config can flow into HTTP header values in some contexts. ZWSP characters violate RFC 7230 which requires visible ASCII characters in header field values.

Scope Clarification

This PR provides hardening within oh-my-opencode constraints.

The root cause of #3220 (agents not appearing after OpenCode 1.4.0 upgrade) is an OpenCode plugin loading order issue where Agent.list() reads from static config before plugin hooks are registered. Full resolution requires OpenCode changes which are outside our scope.

This fix ensures:

  • Config keys are RFC 7230 compliant (no ZWSP)
  • ZWSP remains in name field for UI sorting (user experience preserved)
  • Defensive hardening against potential header value issues

Related

Testing

  • All existing tests pass
  • New RFC 7230 compliance tests added for all config handlers
  • ZWSP presence in name field verified by tests

Summary by cubic

Removes zero‑width spaces from config object keys and switches to HTTP‑safe display names to comply with RFC 7230. Also normalizes ZWSP‑prefixed runtime names and fixes model ID formatting, reducing header validation issues related to #3220.

  • Bug Fixes
    • Use getAgentDisplayName() for config keys and default_agent; stop using getAgentListDisplayName().
    • Keep ZWSP only in agent.name; add tests ensuring no ZWSP in keys and presence in names.
    • Normalize command agents, priority ordering, and tool lookups to HTTP‑safe display names; getAgentDisplayName() now strips ZWSP prefixes from runtime inputs.
    • Add RFC 7230 compliance tests and clean up stale header comments; fix Anthropic model ID format in tests (claude-opus-4.6).

Written for commit 44860d8. Summary will update on new commits.

…liance

Object keys used in plugin config can flow into HTTP header values.
ZWSP (U+200B) characters in keys violate RFC 7230 which requires
visible ASCII characters in header field values.

Changes:
- Use getAgentDisplayName() instead of getAgentListDisplayName() for
  config object keys (no ZWSP)
- Keep ZWSP only in agent 'name' field for UI sorting purposes
- Add RFC 7230 compliance tests verifying no ZWSP in object keys
- Fix stale comments referencing non-existent x-opencode-agent-name header

Related: #3220
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 14 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Fixes RFC 7230 compliance by removing ZWSP from config keys while preserving it in 'name' fields for UI sorting. Includes comprehensive test coverage for the changes.

…DisplayName

getAgentDisplayName now strips ZWSP characters before lookup.
This handles cases where a ZWSP-prefixed runtime name (e.g., from
default_agent config) is passed to the function.

Also fixes generate-omo-config test expectations to use correct
model ID format (claude-opus-4.6 after provider transformation).

Related: #3220
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 3 files (changes from recent commits).

Requires human review: Refactor calls 'stripInvisibleAgentCharacters' in agent-display-names.ts, but the function's definition is not visible in the diff, making it impossible to verify it won't cause a ReferenceError.

@code-yeongyu
Copy link
Copy Markdown
Owner Author

Closing this PR.

The root cause was found in OpenCode's Agent.defaultLayer timing issue, which has been fixed in OpenCode 1.4.3 (commit 2ecc6ae65).

Solution for users: Upgrade OpenCode to 1.4.3 or later.

The hardening changes in this PR are not necessary since the upstream bug is fixed. If RFC 7230 compliance becomes relevant in the future, we can revisit.

@code-yeongyu code-yeongyu deleted the fix/issue-3220-zwsp-clean branch April 13, 2026 05:24
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