Skip to contents

Copies a configured ellmer chat into a new agent that owner keeps for later calls, for example through a delegation_tool(). The copy keeps the provider, model settings, system prompt, tools and, optionally, turns, but drops callbacks such as on_tool_request(); the new agent's permissions and hooks apply instead. The original chat is unchanged but shares its tools, and any state they hold, with the copy. To keep an existing Agent, use owner$retain_agent(). See vignette("retained-agents").

Usage

adopt_chat(
  chat,
  owner,
  permissions,
  usage_limits,
  history,
  callbacks,
  name = NULL,
  max_runs = 32L
)

Arguments

chat

A configured ellmer Chat.

owner

The Agent that will own and call the new agent.

permissions

Permissions for the new agent. The owner's current permissions also apply to every call.

usage_limits

UsageLimits for all calls combined.

history

"retain" to copy the chat's turns, or "fresh" to start with an empty history.

callbacks

Must be "replace", to confirm that the chat's callbacks are dropped.

name

Optional display name for the new agent.

max_runs

Maximum number of calls. Defaults to 32.

Value

A handle for delegation_tool() and for owner's $continue_agent(), $cancel_agent() and $release_agent(). It only works with owner.