---
title: "Agents hooks"
description: "Hand-written shim. Generated CRUD hooks via ./agents.gen.
useSyncAgent{Tools,Skills,McpServers} stay hand-written — they
target the surviving sub-resource sync classes on client.agents."
section: "Libraries"
group: "React hooks"
order: 401
---

## Hooks

### `useCreateAgent` `mutation`

Create an agent.

```ts
useCreateAgent(options?: MutationOpts<Agent, CreateAgentParams>)
```

**Types:** [Agent](/types/agent) · [CreateAgentParams](/types/create-agent-params)

### `useDeleteAgent` `mutation`

Soft-delete an agent.

```ts
useDeleteAgent(options?: MutationOpts<SuccessResponse, string>)
```

**Types:** [SuccessResponse](/types/success-response)

### `useListAgents` `query`

List agents.

```ts
useListAgents(params?: Omit<ListAgentsParams, | > & { filter?: AgentFilter; orderBy?: AgentOrderBy[]; } & AgentShorthands, options?: QueryOpts<Page<Agent>>)
```

**Types:** [ListAgentsParams](/types/list-agents-params) · [AgentFilter](/types/agent-filter) · [AgentOrderBy](/types/agent-order-by) · [AgentShorthands](/types/agent-shorthands) · [Page](/types/page) · [Agent](/types/agent)

### `usePurgeAgent` `composite`

Permanently delete a soft-deleted agent.

```ts
usePurgeAgent(options?: MutationOpts<SuccessResponse, PurgeAgentParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [PurgeAgentParams](/types/purge-agent-params)

### `useRestoreAgent` `composite`

Restore a soft-deleted agent.

```ts
useRestoreAgent(options?: MutationOpts<Agent, string>)
```

**Types:** [Agent](/types/agent)

### `useRetrieveAgent` `query`

Get an agent by ID.

```ts
useRetrieveAgent(id: string, options?: QueryOpts<Agent>)
```

**Types:** [Agent](/types/agent)

### `useSyncAgentMcpServers` `composite`

Replace all MCP server assignments for an agent in a single PUT.

```ts
useSyncAgentMcpServers(options?: MutationOpts<SuccessResponse, SyncAgentMcpServersParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [SyncAgentMcpServersParams](/types/sync-agent-mcp-servers-params)

```ts
const syncMcp = useSyncAgentMcpServers();
syncMcp.mutate({
  agentId: "agt_abc123",
  mcpServerIds: ["mcp_abc"],
});
```

### `useSyncAgentSkills` `composite`

Replace all skill assignments for an agent in a single PUT.

```ts
useSyncAgentSkills(options?: MutationOpts<SuccessResponse, SyncAgentSkillsParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [SyncAgentSkillsParams](/types/sync-agent-skills-params)

```ts
const syncSkills = useSyncAgentSkills();
syncSkills.mutate({
  agentId: "agt_abc123",
  skillIds: ["skl_system_aeontel_libraries"],
});
```

### `useSyncAgentTools` `composite`

Replace all tool assignments for an agent in a single PUT.
Pass the desired set; omitted IDs are unassigned. Invalidates
both agent and tool query caches on success.

```ts
useSyncAgentTools(options?: MutationOpts<SuccessResponse, SyncAgentToolsParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [SyncAgentToolsParams](/types/sync-agent-tools-params)

```ts
const syncTools = useSyncAgentTools();
syncTools.mutate({
  agentId: "agt_abc123",
  toolIds: ["tol_search", "tol_summarize"],
});
```

### `useUpdateAgent` `mutation`

Update an agent.

```ts
useUpdateAgent(options?: MutationOpts<Agent, UpdateAgentParams>)
```

**Types:** [Agent](/types/agent) · [UpdateAgentParams](/types/update-agent-params)
