Skip to Content
Recodocs

Agent management and audit

Console APIs to list managed agents, edit drafts and activations, control access, probe capabilities, promote candidates, and query audit history.

6 min read

Admin-owned agent management: configuration changes stay as drafts until a revision is explicitly activated. The module mounts four routers under the console HTTP API.

What this API area is for

The agent-management API separates configuration proposals from live versions. Listing, editing a draft and activating a revision have different effects and authority requirements.

These routes support the agent control plane in RecoX. Operators with read access can browse the managed agent fleet, read revision config, review recent activity, list system capabilities, inspect promotion candidates, and search audit events or lineage. Inspecting one agent returns agent_control.detail, fleet overview, and max_run_seconds from effective_budget. Administrators (and other roles allowed by each handler) can save configuration drafts, activate a revision, change per-agent or fleet-wide access, run a safe capability check, promote a candidate, and read prompt-cache diagnostics.

Edits that mutate runtime configuration or access require console write trust on the request where the handlers call require_console_write_trust. Several handlers add stricter role checks beyond the route permission ceiling (for example require_admin on cache diagnostics and capability checks).

Routes

MethodPathPermissionHandlerWhat it does
GET/api/agents/caching/statusagents.readcache_statusReturns prompt-cache diagnostics and storage status; also calls require_admin().
GET/api/agents/capabilitiesagents.readcapabilitiesReturns what RecoX can do as one system and whether each capability works right now (capability_board.board).
POST/api/agents/capabilities/checkagents.managecheck_capabilitiesTests what can be tested safely; writes and billed web search are never called; requires write trust and require_admin().
GET/api/agents/candidates/{candidate_id}agents.readcandidateReturns detail for one agent candidate.
POST/api/agents/candidates/{candidate_id}/promoteagents.managepromote_candidatepromote_candidate requires write trust and an admin actor, then returns agent_candidates.promote(...).
POST/api/agents/access/allagents.manageset_all_accessChanges access for all agents (registered before per-agent access so access is not parsed as an agent id); requires write trust and require_admin("agents.manage").
POST/api/agents/{agent_id}/accessagents.manageset_accessset_access sets one managed agent's stopped flag with expected_version (AccessConflict becomes stale) and requires write trust plus require_admin("agents.manage").
GET/api/agentsagents.readagentsReturns the managed agent directory (agent_fleet.directory).
GET/api/agents/{agent_id}agents.readagentReturns agent detail, fleet overview, and max_run_seconds from effective budget.
GET/api/agents/{agent_id}/activityagents.readactivityReturns recent audit events for the agent (limit query, default 5, clamped between 1 and 20).
POST/api/agents/{agent_id}/draftsagents.managesaveSaves a configuration draft (HTTP 201); idempotent when request_id is set; requires write trust and require_role(DRAFT_ROLES).
GET/api/agents/{agent_id}/revisions/{revision}agents.readrevisionReturns stored config and effective_config for a revision id.
POST/api/agents/{agent_id}/revisions/{revision}/activateagents.manageactivateActivates a draft revision; idempotent when request_id is set; requires write trust and admin.
GET/api/audit/eventsagents.readaudit_eventsQueries agent audit events with filters and cursor pagination.
GET/api/audit/lineageagents.readaudit_lineageQueries governance lineage events and returns them under events.

The candidate router is mounted so /api/agents/candidates/... is not interpreted as /api/agents/{agent_id}.

Request and response models

Body models (JSON)

DraftRequest (POST .../drafts)

FieldTypeNotes
base_digeststringRequired.
base_revisionstring or nullOptional.
settingsobjectKeys map to string | bool | int | float | null; default empty.
harnessdict[str, str]Default empty.
toolsdict[str, bool]Default empty.
request_idstring or nullOptional; used for idempotent replay.

Extra properties are forbidden (extra="forbid").

AccessRequest (POST .../{agent_id}/access)

FieldTypeNotes
stoppedboolStrict boolean.
expected_versionintge=0, strict.
reasonstringDefault "", max_length=2000.
reviewedboolDefault false, strict.

AccessAllRequest (POST .../access/all)

FieldTypeNotes
stoppedboolStrict boolean.
reasonstringDefault "", max_length=2000.
reviewedboolDefault false, strict.

ActivationRequest (POST .../revisions/{revision}/activate)

FieldTypeNotes
expected_generationintge=1, strict.
restoreboolDefault false.
request_idstring or nullOptional; used for idempotent replay.

Query parameters

GET .../activity

ParameterTypeDefault
limitint5 (effective count uses max(1, min(limit, 20)))

GET /api/audit/events

ParameterType
actorstring or null
agent_idstring or null
actionstring or null
target_typestring or null
target_idstring or null
correlation_idstring or null
sincestring or null
untilstring or null
limitint or null (passed through bounded_limit)
cursorstring or null

GET /api/audit/lineage

ParameterType
columnstring or null
tablestring or null
subjectstring or null
actorstring or null
channelstring or null
sincestring or null
untilstring or null
limitint or null (passed through bounded_limit)

Representative response shapes

Handlers return JSON objects unless noted. Shapes inferred from return statements and delegations:

HandlerResponse
cache_status{ "diagnostics": ..., "storage": ... }
capabilitiesCapability board payload from capability_board.board.
check_capabilitiesResult of capability_board.check.
candidateCandidate detail from agent_candidates.detail.
promote_candidateResult of agent_candidates.promote.
set_all_accessset_all_access returns the list produced by agent_access.change_all.
set_accessSingle change record from agent_access.change.
agentsFleet directory from agent_fleet.directory.
agentMerged agent_control.detail, overview, and max_run_seconds.
activity{ "events": [...] }
save{ "revision_id", "agent_id", "activation": null } on success (201).
revision{ "config", "effective_config" }
activate{ "state": "active", "agent_id", "active_revision", "generation", "activated_by" }
audit_eventsResult of agent_audit.query.
audit_lineage{ "events": events }

Behaviour and errors

Unknown agents. _known(agent_id) raises not_found("Agent is not registered") when agent_id is not in MANAGED_IDS. Used by agent detail, activity, drafts, revisions, activate, and per-agent access.

Candidates. candidate and promote_candidate translate LookupError to not_found with the lookup message.

Access changes. If stopped is false and reviewed is false, both access endpoints raise invalid("Review active actions before enabling agent access"). Per-agent access maps agent_access.AccessConflict to stale and ValueError to invalid.

Drafts and activation. save maps agent_control.AgentConflict to stale and ValueError to invalid. activate maps AgentConflict to stale, UnknownRevision to not_found, and ValueError to invalid. On successful activation the handler returns generation as expected_generation + 1.

Revisions. Unknown revision rows raise not_found("Unknown revision").

Audit queries. ValueError from agent_audit.query or governance_audit.query_lineage is turned into invalid.

Capability probe helper. _run_read_tool raises ProbeRefused when the tool handler is missing or when invoke_capability raises an HTTP error with status below 500; 5xx errors become RuntimeError.

Idempotency. save and activate wrap their mutations in idempotent with kinds agent.draft and agent.activate respectively.

Status codes. save is registered with status_code=201. Other routes use default success codes unless helpers map errors to specific HTTP statuses (for example not_found, invalid, stale from agent_http).

How the permission model applies

Each route’s handler is keyed in ROUTE_PERMISSIONS as agent_routes.<handler_name>. The console gate dependency refuses signed-in users whose role does not hold that permission (403 with a denied error). The table above lists those permission strings.

That mapping is a ceiling: handlers may require additional checks. Examples in this module:

  • require_role() or require_role(DRAFT_ROLES) for read and draft saves.
  • require_admin() or require_admin("agents.manage") for admin-only mutations and diagnostics.
  • require_console_write_trust(request) runs on every POST in this module, including the capability check, which does not call writes.

When sign-in is off, route role documentation notes the caller is treated as the OS admin on the machine; bearer-authenticated machine calls carry their own grants. Every handler in this module has a declared route permission; none are missing from the registry.

How is this page?

Last updated on