Skip to content

Constrain agent names to hyphen-only 2–64 and migrate ./_ names - #536

Open
bhaveshpatel640 wants to merge 10 commits into
mainfrom
AGE-2065
Open

Constrain agent names to hyphen-only 2–64 and migrate ./_ names#536
bhaveshpatel640 wants to merge 10 commits into
mainfrom
AGE-2065

Conversation

@bhaveshpatel640

@bhaveshpatel640 bhaveshpatel640 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Align TrueForge agent names to hyphen-only 2–64 char and migration to enforce hyphen-only naming convention

Closes AGE-2065

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Irreversible data migration renames live agent identifiers and denormalized references; API clients can no longer create agents with . or _ in names.

Overview
Introduces a dedicated AgentName type (OpenAPI, SDK, and Zod) for agent registry identifiers: 2–64 lowercase characters, hyphens only between the leading letter and trailing alphanumeric. Agent create/list, schedules’ agent_name, and session name refs now validate against this stricter rule instead of generic ResourceName (which still allows . and _ for other resources like schedule names).

Create agent requests with dotted or underscored names are rejected; reserved names (tfg, trueforge) behavior is unchanged.

A one-way Postgres/SQLite migration rewrites existing agents whose names contain . or _ by hyphenating and appending a random 4-hex suffix (with truncation to fit 64 chars), and updates denormalized session.agent_name and schedule.agent_name to match. Original names are not preserved.

Unit tests cover AgentNameSchema, rename planning, and API rejection of invalid agent names.

Reviewed by Cursor Bugbot for commit d9217da. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d9217da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bhaveshpatel640
bhaveshpatel640 force-pushed the AGE-2065 branch 2 times, most recently from a62baaa to 8b89256 Compare September 1, 2026 12:09
Comment thread packages/trueforge/src/db/planAgentNameHyphenRenames.ts Outdated
Comment thread packages/trueforge/src/db/planAgentNameHyphenRenames.ts Outdated
@bhaveshpatel640
bhaveshpatel640 marked this pull request as draft September 1, 2026 13:07
@bhaveshpatel640
bhaveshpatel640 force-pushed the AGE-2065 branch 2 times, most recently from b442af5 to 1081bee Compare September 3, 2026 12:25
@bhaveshpatel640 bhaveshpatel640 changed the title Align TrueForge agent names to hyphen-only 2–64 char and migration to enforce hyphen-only naming convention Constrain agent names to hyphen-only 2–64 and migrate existing names with ./_ Sep 3, 2026
@bhaveshpatel640
bhaveshpatel640 marked this pull request as ready for review September 3, 2026 12:26
@bhaveshpatel640
bhaveshpatel640 marked this pull request as draft September 3, 2026 12:27
@bhaveshpatel640
bhaveshpatel640 marked this pull request as ready for review September 3, 2026 13:45
@bhaveshpatel640 bhaveshpatel640 changed the title Constrain agent names to hyphen-only 2–64 and migrate existing names with ./_ Constrain agent names to hyphen-only 2–64 and migrate ./_ names Sep 3, 2026

@cursor cursor 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.

Stale Bugbot comment from a previous run.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dd2b040. Configure here.

UPDATE schedule
SET agent_name = ${rename.to}
WHERE tenant_id = ${rename.tenant_id} AND agent_name = ${rename.from}
`.execute(db);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remote TrueFoundry agents stay unrenamed

Medium Severity

The migration rewrites only local agent.name (and denormalized session/schedule copies). In TrueFoundry mode, putRemoteAgent is keyed by name and does not receive external_id, so the next agent update PUTs the new local name and can create a new ServiceFoundry agent, orphan the old remote, and drop MCP grants bound to it.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dd2b040. Configure here.

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