Skip to content

fix(agents): replace deprecated getAgentListDisplayName with getAgentDisplayName (fixes #3281)#3407

Open
MoerAI wants to merge 4 commits intocode-yeongyu:devfrom
MoerAI:fix/agent-header-strip-zwsp
Open

fix(agents): replace deprecated getAgentListDisplayName with getAgentDisplayName (fixes #3281)#3407
MoerAI wants to merge 4 commits intocode-yeongyu:devfrom
MoerAI:fix/agent-header-strip-zwsp

Conversation

@MoerAI
Copy link
Copy Markdown
Contributor

@MoerAI MoerAI commented Apr 14, 2026

Summary

  • Remove ZWSP-based agent sort prefixes from config handler outputs to fix agent name resolution failures

Problem

getAgentListDisplayName() prepends zero-width space (ZWSP) characters to agent display names for TUI list ordering. These invisible characters leak into HTTP headers, config keys, and agent lookup paths, causing:

  • Agent name resolution failures (e.g., /compact command cannot find default agent)
  • Display corruption on terminals that don't render ZWSP correctly
  • Inconsistent agent name matching across the codebase

Fix

Replaced all getAgentListDisplayName() calls in config/tool/command handlers with getAgentDisplayName(), which returns clean display names without ZWSP prefixes. The agent-key-remapper.ts now uses getAgentDisplayName for both object keys and the name field. Updated all corresponding test expectations.

Changes

File Change
src/plugin-handlers/agent-key-remapper.ts Use getAgentDisplayName instead of getAgentListDisplayName/getAgentRuntimeName
src/plugin-handlers/agent-config-handler.ts Use getAgentDisplayName for default_agent resolution
src/plugin-handlers/agent-priority-order.ts Use getAgentDisplayName for priority ordering keys
src/plugin-handlers/command-config-handler.ts Use getAgentDisplayName for command agent refs
src/plugin-handlers/tool-config-handler.ts Use getAgentDisplayName for tool permission keys
src/shared/agent-display-names.test.ts Update test expectations
src/plugin-handlers/*.test.ts Update 7 test files to expect clean display names
src/plugin-interface.test.ts Update test expectations
src/plugin/chat-message.test.ts Update test expectations

Fixes #3281
Also addresses #3337, #3307, #3347 (ZWSP display issues)
Also addresses #3245 (/compact command agent resolution failure)


Summary by cubic

Removed zero‑width space (ZWSP) prefixes from agent names and replaced all uses of getAgentListDisplayName with getAgentDisplayName so config, routing, and headers use clean names. Fixes #3281 and also unblocks /compact and resolves TUI ZWSP artifacts (#3337, #3307, #3347, #3245).

  • Bug Fixes
    • Config: agent-config-handler, command-config-handler, tool-config-handler now resolve default_agent, refs, and permission keys via getAgentDisplayName.
    • Mapping/ordering: agent-key-remapper and agent-priority-order use clean display names for keys and sorting.
    • Cleanups: removed all getAgentListDisplayName imports, restored missing getAgentDisplayName imports, and updated tests to expect clean names.

Written for commit ad09192. Summary will update on new commits.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Apr 14, 2026

I have read the CLA Document and I hereby sign the CLA

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.

3 issues found across 14 files

Confidence score: 2/5

  • There is a high-confidence merge risk: src/plugin-handlers/config-handler.test.ts has a duplicate import specifier, which makes the test file invalid TypeScript and is likely to fail checks immediately.
  • src/plugin-handlers/agent-config-handler.test.ts removes PluginComponents while it is still referenced as a type, creating an unresolved type error that breaks source validity.
  • src/plugin-handlers/agent-key-remapper.test.ts also appears out of sync with the new display-name sorting behavior, so test expectations should be updated to avoid regression in test outcomes.
  • Pay close attention to src/plugin-handlers/config-handler.test.ts, src/plugin-handlers/agent-config-handler.test.ts, and src/plugin-handlers/agent-key-remapper.test.ts - compile-time/type validity and test expectation mismatches are likely to block a clean merge.
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/agent-config-handler.test.ts">

<violation number="1" location="src/plugin-handlers/agent-config-handler.test.ts:14">
P1: Custom agent: **Opencode Compatibility**

Removing the `PluginComponents` import leaves an unresolved type reference in this test file, so the change breaks source validity.</violation>
</file>

<file name="src/plugin-handlers/config-handler.test.ts">

<violation number="1" location="src/plugin-handlers/config-handler.test.ts:7">
P0: Custom agent: **Opencode Compatibility**

Duplicate import specifier makes the test file invalid TypeScript.</violation>
</file>

<file name="src/plugin-handlers/agent-key-remapper.test.ts">

<violation number="1" location="src/plugin-handlers/agent-key-remapper.test.ts:99">
P2: Update the expected sorted order to match the clean display names, or this test will fail after removing the ZWSP prefixes.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment on lines +99 to +102
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 14, 2026

Choose a reason for hiding this comment

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

P2: Update the expected sorted order to match the clean display names, or this test will fail after removing the ZWSP prefixes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/plugin-handlers/agent-key-remapper.test.ts, line 99:

<comment>Update the expected sorted order to match the clean display names, or this test will fail after removing the ZWSP prefixes.</comment>

<file context>
@@ -96,10 +96,10 @@ describe("remapAgentKeysToDisplayNames", () => {
-      getAgentListDisplayName("hephaestus"),
-      getAgentListDisplayName("prometheus"),
-      getAgentListDisplayName("atlas"),
+      getAgentDisplayName("sisyphus"),
+      getAgentDisplayName("hephaestus"),
+      getAgentDisplayName("prometheus"),
</file context>
Suggested change
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
getAgentDisplayName("atlas"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("sisyphus"),
Fix with Cubic

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aaa724932

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 161 to +162
(params.config as { default_agent?: string }).default_agent =
getAgentListDisplayName(configuredDefaultAgent);
getAgentDisplayName(configuredDefaultAgent);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize default_agent through config-key parser

default_agent is now canonicalized with getAgentDisplayName(configuredDefaultAgent), which does not strip legacy ZWSP list prefixes. If an existing config still contains an old prefixed value (for example from prior releases), this assignment keeps the prefix while config.agent keys are remapped to unprefixed display names, so the default agent can stop matching any exported agent key after upgrade. Resolve the input with getAgentConfigKey(...) before converting back to a display name.

Useful? React with 👍 / 👎.

Comment on lines +19 to 20
return (agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as
| AgentWithPermission
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy prefixed-key lookup in agentByKey

This helper no longer checks the legacy list-display form, so agent permission patching now misses entries keyed with old prefixed names (for example \u200B...Atlas - Plan Executor). Those legacy keys can still appear in upgraded configs, and when they do, blocks like atlas/sisyphus permission hardening are skipped, leading to inconsistent tool permissions. Keep a prefixed-key fallback or normalize agentResult keys before lookups.

Useful? React with 👍 / 👎.

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 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad09192318

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


for (const [key, value] of Object.entries(agents)) {
const displayName = getAgentListDisplayName(key)
const displayName = getAgentDisplayName(key)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize legacy prefixed keys before remapping agents

Using getAgentDisplayName(key) directly leaves legacy ZWSP-prefixed keys unchanged, while builtin config keys (for example atlas) are remapped to the new clean display name. In upgraded configs that still contain prefixed keys, this now produces two entries for the same core agent (clean and prefixed), and downstream logic keyed by clean names can skip the legacy entry (ordering/permission updates), causing inconsistent runtime behavior.

Useful? React with 👍 / 👎.

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.

[Bug]: Header 'x-opencode-agent-name' has invalid value: '​Atlas (Plan Executor)'

1 participant