Skip to content

fix: use display name in runtime-fallback retry#2891

Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
codivedev:fix/issue-2882
Mar 27, 2026
Merged

fix: use display name in runtime-fallback retry#2891
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
codivedev:fix/issue-2882

Conversation

@codivedev
Copy link
Copy Markdown
Contributor

@codivedev codivedev commented Mar 27, 2026

Fixes #2882

When runtime_fallback is enabled and a retryable error occurs, the retry mechanism was using the original agent name (e.g. 'sisyphus') instead of the remapped display name (e.g. 'Sisyphus (Ultraworker)').

This caused the error: "Agent not found: 'sisyphus'. Available agents: Sisyphus (Ultraworker), Atlas (Plan Executor)..."

Changes:

  • Import getAgentDisplayName from ../../shared/agent-display-names
  • Convert retryAgent to display name before passing to promptAsync
  • Update test to expect display name instead of config key

The fix ensures that when retrying with a fallback model, the agent name is properly converted to its display name format before being passed to the API.


Summary by cubic

Fixes #2882. Use the agent display name during runtime-fallback retries so the API can find the agent and the retry succeeds.

  • Bug Fixes
    • Convert the retry agent to its display name with getAgentDisplayName before calling promptAsync.
    • Update the test to expect the display name instead of the config key.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@codivedev
Copy link
Copy Markdown
Contributor Author

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.

No issues found across 2 files

Confidence score: 5/5

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

Auto-approved: Fixes agent identification error in runtime-fallback retry by using display names instead of internal keys. Verified by test updates.

@codivedev
Copy link
Copy Markdown
Contributor Author

recheck

@RaviTharuma
Copy link
Copy Markdown
Contributor

@cubic-dev which path is better using the display name or the id?
which solution is the cleanest and the right one long term?

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Mar 27, 2026

@cubic-dev which path is better using the display name or the id?
which solution is the cleanest and the right one long term?

@RaviTharuma In the current architecture of Opencode, using the display name (which often acts as the registration key) is the correct path because that is what the backend uses as the primary identifier.

The Trade-off

  • Display Name (Current Solution): This is necessary right now because the API expects a match against the strings listed in the error message (e.g., "Prometheus (Plan Builder)"). In Opencode, agents are identified by their registration record keys rather than a separate hidden ID field. If you pass the internal slug (prometheus), the registry lookup fails.
  • Internal ID/Slug (Long-term Ideal): Conventionally, using a stable, machine-readable ID (like prometheus) is "cleaner" because it doesn't break if someone decides to rename the agent's display label. However, implementing this would require a change to the backend registry to support aliasing or a dedicated id field.

Recommendation for this PR

The current solution using getAgentDisplayName is the right one for this fix. It correctly maps the internal reference to the string the API is keyed on.

Long-term improvement:
If the team wants to make the system more resilient to UI changes, the "cleanest" evolution would be:

  1. Update the agent registration to include both a stable id (slug) and a displayName.
  2. Update the backend to resolve the agent field in promptAsync by checking the id first, then falling back to the registration key.

Since the immediate goal is to fix the "Agent not found" error during runtime-fallback, your change is the pragmatic and correct way to align with the existing SDK behavior.

For more details on how agents are registered and identified, you can check the Core Architecture or the repository learnings regarding agent configuration.

@RaviTharuma
Copy link
Copy Markdown
Contributor

@cubic-dev

So we should take the display name because OpenCode itself does not even use the ID.
Although the ID would be the cleanest solution. Is this what you are saying?

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Mar 27, 2026

@cubic-dev

So we should take the display name because OpenCode itself does not even use the ID.
Although the ID would be the cleanest solution. Is this what you are saying?

@RaviTharuma Exactly. To clarify, what we call the "ID" or "slug" internally (like sisyphus or prometheus) is essentially invisible to the OpenCode backend's agent registry. The backend only knows about the agents by the keys they were registered with, which are their full display names (e.g., Sisyphus (Ultraworker)).

So, while using a stable, machine-readable ID is the better engineering practice for the long term, it isn't currently an option without changing how the backend identifies agents.

This matches our repository learnings which note that agents are identified by their registration record key rather than a specific ID property. Your current fix is the correct way to handle this given the current architecture.

Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu left a comment

Choose a reason for hiding this comment

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

Correct fix. The promptAsync call needs display name format (e.g., "Sisyphus (Ultraworker)") not config key ("sisyphus"), same pattern as how OpenCode registers agents. Test update is also correct. LGTM.

@code-yeongyu code-yeongyu merged commit 6310924 into code-yeongyu:dev Mar 27, 2026
2 checks passed
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.

runtime-fallback retry fails with 'Agent not found' due to agent name remapping

3 participants