fix(agent-key): remove ZWSP from config object keys for RFC 7230 compliance#3375
fix(agent-key): remove ZWSP from config object keys for RFC 7230 compliance#3375code-yeongyu wants to merge 4 commits intodevfrom
Conversation
Object keys containing ZWSP characters cause HTTP header validation failures in OpenCode 1.4.0+, breaking agent registration. - Use getAgentDisplayName() (no ZWSP) for object keys - Keep getAgentRuntimeName() (with ZWSP) only in name field for sorting - Maintains ZWSP sorting for Sisyphus, Hephaestus, Prometheus, Atlas Fixes #3220
- Add RFC 7230 compliance tests for object key validation - Verify name field still contains ZWSP for core agents - Update all test expectations to use getAgentDisplayName()
There was a problem hiding this comment.
1 issue found across 13 files
Confidence score: 2/5
- There is a high-confidence, high-severity issue in
src/tools/delegate-task/tools.test.ts: a duplicate import binding makes the test file uncompilable. - Because this causes a compile-time failure in tests, the PR has a clear merge-blocking risk until the import conflict is resolved.
- Pay close attention to
src/tools/delegate-task/tools.test.ts- duplicate import binding currently breaks test compilation.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/tools/delegate-task/tools.test.ts">
<violation number="1" location="src/tools/delegate-task/tools.test.ts:4">
P1: Custom agent: **Opencode Compatibility**
Duplicate import binding makes the test file uncompilable.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Auto-approved: Fixes RFC 7230 violation causing crashes. Systematically removes ZWSP from config keys while preserving UI sort order in values. Extensive test coverage (5429 tests) confirms stability.
CI Status NoteThe test failure in CI is due to a pre-existing issue in the
This PR's changes do not affect the failing tests. The failing file ( Once PR #3361 is merged and this branch is rebased, CI should pass. |
|
…me header Per OpenCode source investigation, no such header exists. Updated comments to accurately reflect RFC 7230 compliance concerns for object keys.
|
|
Superseded by #3378 (clean commit history without |
Summary
Removes ZWSP characters from config object keys to ensure RFC 7230 HTTP header compliance. This is a hardening fix, not a resolution of #3220.
Investigation Findings (from
../opencode)Root Cause of #3220
After investigating both the plugin code and OpenCode source (
../opencode), the root cause is:OpenCode plugin loading order issue (confirmed by repo owner):
OpenCode Source Evidence
packages/opencode/src/agent/agent.ts(line 304)Agent.list()returns agents from static config; plugin-registered agents via config hooks not visiblepackages/opencode/src/session/prompt.ts(lines 1406-1407)agent.namefor session storage, not HTTP headerspackages/opencode/src/session/llm.ts(line 91)agent.nameused only for logging tagspackages/opencode/src/session/llm.ts(lines 357-360)x-opencode-project,x-opencode-session,x-opencode-request,x-opencode-clientConclusion:
agent.namedoes NOT reach HTTP headers in OpenCode's LLM request path. The ZWSP innamefield (for sorting) is safe.Why Full Resolution is Not Possible Within Constraints
The user explicitly forbade:
Without either of these, the #3220 root cause cannot be fixed from the plugin side.
What This PR Does Fix
This PR fixes a separate but related issue: ZWSP characters leaking into HTTP header values via config object keys.
\u200B) in headers violates RFC 7230getAgentDisplayName()(no ZWSP)namefield for UI sorting (as required)Changes
agent-key-remapper.tsgetAgentDisplayName()for object keysagent-priority-order.tsgetAgentDisplayName()for displayName lookupcommand-config-handler.tsgetAgentDisplayName()for agent referenceagent-config-handler.tsgetAgentDisplayName()for default_agenttool-config-handler.tsgetAgentDisplayName()with fallbackagent-display-names.tsagent-config-handler.test.tsTesting
namefield for core agents)CI Note
Test failure in CI is due to pre-existing dev branch issue (model ID format mismatch in
generate-omo-config.test.ts). PR #3361 addresses this. Changes in this PR do not affect the failing tests.Recommendations for #3220
To fully resolve #3220, one of the following is needed:
Without relaxing the constraints, #3220 cannot be fully resolved from the plugin side.
Related to #3220 (hardening, not resolution)