Repository navigation
feat(agent): measure each local model on its first run and warn when unproven - #565
Merged
Merged
Conversation
…unproven Nothing in the product called the capability probe, so every Agent run used the prompt-only plain_json format, which none of the local models tried in a live test could follow. The launched app now probes a local model that has no saved profile on the worker, before its first run, and caches the result. A run uses the wire format the model was measured on whenever it managed a basic tool call there; a model that failed a check still runs, and the run panel warns, naming the failed checks in plain language. Approvals still gate every action. Cloud models are never probed, an unreadable profile store is neither trusted nor overwritten, a probe in which every check failed is not cached, and Stop is honoured between checks. Test apps keep profiling off unless they ask for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nothing in the product called the capability probe (
agent/model_profiles.probe_model), and nothing wrote the profile store. So every Agent run, for every model, used the weakest wire format,plain_json(prompt-only JSON, with no native tool calls or constrained decoding).In a live test, none of the local models tried could follow it. qwen3:8b and granite4.1:8b failed with
invalid_model_repliesafter inventing envelope fields. With a measurednative_toolsprofile, the same granite model made valid tool calls and fixed the bug.Decision (maintainer)
Measure a model on first use and cache the result. Run on the format it was measured on, even when it is not recommended, and show a visible warning. Approvals still gate every action.
Change
Backend (
services/agent_runs.py,agent/model_profiles.py)AgentRuns(profile_models=...)switch. It is off by default (tests and embedded apps), andapp_factory.build_appturns it on through a newcreate_app(agent_profile_models=...)argument.pendingand emitsstatus {status: "pending", phase: "model_check"}. The probe usesDEFAULT_PROBE_CONTEXT_SIZE, so budgets andnum_ctxmatch the defaults the loop was built with, and only the wire format changes.single_callon it. Otherwise it keepsplain_json. Recommendation now only decides the warning.runningstatus event carriesmodel_check: {recommended, failed_checks}for both cached and newly measured profiles.ProfileStore.upsert, which replaces only that model's record. Guards:probe_model(should_stop=...), which raisesProbeStopped. Nothing is saved.Frontend
useAgentRunexposescheckingModelandmodelCheck. A model is never shown as recommended when a failed check is listed.Tests
test_agent_runs_wiring.py:native_tools;test_agent_model_profiles.py:should_stopbefore and between checks,upsertreplaces only one model,upsertnever overwrites an unreadable store.test_app_paths.py: the launched app turns profiling on, and a plainAgentRuns()keeps it off.useAgentRun: the checking state, then the result, with malformed results ignored and failures never shown as recommended;AgentPage: the probe heading, then the warning, and no warning for a recommended model;modelCheck: the warning text.vitest src/features/agent(112 passed). ruff is clean, and mypy is clean over 145 files.Risk and rollback
The first run with each local model takes longer, while seven short synthetic exchanges run, and the UI says so. Probe content is synthetic, and only check outcomes are stored, never transcripts. Rollback is reverting this commit. Saved profiles then go back to being used only when recommended.
Limits
🤖 Generated with Claude Code