fix(frontend): name new agents after the message that created them - #5526
fix(frontend): name new agents after the message that created them#5526ashrafchowdury wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesAgent naming flow
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
web/oss/src/components/pages/agent-home/assets/agentName.tsweb/oss/src/components/pages/agent-home/hooks/useCreateAgent.ts
| const words = name.split(" ") | ||
| while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1].toLowerCase())) { | ||
| words.pop() | ||
| } | ||
| name = words.join(" ").replace(/[\s.,;:!?/\\|—–-]+$/, "") |
There was a problem hiding this comment.
🎯 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.
| 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(" ") |
Railway Preview Environment
|
There was a problem hiding this comment.
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
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 fewcreations the agent list is unreadable and the slugs are indistinguishable in API calls.
useCreateAgentfell back to the literal string "New agent" whenever the caller passedno 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
useCreateAgentnow names the agent from the seed message the user already typed. Itfalls back to "New agent" only when there is nothing usable to name from.
The new
deriveAgentNameFromMessagehelper 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:
Tests
tsc --noEmitis clean acrossweb/oss. ESLint and Prettier are clean on both files.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.
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
template. The list shows a name taken from your description, and the slug in the edit
modal matches that name.
/playgroundroute, which commitsin place with no redirect). Same result.
unchanged from before this PR.