Skip to main content

Agents, runs, sessions

Agents, presets & environments

Configurable agents are project-scoped definitions used by:

  • Interactive chat (agentDefinitionId on /api/ai/chat)
  • Event automations (must name an agent)
  • Headless Kubernetes Jobs (development agents with repository / setup / build / test)
  • Scheduled tasks targeting AgentRun

Agents — AgentsController (api/agents) — JWT

MethodPathAuthPurpose
GET/api/agents?projectId=Project memberList (+ automation counts)
GET/api/agents/{id}MemberDetail
POST/api/agentsMemberCreate config agent
PUT / DELETE/api/agents/{id}Member*Update / delete (*dev agents with repository: Admin only)
POST/api/agents/development-templateAdminSeed K8s dev agent (setup/build/test)
GET / POST / PUT / DELETE/api/agents/{id}/schedules…AdminLegacy agent cron schedules
POST/api/agents/{id}/runsAdminQueue K8s Job (Agents:Enabled or 503)
GET / POST / DELETE/api/agents/{id}/grants…MemberTool grants (not gated on Automations)

Create config agent (automations / chat):

{
"projectId": 1,
"name": "Support agent",
"description": null,
"providerId": null,
"systemPrompt": "You are a support agent. Read the customer message and draft a reply.",
"temperature": 0.2,
"isActive": true,
"mcpServerIds": [12],
"mcpAccountNames": { "12": "default" }
}

Member-facing CRUD cannot author RepositoryUrl, BaseBranch, setup/build/test commands, or budget fields — those are Admin / development-template concerns.

Start run:

{
"task": "Fix failing tests",
"idempotencyKey": "manual:abc",
"deliveryTarget": "PullRequest",
"gitHubInstallationId": 4287162
}

Tool grant:

{
"integrationConnectionId": "…",
"toolName": "pipedream__slack__send_message",
"externalActionKey": null,
"actionClass": "ExternalCommunication",
"allowedResourcePattern": "#support",
"maxCallsPerRun": 1,
"requiresApproval": true
}

Environments — AgentEnvironmentsController (api/agent-environments) — Admin

MethodPathPurpose
GET / POST/api/agent-environmentsList / create profiles
GET / PUT / DELETE/{id}CRUD
POST/ensure-universalEnsure shared universal profile
GET / POST/prewarmWorkspace image coverage / prewarm

Profiles override image, storage, CPU, memory, and declared egress hosts.


Agent runs (headless Jobs)

Controller: AgentRunsController (api/agent-runs) — Admin (Roles=Admin)

Requires Agents:Enabled + Kubernetes for execution. Runs are queued in PostgreSQL, leased, provisioned as Jobs in namespace agent-runs, and streamed via append-only events.

MethodPathPurpose
GET/api/agent-runs?agentId=List (≤200)
GET/{id}Run + artifacts summary
GET/{id}/events?after=SSE resumable event stream
POST/{id}/input{ "input": "…" } when WaitingForInput
POST/{id}/cancelCancel
POST/{id}/retryRetry
GET/{id}/artifactsArtifacts
POST/{id}/memory/{memoryId}/{decision}Memory review
curl -N "https://your-kroov-host/api/agent-runs/42/events?after=0" \
-H "Authorization: Bearer $ADMIN_JWT"

Interactive sessions

Controller: AgentSessionsController (api/sessions) — JWT (any authenticated user)
Feature bit: agentSessions = AgentSessions:Enabled && Kubernetes:Enabled

Sessions provision a persistent workspace pod (+ PVC). They can clone a GitHub repository or start empty (general-purpose) when both repositoryFullName and repositoryUrl are omitted. projectId remains required (security, billing, provider, MCP boundary).

MethodPathPurpose
GET / POST/api/sessionsList / create
GET/{id}Detail
GET/{id}/usageLifetime + per-turn usage
POST/{id}/messages{ "message": "…" }
POST/{id}/filesMultipart uploads (files)
POST/{id}/transcribeMultipart audio → text (audio)
PATCH/{id}/settingsprovider/model/mode/budgets
POST/{id}/messages/editEdit + rerun from sequence
POST/{id}/compactManual context compaction
POST/{id}/cancelCancel in-flight turn
POST/{id}/stopStop session
DELETE/{id}Tear down pod + PVC + history
GET/{id}/files?path=Download workspace file (≤25 MB; paths under /workspace/repository or /workspace/uploads)
GET/{id}/exportZIP export (≤50 MB, excludes .git)
GET/{id}/diagnosticsK8s provisioning diagnostics
GET/{id}/diff / /{id}/changesGit diff / changed files
GET/{id}/events?after=SSE event stream

Create:

{
"projectId": 1,
"repositoryFullName": "org/repo",
"repositoryUrl": "https://github.com/org/repo",
"branch": "main",
"gitHubInstallationId": 1,
"environmentProfileKey": "universal",
"providerId": 12,
"model": null,
"title": "Investigate flake",
"firstMessage": "Find why CI fails on main"
}

Omit both repository fields for an empty workspace (still requires projectId). Supplying one repository field requires both.

Settings patch:

{
"providerId": 12,
"model": "gpt-4o",
"mode": "Agent",
"maxInputContextTokens": 128000,
"maxTokens": 500000,
"maxEstimatedCostUsd": 25
}

Modes typically include Agent (read/write tools), Plan, and Ask (read-only tool sets).

Usage semantics: lifetime counters are TotalTurns, ActiveMs, TotalModelCalls, TotalToolCalls, InputTokens, OutputTokens. Per-turn guards ModelCalls / ToolCalls reset each turn — do not use them for lifetime reporting.

MCP tools assigned to the project (with the user’s credential/grant) are resolved automatically for interactive sessions.