Skip to content

chore(backend): Rename taskId -> agentTaskId#8013

Open
tmilewski wants to merge 3 commits intomainfrom
tom/task-id-to-agent-task-id
Open

chore(backend): Rename taskId -> agentTaskId#8013
tmilewski wants to merge 3 commits intomainfrom
tom/task-id-to-agent-task-id

Conversation

@tmilewski
Copy link
Member

@tmilewski tmilewski commented Mar 9, 2026

Description

Added agentTaskId, and deprecated taskId.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Responses now include a new agentTaskId field for Agent Tasks.
  • Deprecations

    • The taskId field is deprecated; migrate to agentTaskId for future compatibility.
  • Tests

    • Updated tests to reflect the new response shape.
  • Chores

    • Changelog updated for a patch release.

@tmilewski tmilewski self-assigned this Mar 9, 2026
@vercel
Copy link

vercel bot commented Mar 9, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Mar 9, 2026 9:47pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: 5c576d0

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

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

The PR adds agent_task_id to the AgentTask JSON shape and marks task_id as deprecated. AgentTask gains a new agentTaskId field; its constructor and fromJSON are updated to accept and map agent_task_id (falling back to task_id). Tests and the changelog were updated to reflect the new response shape and property.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: renaming taskId to agentTaskId across the backend codebase. It is concise, specific, and clearly communicates the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 9, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8013

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8013

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8013

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8013

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8013

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8013

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8013

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8013

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8013

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8013

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8013

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8013

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8013

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8013

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8013

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8013

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8013

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8013

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8013

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8013

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8013

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8013

commit: 5c576d0

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/backend/src/api/resources/JSON.ts`:
- Around line 516-520: AgentTaskJSON and AgentTask.fromJSON must remain
backward-compatible with the legacy task_id field: update the AgentTaskJSON
interface to include an optional legacy field (task_id?: string) and modify
AgentTask.fromJSON to read agent_task_id first and, if missing, fall back to
task_id, populating the internal agentTaskId (and any related getters) from
whichever key is present; ensure both keys are accepted during the deprecation
window so older API responses still produce a valid AgentTask instance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f29cea65-108a-4391-8fcf-ff991334233f

📥 Commits

Reviewing files that changed from the base of the PR and between 20a5620 and 10292ef.

📒 Files selected for processing (4)
  • .changeset/cute-places-wear.md
  • packages/backend/src/api/__tests__/AgentTaskApi.test.ts
  • packages/backend/src/api/resources/AgentTask.ts
  • packages/backend/src/api/resources/JSON.ts

Comment on lines 516 to 520
export interface AgentTaskJSON extends ClerkResourceJSON {
object: typeof ObjectType.AgentTask;
agent_id: string;
task_id: string;
agent_task_id: string;
url: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Keep accepting task_id during the deprecation window.

Line 519 hard-renames the wire shape in a patch release, but the PR description says the old field is only deprecated. If an older API response still sends only task_id, AgentTask.fromJSON will populate both taskId and agentTaskId as undefined. Please keep the legacy key optional until the actual removal and fall back to it when agent_task_id is absent.

Proposed compatibility fix
 export interface AgentTaskJSON extends ClerkResourceJSON {
   object: typeof ObjectType.AgentTask;
   agent_id: string;
-  agent_task_id: string;
+  /**
+   * `@deprecated` Use `agent_task_id` instead.
+   */
+  task_id?: string;
+  agent_task_id?: string;
   url: string;
 }
 static fromJSON(data: AgentTaskJSON): AgentTask {
-  return new AgentTask(data.agent_id, data.agent_task_id, data.agent_task_id, data.url);
+  const agentTaskId = data.agent_task_id ?? data.task_id;
+  return new AgentTask(data.agent_id, agentTaskId, agentTaskId, data.url);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/backend/src/api/resources/JSON.ts` around lines 516 - 520,
AgentTaskJSON and AgentTask.fromJSON must remain backward-compatible with the
legacy task_id field: update the AgentTaskJSON interface to include an optional
legacy field (task_id?: string) and modify AgentTask.fromJSON to read
agent_task_id first and, if missing, fall back to task_id, populating the
internal agentTaskId (and any related getters) from whichever key is present;
ensure both keys are accepted during the deprecation window so older API
responses still produce a valid AgentTask instance.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/backend/src/api/resources/AgentTask.ts (1)

10-28: ⚠️ Potential issue | 🔴 Critical

Keep the AgentTask constructor backward-compatible.

AgentTask is re-exported from packages/backend/src/index.ts, so adding a required agentTaskId parameter before url is a breaking public API change. Existing callers using new AgentTask(agentId, taskId, url) will now get agentTaskId === url and url === undefined at runtime.

Suggested fix
 export class AgentTask {
   constructor(
     /**
      * A stable identifier for the agent, unique per agent_name within an instance.
      */
     readonly agentId: string,
     /**
      * A unique identifier for this agent task.
      * `@deprecated` Use agentTaskId instead.
      */
     readonly taskId: string,
-    /**
-     * A unique identifier for this agent task.
-     */
-    readonly agentTaskId: string,
     /**
      * The FAPI URL that, when visited, creates a session for the user.
      */
     readonly url: string,
+    /**
+     * A unique identifier for this agent task.
+     */
+    readonly agentTaskId: string = taskId,
   ) {}
@@
   static fromJSON(data: AgentTaskJSON): AgentTask {
     const agentTaskId = data.agent_task_id ?? data.task_id ?? '';
-    return new AgentTask(data.agent_id, agentTaskId, agentTaskId, data.url);
+    return new AgentTask(data.agent_id, data.task_id ?? agentTaskId, data.url, agentTaskId);
   }
 }

Also applies to: 36-38

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/backend/src/api/resources/AgentTask.ts` around lines 10 - 28, The
AgentTask constructor change is breaking callers that pass (agentId, taskId,
url); make agentTaskId optional and restore backward-compatibility by detecting
the old call shape inside the constructor: if the third argument looks like the
URL (i.e., url is undefined and agentTaskId is present), shift values so
agentTaskId gets taskId and url gets the third arg, or alternatively accept
agentTaskId?: string and when url is undefined treat the third param as url and
set agentTaskId = taskId; update the constructor signature (AgentTask) and its
internal argument handling accordingly so existing new AgentTask(agentId,
taskId, url) continues to work.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/backend/src/api/resources/AgentTask.ts`:
- Around line 10-28: The AgentTask constructor change is breaking callers that
pass (agentId, taskId, url); make agentTaskId optional and restore
backward-compatibility by detecting the old call shape inside the constructor:
if the third argument looks like the URL (i.e., url is undefined and agentTaskId
is present), shift values so agentTaskId gets taskId and url gets the third arg,
or alternatively accept agentTaskId?: string and when url is undefined treat the
third param as url and set agentTaskId = taskId; update the constructor
signature (AgentTask) and its internal argument handling accordingly so existing
new AgentTask(agentId, taskId, url) continues to work.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a1ae0aa6-9629-4412-9ae6-244a0aaa5541

📥 Commits

Reviewing files that changed from the base of the PR and between 10292ef and 5c576d0.

📒 Files selected for processing (2)
  • packages/backend/src/api/resources/AgentTask.ts
  • packages/backend/src/api/resources/JSON.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/backend/src/api/resources/JSON.ts

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants