fix(agent-key): restore getAgentDisplayName for HTTP-header-safe agent keys#3371
fix(agent-key): restore getAgentDisplayName for HTTP-header-safe agent keys#3371FuDesign2008 wants to merge 4 commits intocode-yeongyu:devfrom
Conversation
…t keys Commit 79b4b0a reintroduced ZWSP characters into config.agent object keys by switching remapAgentKeysToDisplayNames to use getAgentListDisplayName, which returns ZWSP-prefixed runtime names (e.g. U+200B + 'Sisyphus - Ultraworker'). These object keys are used as HTTP header values in the OpenCode /agent API. ZWSP is an invalid RFC 7230 header character, causing: TypeError: Header 'mode_type' has invalid value Fix: revert the key lookup to getAgentDisplayName (no ZWSP prefix). The name field inside each agent object continues to use getAgentRuntimeName (with ZWSP) so OpenCode's localeCompare sort ordering is preserved. Closes code-yeongyu#3281
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes a regression causing HTTP header validation errors by removing ZWSP from agent keys while preserving sorting via the internal name field. Tests verify the fix.
|
I have read the CLA Document and I hereby sign the CLA |
…, and priority ordering Three more code paths still used getAgentListDisplayName (ZWSP-prefixed) where the keys must be HTTP-header-safe (no ZWSP): - agent-config-handler.ts: default_agent was set to getAgentRuntimeName(), causing mismatches with the clean agent keys and ZWSP in the displayed name - agent-priority-order.ts: CORE_AGENT_ORDER.displayName used getAgentListDisplayName() for key matching, so core agents were not found and priority ordering silently broke - command-config-handler.ts: cmd.agent was remapped to getAgentListDisplayName(), making command routing fail to resolve against clean agent keys All three now use getAgentDisplayName() (no ZWSP). The name field inside each agent object continues to use getAgentRuntimeName() (ZWSP) for localeCompare sort ordering. Closes code-yeongyu#3281
|
Follow-up: extended ZWSP fix to three more code paths (see commit a3143d0) After the initial fix to
All 147 tests pass after the fix. |
…er violation OpenCode passes the agent name field as the mode_type HTTP header value. ZWSP in the name field causes TypeError: Header 'mode_type' has invalid value, blocking all agent invocations. Changed rewriteAgentNameForListDisplay to use getAgentDisplayName (clean) instead of getAgentRuntimeName (ZWSP-prefixed). Agent ordering is handled deterministically by reorderAgentsByPriority via the explicit order field (1-4), not by name sorting. Node.js localeCompare treats ZWSP as ignorable (returns 0), confirming the ZWSP sorting mechanism was never effective. Updated AGENTS.md to document the order field as the canonical ordering mechanism and prohibit ZWSP in the name field.
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
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/plugin-handlers/AGENTS.md">
<violation number="1" location="src/plugin-handlers/AGENTS.md:16">
P3: Don't describe `order` as the mechanism that guarantees ordering; this repo only stores it, while actual ordering still comes from display-name handling.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The order field is metadata stored by this repo; actual ordering is guaranteed by reorderAgentsByPriority matching core agents by display name and leveraging JavaScript key-insertion order. Addresses cubic review: P3 — do not describe order as the mechanism that guarantees ordering.
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: PR description claims the 'name' field keeps ZWSP, but the code diff shows it is removed. This contradicts the previous requirement that ZWSP in 'name' is needed for UI sorting.
|
Re: cubic P3 — Fixed in commit 9bd9dfa ( Agreed with the feedback. The corrected wording now reads:
The actual ordering guarantee is the display-name matching loop + JS key-insertion order in |
Summary
79b4b0areintroduced ZWSP intoconfig.agentobject keys by switchingremapAgentKeysToDisplayNamesto callgetAgentListDisplayName, which returns ZWSP-prefixed runtime names (e.g.\u200BSisyphus - Ultraworker)./agentAPI; ZWSP violates RFC 7230, causingTypeError: Header 'mode_type' has invalid value.Root Cause
The
namefield inside each agent object continues to usegetAgentRuntimeName(key)(with ZWSP prefix), so OpenCode'slocaleComparesort ordering is fully preserved.Changes
src/plugin-handlers/agent-key-remapper.tsgetAgentDisplayName;namefield keepsgetAgentRuntimeNamesrc/plugin-handlers/agent-key-remapper.test.tsexpect(name).not.toContain("\u200B")guardsrc/plugin-handlers/agent-config-handler.test.tsgetAgentDisplayNameTesting
Closes #3281
Summary by cubic
Removes ZWSP from agent keys and name fields to keep
/agentHTTP headers RFC 7230 compliant. Enforces core agent ordering viareorderAgentsByPriority(display-name matching + JS key insertion) and treats theorderfield as metadata only; fixesdefault_agent, command routing, and priority matching.getAgentDisplayNamefor agent keys,agent.name,default_agent, commandagentmapping, and core priority display names; ZWSP is forbidden everywhere.AGENTS.mdto clarify ordering is guaranteed byreorderAgentsByPriorityand thatorderis metadata; refresh tests to assert clean keys/names and verify routing/ordering against clean display names.Written for commit 9bd9dfa. Summary will update on new commits.