profile_versions
Manage per-environment agent profile versions: list, view, save, restore, pin the served version, and diff changes to audit or roll back configuration.
Instructions
Per-(profile, environment) version history + served-version pin — the MCP surface for the agents screen's version bar (save / view / pin / restore), delegating to admin.services.profile_versions so the portal and MCP stay in lockstep (the eval-work lesson). Mixed read/write (list/view read; save/restore/pin mutate) — left unannotated rather than READ_ONLY, same reasoning as prompts/models/tools.
action:
list — version history for profile_id in env, newest first:
[{version_id, version_number, promoted_at, notes, is_served}].
view (version_id) — that version's resolved config snapshot.
version_id must belong to profile_id (same ownership guard
restore/pin use) — errors otherwise.
save (notes optional) — snapshot the profile's CURRENT live/draft
config into a brand-new version via the same
runtime.compiler.compile_profile_snapshot promote uses; does NOT
change what's served. Returns {version_id, version_number}.
restore (version_id) — copy that version's config back onto the live
draft row (identity fields agent_kind/slug/display_name/
description untouched), filtering out any tool/data-source/
MCP-server/model/prompt-version reference that no longer exists in
this env (reported in `dropped`); never changes served_version_id
— save afterwards to turn "editing a copy of vN" into a new
version. Returns {restored, dropped}.
pin (version_id, or "" to clear) — set/clear
agent_profiles.served_version_id, the exact
agent_profile_versions snapshot AgentProfileLoader serves for this
profile+env (clearing reverts to default resolution). Returns
{served_version_id}.
diff (version_id → that version vs the LIVE/draft row; or
ids=[version_a, version_b] → two saved versions) — the portal's
version-diff view: {changes: ["model_main_id: 'x' -> 'y'",
"tools: +a, -b", ...]}; include_detail=true adds the full
structured diff. Read-only.
All writes run inside use_env(env) so reused portal service code
resolves the right env branch, and are audited by
admin.services.profile_versions itself (its own record_change calls —
no separate MCP-level audit, so a save/restore/pin produces exactly
one audit_log row, not two). ValueError from the service layer
(profile/version not found, or a version_id that belongs to a
different profile) surfaces as the standard err() payload via
@tool_errors.Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>",
"profile_id": "<profile_id>"
},
"name": "profile_versions"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| env | No | Config branch: which `environment` rows of the AI config DB to read/write. staging = the editable working set (default); prod = what production serves. | staging |
| ids | No | diff: [version_a, version_b] to diff two saved versions (instead of version_id vs the live row). | |
| notes | No | save: notes stored with the version. | |
| action | Yes | Operation to run: list | view | save | restore | pin | diff. The tool description lists what each action needs. | |
| profile_id | Yes | Agent profile UUID (list_profiles / get_profile). | |
| version_id | No | agent_profile_versions UUID. | |
| include_detail | No | diff: also return the full structured diff (default: summary lines only). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |