The platform for continuously improving AI agents.
Support model handoffs without a capability (#278)
Tyler-Edwardsb666a6b14ac4
diff --git a/frontend/src/openapi/models/ModelSwapPrompt.ts b/frontend/src/openapi/models/ModelSwapPrompt.tsindex 65cd137a..74f09e2b 100644--- a/frontend/src/openapi/models/ModelSwapPrompt.ts+++ b/frontend/src/openapi/models/ModelSwapPrompt.ts@@ -36,7 +36,7 @@ export interface ModelSwapPrompt {* @type {string}* @memberof ModelSwapPrompt*/- capabilityId: string;+ capabilityId: string | null;/**** @type {string}diff --git a/overbae/api/serializers.py b/overbae/api/serializers.pyindex 0defd35c..e3ec5f5f 100644--- a/overbae/api/serializers.py+++ b/overbae/api/serializers.py@@ -1074,7 +1074,7 @@ class ModelSwapPromptRequestSerializer(serializers.Serializer):default=False,help_text=("Write this one deployment's concrete model id into the code instead of the "- "capability's permanent alias."+ "capability's permanent alias. A run without a capability is always pinned."),)@@ -1082,8 +1082,8 @@ class ModelSwapPromptRequestSerializer(serializers.Serializer):class ModelSwapPromptSerializer(serializers.Serializer):prompt = serializers.CharField()pin = serializers.BooleanField()- capability_id = serializers.UUIDField()- capability_name = serializers.CharField()+ capability_id = serializers.UUIDField(allow_null=True)+ capability_name = serializers.CharField(allow_blank=True)old_model = serializers.CharField()new_model = serializers.CharField()diff --git a/overbae/api/views.py b/overbae/api/views.pyindex 38a4d89a..1eef7894 100644--- a/overbae/api/views.py+++ b/overbae/api/views.py@@ -1011,7 +1011,8 @@ class FinetuningJobViewSet(viewsets.ModelViewSet):OpenApiParameter.QUERY,required=False,description=(- "Write this deployment's concrete model id instead of the capability alias."+ "Write this deployment's concrete model id instead of the capability alias. "+ "A run without a capability is always pinned."),),],diff --git a/overbae/services/mcp/__init__.py b/overbae/services/mcp/__init__.pyindex 0af3a35f..219cf150 100644--- a/overbae/services/mcp/__init__.py+++ b/overbae/services/mcp/__init__.py@@ -1,3 +1,3 @@"""MCP protocol and catalog services."""-CONTRACT_VERSION = "7.20.0"+CONTRACT_VERSION = "7.21.0"diff --git a/overbae/services/mcp/contracts/inference.py b/overbae/services/mcp/contracts/inference.pyindex eb2e0646..b72ce88b 100644--- a/overbae/services/mcp/contracts/inference.py+++ b/overbae/services/mcp/contracts/inference.py@@ -47,8 +47,10 @@ class RunInferenceOutput(MCPModel):class GetModelSwapPromptInput(MCPModel):finetune: str = Field(min_length=1, max_length=255)- # False points the code at the capability alias, so later swaps need no code change.- pin: bool = False+ pin: bool = Field(+ default=False,+ description="False uses the capability alias when one exists.",+ )class GetModelSwapPromptOutput(MCPModel):@@ -56,7 +58,7 @@ class GetModelSwapPromptOutput(MCPModel):finetune: strpin: boolprompt: str = Field(min_length=1, max_length=16_000)- capability_id: str+ capability_id: str | Nonecapability_name: str = Field(max_length=255)old_model: str = Field(max_length=255)new_model: str = Field(max_length=255)diff --git a/overbae/services/mcp/tools_finetuning.py b/overbae/services/mcp/tools_finetuning.pyindex a6a4fc8a..3c90823a 100644--- a/overbae/services/mcp/tools_finetuning.py+++ b/overbae/services/mcp/tools_finetuning.py@@ -986,12 +986,15 @@ def _model_swap_prompt_sync(raise MCPError("model_swap_prompt_not_ready", error or "The swap prompt is unavailable.")links = [resource_link("finetunes", str(job.id), job.name or "Fine-tuning job"),- resource_link("capabilities", result["capability_id"], result["capability_name"]),]+ if result["capability_id"]:+ links.append(+ resource_link("capabilities", result["capability_id"], result["capability_name"])+ )return GetModelSwapPromptOutput(summary=f"Swap prompt ready: {result['old_model']} to {result['new_model']}.",finetune=str(job.id),- pin=payload.pin,+ pin=result["pin"],prompt=result["prompt"],capability_id=result["capability_id"],capability_name=result["capability_name"],diff --git a/overbae/services/model_swap_prompt.py b/overbae/services/model_swap_prompt.pyindex b6cb2857..18a12964 100644--- a/overbae/services/model_swap_prompt.py+++ b/overbae/services/model_swap_prompt.py@@ -48,30 +48,26 @@ def current_capability_model(job: FinetuningJob, capability: Capability | None =return observed_capability_model(capability) or capability.model or job.base_model-def resolve_swap_capability(job: FinetuningJob) -> tuple[Capability | None, str | None]:- """The capability whose code this prompt retargets — ``(capability, error)``."""+def resolve_swap_capability(job: FinetuningJob) -> Capability | None:+ """The run's capability, else the project's only one."""if job.capability_id:- return job.capability, None+ return job.capabilitycandidates = list(Capability.objects.filter(project_id=job.project_id).current()[:2])- if len(candidates) == 1:- return candidates[0], None- if not candidates:- return None, "This training run is not linked to a capability and its project has none."- return None, "This training run is not linked to a capability and its project has several."+ return candidates[0] if len(candidates) == 1 else None-def alias_target_deployment(- job: FinetuningJob, capability: Capability+def target_deployment(+ job: FinetuningJob, capability: Capability | None) -> tuple[DeployedModel | None, str | None]:- """The deployment the alias will answer with — ``(deployed, error)``."""deployed = _job_deployed_model(job)if deployed is None:return None, "This training run has no deployed model."if deployed.status != DeployedModel.Status.READY:return None, f"{deployed.model_id} is not ready to serve (status: {deployed.status})."- if str(deployed.project_id) != str(capability.project_id):- return None, "The deployed model belongs to a different project than the capability."+ project_id = capability.project_id if capability else job.project_id+ if str(deployed.project_id) != str(project_id):+ return None, "The deployed model belongs to a different project."if deployed.inference_contract != "chat":return None, "Decision models use typed inference, not an OpenAI chat model swap."return deployed, None@@ -111,34 +107,50 @@ def build_model_swap_prompt(f'welcome; anything that reads as "update me later" is wrong.\n')else:+ target = f"AI agent '{capability_name}'" if capability_name else "application's LLM calls"headline = (- f"You are pinning the AI agent '{capability_name}' in this repository to one exact "+ f"You are pinning the {target} in this repository to one exact "f"fine-tuned model served by Overmind's OpenAI-compatible inference API.")identifier_note = (f'Exact model identifier to pin: "{new_model}"\n'f"This names one specific deployment. It is a deliberate hard pin, so it will "- f"need a new change whenever the capability should run a different model.\n"+ f"need a new change to use a different model.\n")stability_rules = ("6. This is an intentional pin to one exact model, so a comment naming the ""model or the training run is appropriate here.\n")+ find_step = (+ "1. Find where this capability configures its LLM client and model (model name "+ "string, config value, or env-var default).\n"+ if capability_name+ else "1. Find the LLM call this model replaces (model name string, config value, or "+ "env-var default). If several call sites configure a model and the user has not "+ "named one, stop and ask which call to change.\n"+ )+ call_target = "the capability's LLM calls" if capability_name else "that LLM call"+ model_hint_label = (+ "Model identifier currently in the code" if capability_name else "Training base model hint"+ )+ model_origin = (+ "derived from this capability's observed traffic and may be stale or missing"+ if capability_name+ else "the training run's base model and may differ from the application's current model"+ )return (f"{headline}\n\n"- f"Capability source location hint: {source_path or '(unknown — search the repo)'}\n"- f'Model identifier currently in the code: "{old_model}"\n'+ f"Source location hint: {source_path or '(unknown — search the repo)'}\n"+ f'{model_hint_label}: "{old_model}"\n'f"{identifier_note}"f"Overmind inference base URL: {base_url}\n"f"Overmind API key env var: {OVERMIND_API_KEY_ENV} (an 'ovr_...' key, sent as "f"'Authorization: Bearer')\n\n"- "Task — make the capability's LLM calls run through Overmind:\n"- f"1. Find where this capability configures its LLM client and model (model name "- f"string, config value, or env-var default).\n"- f'2. Set the model parameter of the capability\'s LLM calls to "{new_model}".\n'- f'3. The "currently in the code" identifier above is derived from this capability\'s '- f"observed traffic and may be stale or missing. Whatever model string you "+ "Task — make these LLM calls run through Overmind:\n"+ f"{find_step}"+ f'2. Set the model parameter of {call_target} to "{new_model}".\n'+ f"3. The model identifier above is {model_origin}. Whatever model string you "f"actually find at that call site is the one to replace — do not stop because "f'"{old_model}" is not present verbatim.\n'f"4. Point the OpenAI(-compatible) client at Overmind: in Python, "@@ -178,11 +190,11 @@ def model_swap_prompt_for_job(if job.status != job.Status.SUCCEEDED:return None, "Only successfully trained models can be shipped to the codebase."- capability, capability_error = resolve_swap_capability(job)- if capability is None:- return None, capability_error+ capability = resolve_swap_capability(job)+ # Only a capability has an alias; without one the prompt pins the deployment.+ pin = pin or capability is None- deployed, deployed_error = alias_target_deployment(job, capability)+ deployed, deployed_error = target_deployment(job, capability)if deployed is None:return None, deployed_error@@ -191,8 +203,8 @@ def model_swap_prompt_for_job(old_model = current_capability_model(job, capability)prompt = build_model_swap_prompt(base_url=base_url,- capability_name=capability.name,- source_path=capability.source_path or "",+ capability_name=capability.name if capability else "",+ source_path=(capability.source_path or "") if capability else "",old_model=old_model,new_model=new_model,is_alias=not pin,@@ -200,8 +212,8 @@ def model_swap_prompt_for_job(return {"prompt": prompt,"pin": pin,- "capability_id": str(capability.id),- "capability_name": capability.name,+ "capability_id": str(capability.id) if capability else None,+ "capability_name": capability.name if capability else "","old_model": old_model,"new_model": new_model,}, Nonediff --git a/overmind/.claude-plugin/plugin.json b/overmind/.claude-plugin/plugin.jsonindex 14065605..92cf7821 100644--- a/overmind/.claude-plugin/plugin.json+++ b/overmind/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "overmind",- "version": "1.2.7",+ "version": "1.2.8","description": "Overmind skills — agent observability, tracing, and platform workflows for coding agents.","author": {"name": "Overmind",diff --git a/overmind/.codex-plugin/plugin.json b/overmind/.codex-plugin/plugin.jsonindex 858e071f..f49af796 100644--- a/overmind/.codex-plugin/plugin.json+++ b/overmind/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "overmind",- "version": "1.2.7",+ "version": "1.2.8","description": "Investigate agent failures, prepare datasets, evaluate models, and manage training and serving with Overmind.","author": {"name": "Overmind",diff --git a/overmind/.cursor-plugin/plugin.json b/overmind/.cursor-plugin/plugin.jsonindex 4d099fb3..cc3cf140 100644--- a/overmind/.cursor-plugin/plugin.json+++ b/overmind/.cursor-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "overmind","displayName": "Overmind",- "version": "1.2.7",+ "version": "1.2.8","description": "Overmind skills and MCP — agent observability, tracing, and platform tools for coding agents.","author": {"name": "Overmind",diff --git a/overmind/overmind/__init__.py b/overmind/overmind/__init__.pyindex f696ad91..46c5f159 100644--- a/overmind/overmind/__init__.py+++ b/overmind/overmind/__init__.py@@ -10,7 +10,7 @@ from __future__ import annotationsfrom typing import TYPE_CHECKING, Any-__version__ = "0.1.111"+__version__ = "0.1.113"from .client import Client, ModelDeleted, OvermindInferenceErrordiff --git a/overmind/overmind/skills_db.py b/overmind/overmind/skills_db.pyindex 6b3da34d..f312e476 100644--- a/overmind/overmind/skills_db.py+++ b/overmind/overmind/skills_db.py@@ -1,7 +1,7 @@from dataclasses import dataclass# Every plugin manifest (.claude-plugin, .codex-plugin, .cursor-plugin) carries this version.-SKILLS_VERSION = "1.2.7"+SKILLS_VERSION = "1.2.8"@dataclassdiff --git a/overmind/pyproject.toml b/overmind/pyproject.tomlindex 6e6a9c68..742a4314 100644--- a/overmind/pyproject.toml+++ b/overmind/pyproject.toml@@ -46,7 +46,7 @@ license = { text = "MIT" }name = "overmind"readme = "README.md"requires-python = ">=3.10,<4" # todo; remove the upper bound-version = "0.1.112"+version = "0.1.113"[project.urls]"Agent setup" = "https://console.overmindlab.ai/setup.md"diff --git a/overmind/skills/overmind-inference/SKILL.md b/overmind/skills/overmind-inference/SKILL.mdindex 12fbc1ce..c13aebe8 100644--- a/overmind/skills/overmind-inference/SKILL.md+++ b/overmind/skills/overmind-inference/SKILL.md@@ -115,7 +115,9 @@ For a repository rollout, `get_model_swap_prompt` accepts a successful fine-tunean optional `pin` and returns a copy-paste `prompt` plus `capability_id`,`old_model` and `new_model`; it is a local handoff and MCP does not edit therepository. Omit `pin` to point the code at the capability alias, so later swaps need-no further code change. Apply code changes only within the requested scope and+no further code change. Use `pin: true` for an exact deployment. A model without a+capability is always pinned: the result returns `pin: true` and a null `capability_id`.+Apply code changes only within the requested scope andverify final capability and deployment state. After `set_active_model`, verify thefinal state from the deployment and capability resources. A failed activationpreserves the current model and can be retried with the same selection. Successful application API-key calls establish connectiondiff --git a/overmind/uv.lock b/overmind/uv.lockindex 02628336..3c0b8977 100644--- a/overmind/uv.lock+++ b/overmind/uv.lock@@ -923,7 +923,7 @@ wheels = [[[package]]name = "overmind"-version = "0.1.111"+version = "0.1.113"source = { editable = "." }dependencies = [{ name = "packaging" },diff --git a/tests/journeys/console/test_model_handoff.py b/tests/journeys/console/test_model_handoff.pynew file mode 100644index 00000000..c3abe9ab--- /dev/null+++ b/tests/journeys/console/test_model_handoff.py@@ -0,0 +1,42 @@+import uuid++from overbae.models import Dataset, DeployedModel, FinetuningJob+++def test_standalone_trained_model_copies_its_setup_prompt(console, rest_for, account_key, mcp_for):+ project = rest_for(account_key).request(+ "POST", "/api/projects/", json={"name": "Standalone model", "slug": "standalone-model"}+ )["id"]+ group = uuid.uuid4()+ job = FinetuningJob.objects.create(+ project_id=project,+ dataset=Dataset.objects.create(project_id=project, name="Standalone training data"),+ base_model="Qwen/Qwen2.5-14B-Instruct",+ status="succeeded",+ group_id=group,+ output_model_name="ft-standalone-browser",+ )+ model = DeployedModel.objects.create(+ project_id=project,+ finetuning_job=job,+ model_id="ft-standalone-browser",+ status="ready",+ max_model_len=8192,+ )+ console._browser.call(+ console._page.context.grant_permissions, ["clipboard-read", "clipboard-write"]+ )+ console._browser.call(console._page.evaluate, "navigator.clipboard.writeText('')")+ console.goto(f"/training?projectId={project}&groupId={group}&jobId={job.id}")+ console.press("Copy a prompt switching to ft-standalone-browser")+ console.sees("Prompt copied")+ console.save_evidence("standalone-model-setup-prompt")+ prompt = console._browser.call(console._page.evaluate, "navigator.clipboard.readText()")+ assert model.model_id in prompt+ result = mcp_for(account_key).call(+ "get_model_swap_prompt", {"project_id": project, "finetune": str(job.id)}+ )+ assert model.model_id in result["prompt"]+ assert result["pin"] is True+ assert result["capability_id"] is None+ assert len(result["resource_links"]) == 1diff --git a/tests/test_model_swap_prompt.py b/tests/test_model_swap_prompt.pyindex 0c7108df..694665b0 100644--- a/tests/test_model_swap_prompt.py+++ b/tests/test_model_swap_prompt.py@@ -102,6 +102,7 @@ def test_model_swap_prompt_pin_writes_concrete_id():assert payload["new_model"] == "ft-abc12345-qwen2-5-14b"assert payload["pin"] is Trueassert "overmind/" not in payload["prompt"]+ assert 'to "ft-abc12345-qwen2-5-14b"' in payload["prompt"]resp = _get(auth_client(user), job, pin=True)assert resp.status_code == 200@@ -157,15 +158,20 @@ def test_model_swap_prompt_pin_rejects_job_with_no_deployment():assert "no deployed model" in resp.json()["detail"]-def test_model_swap_prompt_rejects_ambiguous_unassigned_job():+def test_model_swap_prompt_pins_the_deployment_without_a_capability():project, user, dataset, _ = _setup()Capability.objects.create(project=project, name="second-bot", slug="second-bot")job = _make_job(project, dataset, capability=None)- _deploy(project, job)+ deployed = _deploy(project, job)resp = _get(auth_client(user), job)- assert resp.status_code == 400- assert "several" in resp.json()["detail"]+ assert resp.status_code == 200+ body = resp.json()+ assert body["pin"] is True+ assert body["capability_id"] is None+ assert body["new_model"] == deployed.model_id+ assert "overmind/" not in body["prompt"]+ assert f'to "{deployed.model_id}"' in body["prompt"]def test_model_swap_prompt_falls_back_to_sole_capability():