Anthropic ManagedAgentSession

Anthropic ManagedAgentSession

Certified

Run a Claude Code session on Claude Managed Agents

Creates an agent, starts a session in an Anthropic-managed cloud environment, sends the prompt, and follows the session events in the execution logs until the agent stops. Nothing has to be installed or hosted on the Kestra side. The task authenticates with an Anthropic API key only. Killing the execution interrupts the session. See the Managed Agents documentation.

yaml
type: io.kestra.plugin.anthropic.ManagedAgentSession

Fix a failing test in a repository, with a spending limit.

yaml
id: claude_code_session
namespace: company.team

tasks:
  - id: session
    type: io.kestra.plugin.anthropic.ManagedAgentSession
    apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
    model: claude-sonnet-5
    systemPrompt: "You are a careful engineer. Make the smallest change that works."
    prompt: "Investigate the flaky test in the CI logs, fix it, and open a pull request."
    maxCostUsd: 5
    repository:
      url: https://github.com/acme/app
      branch: main
      token: "{{ secret('GITHUB_TOKEN') }}"

  - id: report
    type: io.kestra.plugin.core.log.Log
    message: "{{ outputs.session.status }} ({{ outputs.session.costUsd }} USD): {{ outputs.session.message }}"
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-anthropic --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

Anthropic API Key

Model

Claude model the agent runs on, for example claude-sonnet-5.

Prompt

The task the agent works through on its own.

SubTypestring

Allowed hosts

Hosts the sandbox may reach when networking is LIMITED. MCP servers and package managers are allowed in that mode.

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Base URL

Optional Anthropic-compatible endpoint. Defaults to the SDK endpoint. Requests, including the API key, are sent to this host, so set it with forced: true in plugin defaults when the API key comes from there.

Connect timeout

Connection timeout as an ISO-8601 duration. Defaults to PT1M, and zero disables it.

Environment ID

Existing environment to run in. When empty, a cloud environment is created for the run with the network access set by networking, then archived afterwards.

Spending limit in USD

Must be greater than 0. The session pauses once its list cost reaches this amount, and the task then ends with status SPENDING_LIMIT_REACHED. No limit applies when unset.

Default2

Maximum retries

SDK retries for transient errors, between 0 and 10. Defaults to 2, and 0 disables them.

MCP servers

Remote MCP servers the agent can call.

Definitions
name*string

Server name

Unique name of the MCP server within the agent.

url*string

Server URL

DefaultUNRESTRICTED
Possible Values
UNRESTRICTEDLIMITED

Environment networking

Network access of the environment created for the run, ignored when environmentId is set. UNRESTRICTED lets the sandbox reach any host. Because the sandbox holds the repository token and MCP credentials, prefer LIMITED with allowedHosts whenever the prompt or the repository content is not fully trusted.

Read timeout

Maximum time for a response as an ISO-8601 duration, both between packets and for the whole call. Defaults to the SDK timeout (PT10M), and zero disables it.

Git repository

Repository mounted in the session sandbox before the agent starts.

Definitions
url*string

Repository URL

branchstring

Branch to check out

tokenstring

Access token

Token used to clone the repository and push changes.

Skills

Skills made available to the agent.

Definitions
skillId*string

Skill ID

typestring
Possible Values
ANTHROPICCUSTOM

Skill type

ANTHROPIC for prebuilt skills, CUSTOM for skills uploaded to your organization.

System prompt

Optional system instructions for the agent.

Cost in USD

List cost of the session, when reported by the API.

Final message

Last message written by the agent.

Session ID

ID of the Managed Agents session, usable to inspect it in the Claude Console.

Possible Values
FINISHEDSPENDING_LIMIT_REACHEDMAX_TURNS_REACHEDWAITING_FOR_INPUTFAILED

Status

How the session ended.

Unittoken

Cache read tokens used by the session.

Unittoken

Input tokens used by the session.

Unittoken

Output tokens used by the session.