Skip to content

fix(agent-repository): resolve copied agent name conflicts - #3803

Open
MoeexT wants to merge 4 commits into
developfrom
fix/moeext/repo-agent-copy
Open

fix(agent-repository): resolve copied agent name conflicts#3803
MoeexT wants to merge 4 commits into
developfrom
fix/moeext/repo-agent-copy

Conversation

@MoeexT

@MoeexT MoeexT commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

fix:

  1. copied agent can't be published because duplicate agent name and agent var name
  2. click edit button on agent repo page, then the page will route to another agetn
图片

Copilot AI lite review requested due to automatic review settings August 28, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an opt-in mechanism to resolve agent name / display_name conflicts during agent imports, and enables it specifically for marketplace (agent repository) imports to prevent duplicate-name collisions that block publishing and can misroute “edit” flows that rely on unique agent names.

Changes:

  • Add resolve_name_conflicts plumbing through import_agent_impl(...), import_agent_by_agent_id(...), and import_agent_with_skills_impl(...).
  • When enabled, automatically suffix-conflict agent name and display_name (e.g., _1) before creating the imported agent.
  • Extend service tests to assert the flag is passed for repository imports and verify suffixing behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
backend/services/agent_service.py Adds resolve_name_conflicts flag and implements name/display_name conflict resolution during import.
backend/services/agent_repository_service.py Enables conflict resolution for all repository import paths (with and without skills).
test/backend/services/test_agent_service.py Adds/updates tests to cover conflict resolution behavior and new function signature.
test/backend/services/test_agent_repository_service.py Asserts repository import passes resolve_name_conflicts=True into import routines.
Suppressed comments (1)

backend/services/agent_service.py:2529

  • Same as agent_name: if display_name suffix generation hits max_suffix_attempts, the resulting error lacks any context (which display_name/tenant caused it). Re-raise with the base display_name and tenant_id so the failure is diagnosable.
            agent_display_name = _generate_unique_display_name_with_suffix(
                agent_display_name,
                tenant_id=tenant_id,
                agents_cache=agents_cache,
            )

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2508 to +2512
if resolve_name_conflicts:
agents_cache = query_all_agent_info_by_tenant_id(tenant_id)
if _check_agent_name_duplicate(
agent_name,
tenant_id=tenant_id,
Comment on lines +2515 to +2519
agent_name = _generate_unique_agent_name_with_suffix(
agent_name,
tenant_id=tenant_id,
agents_cache=agents_cache,
)
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@MoeexT
MoeexT force-pushed the fix/moeext/repo-agent-copy branch from 083841c to 6dcbe72 Compare August 29, 2026 01:17
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.

2 participants