Skip to content

[front] Move agent archive/restore/hard-delete into AgentResource - #32927

Merged
tdraier merged 1 commit into
mainfrom
agent-resource-archive-restore-delete
Sep 22, 2026
Merged

tdraier merged 1 commit into
mainfrom
agent-resource-archive-restore-delete

Conversation

@tdraier

@tdraier tdraier commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Description

Continues centralizing agent mutations in AgentResource.

  • archiveAgentConfiguration / restoreAgentConfigurationAgentResource.archive(auth) / AgentResource.restore(auth) instance methods (same behavior: trigger disable/re-enable, wake-up cancel, audit, cache invalidation, reindex).
  • unsafeHardDeleteAgentConfigurationAgentResource.delete(auth), which now purges all versions, their satellites (tools + data-source/table/child-agent links, tags, skills, suggestions), the scoped resources (triggers, wake-ups, favorites, with the Temporal-cleanup completeness guard), the grants/groups and the agents identity row, then invalidates the cache and removes the agent from the search index.

Callers fetch the resource and call the method; scrub_agent delegates the whole teardown to delete(). The per-version row helpers (destroyAgentConfigurationRow, syncAgentSearchAfterRowDestroyed, batchHardDeletePendingAgentConfigurations) are kept for their script/temporal callers.

Tests

front + front-api typecheck clean; all affected suites pass (agent, agent_resource, indexation, grants, conversation, views, tool servers, and the front-api route tests).

Risk

Low–medium. Archive/restore behavior is unchanged. delete() is only reachable from the internal scrub_agent script and now removes every version in one transaction instead of looping per version.

Deploy Plan

Standard.

🤖 Generated with Claude Code

@tdraier

tdraier commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated
playground Ignored Ignored Preview Sep 22, 2026 3:11pm UTC
storybook Ignored Ignored Preview Sep 22, 2026 3:11pm UTC

Request Review

Base automatically changed from centralize-agent-tag-mutations to gate-editors-through-updateconfiguration September 22, 2026 08:19
Base automatically changed from gate-editors-through-updateconfiguration to main September 22, 2026 08:44
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Files in front-api/routes/v1/ have been modified and the PR has the documentation-ack label.
Don't forget to run npm -w front-api run docs and use the Deploy OpenAPI Docs Github action to update https://docs.dust.tt/reference.

⚠️

Temporal workflow/activity files have been modified:
- front/temporal/scrub_workspace/activities.ts

**IMPORTANT**: Renaming activity functions can cause non-deterministic errors in Temporal workflows.

Running workflows may still reference the old activity names, which will cause failures when they try to execute.

Best practices:
- **DO NOT** rename existing activity functions
- **DO** create new activities with new names if you need different behavior
- **DO** use activity versioning patterns if you must change activity signatures
- **DO** ensure all running workflows complete before removing old activities

If you're only adding new activities or fixing bugs within existing ones, this warning can be ignored.

Generated by 🚫 dangerJS against 1287365

@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch 2 times, most recently from ab63b14 to 3c14a20 Compare September 22, 2026 09:40
Comment thread front/lib/resources/agent_resource.ts
Comment thread front/lib/resources/agent_resource.ts
Comment thread front/lib/resources/agent_resource.ts
Comment on lines +1467 to +1471
if (this.status !== "archived") {
return new Err(
new DustError("internal_error", "Agent configuration is not archived")
);
}

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.

should this just be a return with restored: false ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same api as before, i think it's ok to return an error when archiving something already archived

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.

I think restore/archive should behave the same, if restoring an active agent errors, then archiving an archived agent should error as well

Comment thread front/lib/resources/agent_resource.ts Outdated
Comment thread front-api/routes/poke/workspaces/[wId]/agent_configurations/[aId]/index.ts Outdated
Comment thread front-api/routes/v1/w/[wId]/assistant/agent_configurations/[sId]/index.ts Outdated
Comment thread front-api/routes/w/[wId]/assistant/agent_configurations/[aId]/index.ts Outdated
@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch from 3c14a20 to 5bebef7 Compare September 22, 2026 12:35
@tdraier tdraier added the documentation-ack Used to acknowledge that documentation is up-to-date with this PR label Sep 22, 2026
@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch 2 times, most recently from b7d9088 to ea175a9 Compare September 22, 2026 13:04
@tdraier

tdraier commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

r? @sfriquet updated, ptal

@github-actions
github-actions Bot requested a review from sfriquet September 22, 2026 13:23
@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch from ea175a9 to c7a42cd Compare September 22, 2026 13:26
Comment thread front/lib/resources/agent_resource.ts Outdated
Comment thread front/lib/resources/agent_resource.ts

@github-actions github-actions Bot 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.

cc-verify: violations found!

  • agent-verbs: Lifecycle mutations bypass write permission
  • no-catching-own-errors: Expected failure is thrown
  • functional-endpoint-tests: Restore authorization lacks endpoint coverage
  • resource-identifier-naming: Numeric IDs use string-ID names

Comment thread front/lib/resources/agent_resource.ts Outdated
Comment thread front/lib/resources/agent_resource.ts
Comment thread front/lib/resources/agent_resource.ts Outdated
Comment thread front/lib/resources/agent_resource.ts Outdated
Comment thread front/lib/resources/agent_resource.ts Outdated
@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch 3 times, most recently from 29a26d9 to 9dc9f43 Compare September 22, 2026 14:48
Turn archiveAgentConfiguration and restoreAgentConfiguration into
AgentResource.archive/restore instance methods, and replace
unsafeHardDeleteAgentConfiguration with AgentResource.delete, which purges all
versions, their satellites (tools, tags, skills, suggestions), scoped resources
(triggers, wake-ups, favorites), grants/groups and the agents identity row, then
invalidates the cache and removes the agent from the search index. Callers fetch
the resource and call the method; scrub_agent now delegates the full teardown to
delete(). Row-level helpers (destroyAgentConfigurationRow, ...) are kept for the
per-version scripts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tdraier
tdraier force-pushed the agent-resource-archive-restore-delete branch from 9dc9f43 to 1287365 Compare September 22, 2026 15:11
continue;
}

const editorAuth = await Authenticator.fromUserIdAndWorkspaceId(

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.

React Doctor · react-doctor/async-await-in-loop (warning)

This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))

Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time

Docs

auth,
this.sId
);
const remainingWakeUps = await WakeUpResource.listByAgentConfigurationId(

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.

React Doctor · react-doctor/server-sequential-independent-await (warning)

This await doesn't use the previous result, so your users wait twice as long for nothing.

Fix → These two awaits don't depend on each other. Wrap them in Promise.all([...]) so they run at the same time.

Docs

);
for (const agentConfiguration of agentConfigurationsToArchive) {
await archiveAgentConfiguration(auth, agentConfiguration.sId);
const agentToArchive = await AgentResource.fetchById(

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.

React Doctor · react-doctor/async-await-in-loop (warning)

This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))

Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time

Docs

@tdraier
tdraier merged commit 0104796 into main Sep 22, 2026
66 of 67 checks passed
@tdraier
tdraier deleted the agent-resource-archive-restore-delete branch September 22, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation-ack Used to acknowledge that documentation is up-to-date with this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants