Skip to content

fix(frontend): name new agents after the message that created them - #5526

Open
ashrafchowdury wants to merge 1 commit into
mainfrom
fix/agent-auto-name-itself-from-input
Open

fix(frontend): name new agents after the message that created them#5526
ashrafchowdury wants to merge 1 commit into
mainfrom
fix/agent-auto-name-itself-from-input

Conversation

@ashrafchowdury

Copy link
Copy Markdown
Contributor

Context

Agents created from the home composer or from playground onboarding were all named
"New agent". The slug is minted from the name at creation and cannot be changed
afterwards, so every one of them landed as new-agent-<random-suffix>. After a few
creations the agent list is unreadable and the slugs are indistinguishable in API calls.

useCreateAgent fell back to the literal string "New agent" whenever the caller passed
no name, and both composer paths pass none. Template cards and the setup drawer pass a
real name and were never affected, which matches what the issue reported.

Fixes #5397.

Changes

useCreateAgent now names the agent from the seed message the user already typed. It
falls back to "New agent" only when there is nothing usable to name from.

The new deriveAgentNameFromMessage helper strips the markdown the composer can emit
(code fences, inline code, links, list and heading markers, emphasis), keeps the first
3 words capped at 32 characters, drops trailing filler words so a truncated name does
not dangle, then capitalises the result. It returns an empty string for blank or
non-alphanumeric input, so the caller keeps the old default.

Same user message, before and after:

message:  "Route incoming support tickets to the right team based on urgency"
before:   name "New agent",              slug new-agent-mrzh96mpa1
after:    name "Route incoming support", slug route-incoming-support-mrzh96mpa1

Tests

  • tsc --noEmit is clean across web/oss. ESLint and Prettier are clean on both files.
  • Ran the helper over realistic composer inputs: markdown emphasis and inline code,
    multi-line bullet lists, a heading plus body, a markdown link, empty string,
    whitespace only, emoji only, and a single word. Blank and emoji-only inputs fall back
    to "New agent" as intended.
  • For review: the 3-word / 32-character cap is the main tuning knob. It keeps slugs
    short but truncates mid-phrase on longer descriptions, so "Migrate all our legacy
    customer records from the old CRM" becomes "Migrate all our". Widening it is a
    one-line change if that reads badly in practice.

What to QA

  • On the agents home, type a description and create the agent without picking a
    template. The list shows a name taken from your description, and the slug in the edit
    modal matches that name.
  • Repeat through playground onboarding (the project /playground route, which commits
    in place with no redirect). Same result.
  • Submit with an empty composer. The agent is still created and is named "New agent".
  • Regression: create from a template card and from the setup drawer. Names and slugs are
    unchanged from before this PR.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Frontend labels Jul 27, 2026
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jul 27, 2026 1:06pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Agent names are now automatically generated from the initial composer message when no name is provided.
    • Generated names are cleaned up and formatted for readability.
  • Bug Fixes
    • Improved name-based identification when creating multiple agents quickly or from seeded messages.

Walkthrough

Changes

Agent naming flow

Layer / File(s) Summary
Message name derivation
web/oss/src/components/pages/agent-home/assets/agentName.ts
Adds message sanitization, word and character limits, filler-word and punctuation removal, validation, and capitalization for derived agent names.
Agent creation integration
web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
Uses the derived name for unnamed agents created from a seed message, falling back to "New agent" when derivation produces no usable name.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: deriving new agent names from the message that created them.
Description check ✅ Passed The description is directly related to the code changes and the reported agent-slug issue.
Linked Issues check ✅ Passed The changes satisfy #5397 by naming home/onboarding-created agents from user input instead of defaulting to "New agent".
Out of Scope Changes check ✅ Passed The PR stays focused on agent-name derivation and the create-agent flow, with no unrelated code changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-auto-name-itself-from-input

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ashrafchowdury
ashrafchowdury requested a review from ardaerzin July 27, 2026 13:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aa6e2bbb-e2bb-482d-882a-140378f8e524

📥 Commits

Reviewing files that changed from the base of the PR and between cb095f7 and 8dbb582.

📒 Files selected for processing (2)
  • web/oss/src/components/pages/agent-home/assets/agentName.ts
  • web/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts

Comment on lines +55 to +59
const words = name.split(" ")
while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1].toLowerCase())) {
words.pop()
}
name = words.join(" ").replace(/[\s.,;:!?/\\|—–-]+$/, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Strip terminal punctuation before checking filler words.

"Make report for." retains for because line 56 compares for. before line 59 removes .. Normalize punctuation first, then remove trailing fillers.

Proposed fix
-    const words = name.split(" ")
+    name = name.replace(/[\s.,;:!?/\\|—–-]+$/, "")
+    const words = name.split(" ")
     while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1].toLowerCase())) {
         words.pop()
     }
-    name = words.join(" ").replace(/[\s.,;:!?/\\|—–-]+$/, "")
+    name = words.join(" ")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const words = name.split(" ")
while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1].toLowerCase())) {
words.pop()
}
name = words.join(" ").replace(/[\s.,;:!?/\\|-]+$/, "")
name = name.replace(/[\s.,;:!?/\\|-]+$/, "")
const words = name.split(" ")
while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1].toLowerCase())) {
words.pop()
}
name = words.join(" ")

@github-actions

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-583c.up.railway.app/w
Project agenta-oss-pr-5526
Image tag pr-5526-fb5333b
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-07-27T13:18:36.271Z

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with the problem. However, I don't think this is the right approach. The beginning of a sentence does not tell much about Agents and is as random as New Agent

The problem is two fold. Which slug to use and which name to use.

For slug, it's problematic since we don't know what the agent is on creation. The best solution there in my opinion is to create a random human readable name. Something like this

For the name, we should provide the agent a tool to rename itself. The skill should tell it to use it on creation and after it has identified the goal.

What do you think @ashrafchowdury. Can you try updating the PR to do that @ashrafchowdury . There are minor backend changes needed to do this. I would love to see you attempting this. Make sure not to ask the agent to implement this, but first to research how it is done and understand (you and the agent) the architecture for our internal tools, and then plan where to put the implementation.

It might make sense to open a PR with the plan instead of the code. I can provide guidance that would help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Agent slugs default to new-agent and can't be edited

2 participants