:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(autoresearch): choose the research model and effort per pipeline (#119930)
posthog[bot]c310a8704510
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 8dedcef554c1..17a79f41a58e 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6683,9 +6683,9 @@ snapshots:products-autoresearch-model-detail-scene--accuracy-hit-rate-with-challengers--wide--light:hash: v1.k794b7964.9ba1c3edd96fb8572bf98877a23b1ae71c1cabb39c4dd900935751ea9a62a243.vJA1Rx5am3ih3Wu-xMWyJZzd1UMZabJm810pFmVhEggproducts-autoresearch-model-detail-scene--agent-research-narrow--narrow--dark:- hash: v1.k794b7964.0889baa7d2b6bca50dfd14487b80f287e8bd27a098a0e3482cb9da086c840e3e.5vUCdyEAF1AXUusb51kIrj4Jbpwm8BYmrR6O3ATOz34+ hash: v1.k794b7964.319b9dd29cac56eb66e190f20b88f3a57359bad17c962653ceabb3918a6bbc7d.jFqN3oOKIHZdDV3Euq5eDbbvjhsw-7Z7Xjp3Jl6qgGUproducts-autoresearch-model-detail-scene--agent-research-narrow--narrow--light:- hash: v1.k794b7964.c886c90f5857ec3832569882f07dd6d977bbb853acfd91a22c7ce115c07244af.VI_y6lzckFWdnDBbwApi8V4A5qqDqFp5F8lVoJRivhg+ hash: v1.k794b7964.aa13438073b341f11ff0fe2f43185efcb9ae3b85ed23baf46d6754c7692c86c4.inH4okysFK8BNlmD5HK2jX9LnOnsvkXhzYCK5DLHZwQproducts-autoresearch-model-detail-scene--agent-research-wide--wide--dark:hash: v1.k794b7964.d0ca993aa9965e415a9ceab3a9627ab8e17c2cea945674f2eb918bec777bb8d5.4YLF7WUT-SVytW6rcFDb1zd2Ws8Q1W-AYt1gzvxk5_0products-autoresearch-model-detail-scene--agent-research-wide--wide--light:diff --git a/products/autoresearch/AGENTS.md b/products/autoresearch/AGENTS.mdindex 107ca8a5f091..43154d9b89e2 100644--- a/products/autoresearch/AGENTS.md+++ b/products/autoresearch/AGENTS.md@@ -44,6 +44,7 @@ The real-agent training path additionally needs Tasks access, because it runs inTraining never ends, but exploration comes first.The daily sweep starts research runs on scoring days until a run fails to promote a better model or 5 research runs have run, then one run every `research_interval_days` after the latest run (`backend/training/schedule.py`).Each run takes `iterations_per_run` iterations, and records why it started in `kickoff_reason`.+Each run also records the runtime adapter, model and reasoning effort it was dispatched with (see `backend/training/AGENTS.md`).`iteration_budget` and `iteration_budget_remaining` are deprecated: nothing scheduled reads them.## Invariants that cross package boundariesdiff --git a/products/autoresearch/backend/facade/api.py b/products/autoresearch/backend/facade/api.pyindex c99b259cb74b..7783924ba958 100644--- a/products/autoresearch/backend/facade/api.py+++ b/products/autoresearch/backend/facade/api.py@@ -31,6 +31,7 @@ from posthog.models.user import Userfrom posthog.storage.object_storage import ObjectStorageErrorfrom products.actions.backend.models.action import Action+from products.tasks.backend.facade.model_catalogue import REASONING_EFFORT_DISPLAY_NAMES, display_name_for_modelfrom ..dataset import templates as templates_modulefrom ..dataset.labeling import (@@ -65,6 +66,13 @@ from ..models import ()from ..query import measure_queriesfrom ..training import artifacts as artifact_store+from ..training.agent_model import (+ AUTORESEARCH_DEFAULT_MODEL,+ AgentModelError,+ agent_model_choices,+ resolve_agent_run_config,+ validate_agent_settings,+)from ..training.explanation import (MAX_TOP_FEATURES as _MAX_TOP_FEATURES,FeatureDirection as _FeatureDirection,@@ -74,6 +82,9 @@ from ..training.recipe_validation import RecipeValidationError, feature_sql_hintfrom ..training.schedule import ScheduleRun, research_schedule, schedule_runs_forfrom ..training.shadow_set import shadow_set_idsfrom .contracts import (+ AgentModelOption,+ AgentModelOptions,+ AgentReasoningEffortOption,ArtifactContent,ArtifactDeleteResult,ArtifactList,@@ -379,6 +390,7 @@ def _pipeline_to_contract(pipeline_created_at=row.created_at,runs=activity.schedule_runs,)+ agent_config = resolve_agent_run_config(row.agent_model, row.agent_reasoning_effort)return Pipeline(id=row.id,name=row.name,@@ -398,6 +410,10 @@ def _pipeline_to_contract(iteration_budget_remaining=row.iteration_budget_remaining or 0,iterations_per_run=row.iterations_per_run,research_interval_days=row.research_interval_days,+ agent_model=row.agent_model,+ agent_reasoning_effort=row.agent_reasoning_effort,+ effective_agent_model=agent_config.model,+ effective_agent_reasoning_effort=agent_config.reasoning_effort,training_phase=schedule.phase,next_research_at=schedule.next_research_at,success_auc=row.success_auc,@@ -480,6 +496,10 @@ def _training_run_to_contract(row: AutoresearchTrainingRun) -> TrainingRun:task_url=f"/tasks/{row.task_id}" if row.task_id else None,status=row.status,kickoff_reason=row.kickoff_reason,+ agent_runtime_adapter=row.agent_runtime_adapter,+ agent_model=row.agent_model,+ agent_model_label=display_name_for_model(row.agent_model) if row.agent_model else None,+ agent_reasoning_effort=row.agent_reasoning_effort,iteration_budget=row.iteration_budget,iteration_count=row.iteration_count,best_holdout_score=row.best_holdout_score,@@ -919,6 +939,8 @@ def get_pipeline_definition(team_id: int, pipeline_id: str | UUID) -> PipelineWriteration_budget=row.iteration_budget,iterations_per_run=row.iterations_per_run,research_interval_days=row.research_interval_days,+ agent_model=row.agent_model,+ agent_reasoning_effort=row.agent_reasoning_effort,success_auc=row.success_auc,plateau_iterations=row.plateau_iterations,output_person_property=row.output_person_property,@@ -964,6 +986,41 @@ def resolve_action_target(project_id: int, action_id: Any) -> tuple[str, int]:return action.name or "", int(action_id)+# ── Training agent model ───────────────────────────────────────────────────+++def list_agent_model_options() -> AgentModelOptions:+ choices = agent_model_choices()+ default = resolve_agent_run_config(None, None)+ return AgentModelOptions(+ default_model=default.model,+ default_model_label=display_name_for_model(AUTORESEARCH_DEFAULT_MODEL),+ default_reasoning_effort=default.reasoning_effort,+ models=[+ AgentModelOption(+ model=choice.model,+ label=choice.label,+ runtime_adapter=choice.runtime_adapter,+ supported_efforts=[+ AgentReasoningEffortOption(value=effort, label=REASONING_EFFORT_DISPLAY_NAMES.get(effort, effort))+ for effort in choice.supported_efforts+ ],+ cost_multiplier=choice.cost_multiplier,+ )+ for choice in choices+ ],+ )+++def agent_settings_error(model: str | None, reasoning_effort: str | None) -> str | None:+ """Why this model and effort cannot be stored on a pipeline, or None when they can."""+ try:+ validate_agent_settings(model, reasoning_effort)+ except AgentModelError as exc:+ return str(exc)+ return None++# ── Validation and templates ───────────────────────────────────────────────diff --git a/products/autoresearch/backend/facade/contracts.py b/products/autoresearch/backend/facade/contracts.pyindex 3f8ff7a4b240..3d1752bba06d 100644--- a/products/autoresearch/backend/facade/contracts.py+++ b/products/autoresearch/backend/facade/contracts.py@@ -133,6 +133,10 @@ class Pipeline:iteration_budget_remaining: intiterations_per_run: intresearch_interval_days: int | None+ agent_model: str | None+ agent_reasoning_effort: str | None+ effective_agent_model: str+ effective_agent_reasoning_effort: str | Nonetraining_phase: strnext_research_at: datetime | Nonesuccess_auc: float | None@@ -236,6 +240,10 @@ class TrainingRun:task_url: str | Nonestatus: strkickoff_reason: str | None+ agent_runtime_adapter: str | None+ agent_model: str | None+ agent_model_label: str | None+ agent_reasoning_effort: str | Noneiteration_budget: intiteration_count: intbest_holdout_score: float | None@@ -307,6 +315,31 @@ class Run:created_at: datetime+@dataclass(frozen=True)+class AgentReasoningEffortOption:+ value: str+ label: str+++@dataclass(frozen=True)+class AgentModelOption:+ model: str+ label: str+ runtime_adapter: str+ supported_efforts: list[AgentReasoningEffortOption]+ cost_multiplier: str | None+++@dataclass(frozen=True)+class AgentModelOptions:+ """The models a pipeline's training agent may run on, and what a blank setting resolves to."""++ default_model: str+ default_model_label: str+ default_reasoning_effort: str | None+ models: list[AgentModelOption]++# ── Write contracts ────────────────────────────────────────────────────────@@ -331,6 +364,8 @@ class PipelineWrite:iteration_budget: int = 50iterations_per_run: int = 5research_interval_days: int | None = 7+ agent_model: str | None = None+ agent_reasoning_effort: str | None = Nonesuccess_auc: float | None = Noneplateau_iterations: int = 10output_person_property: str = ""diff --git a/products/autoresearch/backend/migrations/0008_agent_model.py b/products/autoresearch/backend/migrations/0008_agent_model.pynew file mode 100644index 000000000000..e47cb6263bc6--- /dev/null+++ b/products/autoresearch/backend/migrations/0008_agent_model.py@@ -0,0 +1,47 @@+# Generated by Django 5.2.18 on 2026-10-19 22:30++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("autoresearch", "0007_research_schedule"),+ ]++ operations = [+ migrations.AddField(+ model_name="autoresearchpipeline",+ name="agent_model",+ field=models.CharField(+ blank=True,+ help_text="Tasks model id the training agent runs on. Null uses the autoresearch default",+ max_length=100,+ null=True,+ ),+ ),+ migrations.AddField(+ model_name="autoresearchpipeline",+ name="agent_reasoning_effort",+ field=models.CharField(+ blank=True,+ help_text="Reasoning effort for the training agent. Null uses the autoresearch default",+ max_length=20,+ null=True,+ ),+ ),+ migrations.AddField(+ model_name="autoresearchtrainingrun",+ name="agent_model",+ field=models.CharField(blank=True, max_length=100, null=True),+ ),+ migrations.AddField(+ model_name="autoresearchtrainingrun",+ name="agent_reasoning_effort",+ field=models.CharField(blank=True, max_length=20, null=True),+ ),+ migrations.AddField(+ model_name="autoresearchtrainingrun",+ name="agent_runtime_adapter",+ field=models.CharField(blank=True, max_length=20, null=True),+ ),+ ]diff --git a/products/autoresearch/backend/migrations/max_migration.txt b/products/autoresearch/backend/migrations/max_migration.txtindex fdbf38252c7c..96685437ac0c 100644--- a/products/autoresearch/backend/migrations/max_migration.txt+++ b/products/autoresearch/backend/migrations/max_migration.txt@@ -1 +1 @@-0007_research_schedule+0008_agent_modeldiff --git a/products/autoresearch/backend/models.py b/products/autoresearch/backend/models.pyindex 7e5a1ac1ecab..877548fb1ee6 100644--- a/products/autoresearch/backend/models.py+++ b/products/autoresearch/backend/models.py@@ -122,6 +122,20 @@ class AutoresearchPipeline(TeamScopedRootMixin, UUIDModel):choices=ResearchIntervalDays.choices,help_text="Days between scheduled research runs once the first burst of daily runs ends",)+ # Null means the autoresearch default (training/agent_model.py), so the default can change+ # without rewriting stored rows.+ agent_model = models.CharField(+ max_length=100,+ null=True,+ blank=True,+ help_text="Tasks model id the training agent runs on. Null uses the autoresearch default",+ )+ agent_reasoning_effort = models.CharField(+ max_length=20,+ null=True,+ blank=True,+ help_text="Reasoning effort for the training agent. Null uses the autoresearch default",+ )# Stop criteriasuccess_auc = models.FloatField(@@ -347,6 +361,10 @@ class AutoresearchTrainingRun(PipelineScopedModel):status = models.CharField(max_length=20, choices=Status.choices, default=Status.PENDING)# Null on runs started before the field existed.kickoff_reason = models.CharField(max_length=20, choices=KickoffReason.choices, null=True, blank=True)+ # What the run was dispatched with. Null on older runs and on runs with no task (stubs, external agents).+ agent_runtime_adapter = models.CharField(max_length=20, null=True, blank=True)+ agent_model = models.CharField(max_length=100, null=True, blank=True)+ agent_reasoning_effort = models.CharField(max_length=20, null=True, blank=True)iteration_budget = models.IntegerField(default=50, validators=[MinValueValidator(1)])iteration_count = models.IntegerField(default=0, validators=[MinValueValidator(0)])best_holdout_score = models.FloatField(null=True, blank=True, validators=UNIT_INTERVAL_VALIDATORS)diff --git a/products/autoresearch/backend/presentation/views/serializers.py b/products/autoresearch/backend/presentation/views/serializers.pyindex 377bf1e2340b..79904ec90e3b 100644--- a/products/autoresearch/backend/presentation/views/serializers.py+++ b/products/autoresearch/backend/presentation/views/serializers.py@@ -15,6 +15,9 @@ from posthog.permissions import get_authenticator_scopesfrom products.autoresearch.backend.facade import apifrom products.autoresearch.backend.facade.contracts import (+ AgentModelOption,+ AgentModelOptions,+ AgentReasoningEffortOption,AutoresearchConflict,Iteration,IterationTrailEntry,@@ -687,6 +690,28 @@ class AutoresearchPipelineSerializer(DataclassSerializer):"start and from rescue runs for a model that cannot score. A shorter interval costs more."),)+ agent_model = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Model the training agent runs on, as set on this pipeline. Null uses the autoresearch default.",+ )+ agent_reasoning_effort = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Reasoning effort for the training agent, as set on this pipeline. Null uses the autoresearch default.",+ )+ effective_agent_model = serializers.CharField(+ read_only=True,+ help_text="Model the next training run uses: agent_model, or the autoresearch default when that is null.",+ )+ effective_agent_reasoning_effort = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text=(+ "Reasoning effort the next training run uses: agent_reasoning_effort, or the autoresearch default when "+ "that is null. Null when the model has no effort setting."+ ),+ )training_phase = serializers.ChoiceField(choices=TRAINING_PHASE_CHOICES,read_only=True,@@ -833,6 +858,10 @@ class AutoresearchPipelineSerializer(DataclassSerializer):"iteration_budget_remaining","iterations_per_run","research_interval_days",+ "agent_model",+ "agent_reasoning_effort",+ "effective_agent_model",+ "effective_agent_reasoning_effort","training_phase","next_research_at","success_auc",@@ -938,6 +967,26 @@ class AutoresearchPipelineCreateSerializer(DataclassSerializer):"start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7."),)+ agent_model = serializers.CharField(+ required=False,+ allow_null=True,+ max_length=100,+ help_text=(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as "+ "'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch "+ "default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ )+ agent_reasoning_effort = serializers.CharField(+ required=False,+ allow_null=True,+ max_length=20,+ help_text=(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model "+ "supports, and without agent_model it is checked against the default model. Null or omitted uses the "+ "autoresearch default, medium. Higher effort costs more per training run."+ ),+ )success_auc = serializers.FloatField(required=False,allow_null=True,@@ -987,6 +1036,8 @@ class AutoresearchPipelineCreateSerializer(DataclassSerializer):"iteration_budget","iterations_per_run","research_interval_days",+ "agent_model",+ "agent_reasoning_effort","success_auc","plateau_iterations","output_person_property",@@ -1064,6 +1115,20 @@ class AutoresearchPipelineCreateSerializer(DataclassSerializer):)return derived+ def _validate_agent_settings(self, team: Any, data: Any) -> None:+ if not (self._supplied(data, "agent_model") or self._supplied(data, "agent_reasoning_effort")):+ return+ # A partial update is checked as the pair it leaves stored.+ stored = api.get_pipeline_definition(team.pk, self._pipeline_id) if self._pipeline_id is not None else None+ model = self._value(data, "agent_model", stored.agent_model if stored else None)+ effort = self._value(data, "agent_reasoning_effort", stored.agent_reasoning_effort if stored else None)+ model_error = api.agent_settings_error(model, None)+ if model_error:+ raise serializers.ValidationError({"agent_model": model_error})+ effort_error = api.agent_settings_error(model, effort)+ if effort_error:+ raise serializers.ValidationError({"agent_reasoning_effort": effort_error})+def validate(self, data: Any) -> Any:# DataclassSerializer hands us the constructed dataclass, not a dict, and it is frozen —# so derived values are collected here and applied with one `replace`.@@ -1084,6 +1149,7 @@ class AutoresearchPipelineCreateSerializer(DataclassSerializer):updates["target_definition"] = target_definitionif is_update:self._validate_model_defining_fields_unchanged(team, replace(data, **updates) if updates else data)+ self._validate_agent_settings(team, data)output_person_property = self._value(data, "output_person_property")if not is_update and not output_person_property:output_person_property = self._derive_output_person_property(replace(data, **updates) if updates else data)@@ -1360,6 +1426,26 @@ class AutoresearchTrainingRunSerializer(DataclassSerializer):"rescue (the champion cannot score) or manual (a person or an agent asked). Null for older runs."),)+ agent_runtime_adapter = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Runtime that drove the training agent, 'claude' or 'codex'. Null for older runs and runs with no task.",+ )+ agent_model = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Model the training agent ran on. Null for older runs and runs with no task.",+ )+ agent_model_label = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Display name of agent_model, e.g. 'Claude Opus 5.5'. Null when agent_model is null.",+ )+ agent_reasoning_effort = serializers.CharField(+ read_only=True,+ allow_null=True,+ help_text="Reasoning effort the training agent ran at. Null for older runs, runs with no task, and models with no effort setting.",+ )iteration_budget = serializers.IntegerField(min_value=-2147483648,max_value=2147483647,@@ -1418,6 +1504,10 @@ class AutoresearchTrainingRunSerializer(DataclassSerializer):"task_url","status","kickoff_reason",+ "agent_runtime_adapter",+ "agent_model",+ "agent_model_label",+ "agent_reasoning_effort","iteration_budget","iteration_count","best_holdout_score",@@ -2314,6 +2404,48 @@ class CreateSuggestionSerializer(serializers.Serializer):)+# ── Training agent model serializers ──────────────────────────────────────────+++class AgentReasoningEffortOptionSerializer(DataclassSerializer):+ value = serializers.CharField(help_text="Effort id to pass as agent_reasoning_effort, e.g. 'medium'.")+ label = serializers.CharField(help_text="Display name, e.g. 'Medium'.") # type: ignore[assignment]++ class Meta:+ dataclass = AgentReasoningEffortOption+ fields = ["value", "label"]+++class AgentModelOptionSerializer(DataclassSerializer):+ model = serializers.CharField(help_text="Model id to pass as agent_model, e.g. 'claude-sonnet-5-5'.")+ label = serializers.CharField(help_text="Display name, e.g. 'Claude Sonnet 5.5'.") # type: ignore[assignment]+ runtime_adapter = serializers.CharField(help_text="Runtime that drives the model: 'claude' or 'codex'.")+ supported_efforts = AgentReasoningEffortOptionSerializer(+ many=True, help_text="Reasoning efforts this model supports. Empty when it has no effort setting."+ )+ cost_multiplier = serializers.CharField(+ allow_null=True,+ help_text="Token price relative to Claude Sonnet 5, e.g. '2×'. Null when no rate is known.",+ )++ class Meta:+ dataclass = AgentModelOption+ fields = ["model", "label", "runtime_adapter", "supported_efforts", "cost_multiplier"]+++class AgentModelOptionsSerializer(DataclassSerializer):+ default_model = serializers.CharField(help_text="Model a pipeline with a null agent_model trains on.")+ default_model_label = serializers.CharField(help_text="Display name of default_model.")+ default_reasoning_effort = serializers.CharField(+ allow_null=True, help_text="Reasoning effort a pipeline with a null agent_reasoning_effort trains at."+ )+ models = AgentModelOptionSerializer(many=True, help_text="Models a pipeline may set as agent_model.")++ class Meta:+ dataclass = AgentModelOptions+ fields = ["default_model", "default_model_label", "default_reasoning_effort", "models"]++# ── Template serializers ───────────────────────────────────────────────────────diff --git a/products/autoresearch/backend/presentation/views/views.py b/products/autoresearch/backend/presentation/views/views.pyindex 61ed6cb748eb..a04281647dc3 100644--- a/products/autoresearch/backend/presentation/views/views.py+++ b/products/autoresearch/backend/presentation/views/views.py@@ -50,6 +50,7 @@ from products.tasks.backend.facade import api as tasks_facadefrom products.tasks.backend.facade.access import code_access_required_response, usage_limit_responsefrom .serializers import (+ AgentModelOptionsSerializer,ArtifactContentSerializer,ArtifactDeleteResultSerializer,ArtifactListSerializer,@@ -221,6 +222,7 @@ class AutoresearchPipelineViewSet(TeamAndOrgViewSetMixin, _FacadePaginationMixin"list_templates","resolve_template","online_performance",+ "agent_models",]scope_object_write_actions = ["create",@@ -369,6 +371,19 @@ class AutoresearchPipelineViewSet(TeamAndOrgViewSetMixin, _FacadePaginationMixindef list_templates(self, request: Request, *args: Any, **kwargs: Any) -> Response:return Response(TemplateInfoSerializer(instance=api.list_templates(), many=True).data)+ @extend_schema(+ responses={200: AgentModelOptionsSerializer},+ summary="List training agent models",+ description=(+ "Return the models a pipeline's training agent may run on, with the reasoning efforts each supports "+ "and its relative token cost, plus the model and effort a pipeline with blank settings uses. "+ "Pass a model id as agent_model and an effort as agent_reasoning_effort on create or update."+ ),+ )+ @action(detail=False, methods=["get"], url_path="agent_models", pagination_class=None)+ def agent_models(self, request: Request, *args: Any, **kwargs: Any) -> Response:+ return Response(AgentModelOptionsSerializer(instance=api.list_agent_model_options()).data)+@validated_request(request_serializer=ResolveTemplateRequestSerializer,responses={diff --git a/products/autoresearch/backend/tests/test_api.py b/products/autoresearch/backend/tests/test_api.pyindex fda8c9b3345a..14f3f91072e9 100644--- a/products/autoresearch/backend/tests/test_api.py+++ b/products/autoresearch/backend/tests/test_api.py@@ -1111,16 +1111,72 @@ class TestAutoresearchPipelineAPI(TeamScopedTestMixin, APIBaseTest):pipeline = self._make_trained_pipeline()resp = self.client.patch(f"{self.base_url}/{pipeline.id}/",- {"name": "Renamed", "cadence_days": 3, "iterations_per_run": 8, "research_interval_days": None},+ {+ "name": "Renamed",+ "cadence_days": 3,+ "iterations_per_run": 8,+ "research_interval_days": None,+ "agent_model": "gpt-6.1-sol",+ "agent_reasoning_effort": "high",+ },format="json",)assert resp.status_code == status.HTTP_200_OK, resp.json()assert resp.json()["next_research_at"] is None+ assert (resp.json()["effective_agent_model"], resp.json()["effective_agent_reasoning_effort"]) == (+ "gpt-6.1-sol",+ "high",+ )pipeline.refresh_from_db()assert pipeline.name == "Renamed"assert pipeline.cadence_days == 3assert pipeline.iterations_per_run == 8assert pipeline.research_interval_days is None+ assert (pipeline.agent_model, pipeline.agent_reasoning_effort) == ("gpt-6.1-sol", "high")++ @parameterized.expand(+ [+ ("unknown_model", {}, {"agent_model": "not-a-model"}, "agent_model"),+ (+ "effort_the_model_lacks",+ {},+ {"agent_model": "gpt-5", "agent_reasoning_effort": "max"},+ "agent_reasoning_effort",+ ),+ ("unknown_effort_on_the_default_model", {}, {"agent_reasoning_effort": "turbo"}, "agent_reasoning_effort"),+ (+ "effort_against_the_stored_model",+ {"agent_model": "gpt-5"},+ {"agent_reasoning_effort": "max"},+ "agent_reasoning_effort",+ ),+ (+ "clearing_the_model",+ {"agent_model": "gpt-5", "agent_reasoning_effort": "high"},+ {"agent_model": None},+ None,+ ),+ ]+ )+ def test_agent_model_settings_are_validated(+ self, _name: str, stored: dict, payload: dict, rejected_field: str | None+ ):+ pipeline = self._make_pipeline(**stored)+ resp = self.client.patch(f"{self.base_url}/{pipeline.id}/", payload, format="json")+ if rejected_field is None:+ assert resp.status_code == status.HTTP_200_OK, resp.json()+ assert (resp.json()["effective_agent_model"], resp.json()["effective_agent_reasoning_effort"]) == (+ "claude-opus-5-5",+ "high",+ )+ return+ assert resp.status_code == status.HTTP_400_BAD_REQUEST+ assert resp.json()["attr"] == rejected_field+ pipeline.refresh_from_db()+ assert (pipeline.agent_model, pipeline.agent_reasoning_effort) == (+ stored.get("agent_model"),+ stored.get("agent_reasoning_effort"),+ )def test_resubmitting_unchanged_target_after_training_is_allowed(self):pipeline = self._make_trained_pipeline()diff --git a/products/autoresearch/backend/training/AGENTS.md b/products/autoresearch/backend/training/AGENTS.mdindex c6b799489133..6044bef0a5fa 100644--- a/products/autoresearch/backend/training/AGENTS.md+++ b/products/autoresearch/backend/training/AGENTS.md@@ -3,7 +3,7 @@Finding a better model for a pipeline's question.One `run_training()` call → one `AutoresearchTrainingRun` → one sandbox agent session → zero or more `AutoresearchIteration` rows → at most one new champion `AutoresearchModel`.-This is the expensive half of the product. A real run costs roughly a dollar in LLM spend and takes tens of minutes, so almost everything here is built around _not_ wasting a run: the stub path for plumbing tests, the safety net for agents that die mid-flight, and server-side champion selection so a confused agent cannot promote itself.+This is the expensive half of the product. A real run costs roughly a dollar in LLM spend on Sonnet, about twice that on the default Opus 5.5, and takes tens of minutes, so almost everything here is built around _not_ wasting a run: the stub path for plumbing tests, the safety net for agents that die mid-flight, and server-side champion selection so a confused agent cannot promote itself.The other half is `../inference/`, which consumes what this package produces and must never re-fit.@@ -12,6 +12,7 @@ The other half is `../inference/`, which consumes what this package produces and- `runner.py`The real path. `run_training()` creates the `AutoresearchTrainingRun` (status `RUNNING`) and fires `Task.create_and_run()` with `internal=True` and no repository, so the run shows up as an internal Task rather than in the normal Tasks list.The brief carries user-authored text, so the sandbox token holds only `TRAINING_MCP_SCOPES` (the `execute-sql` reads, the autoresearch scopes, and `user:read`, which the PostHog MCP server needs to start a session), and an empty connector allowlist keeps the team's shared MCP connectors out of the sandbox.+ The task runs on the model and reasoning effort that `agent_run_config_for()` in `agent_model.py` resolves, and the run records the runtime adapter, model and effort in `agent_runtime_adapter`, `agent_model` and `agent_reasoning_effort`.`build_agent_description()` assembles the agent's brief — the target, the horizon, the population, and the contract for the bundle it must author.When the `autoresearch-report-notebook` flag is on for the launching user, the token also holds `REPORT_NOTEBOOK_MCP_SCOPES` and the brief adds two Finalize steps: before complete, the agent creates one report notebook and passes its `short_id` to complete. After complete, it adds the SQL and chart cells, because the run's model row (and so its `model_explanation`) exists only from then on. `report.md` stays required either way.The brief's worked `features.sql` reads events through a pre-filtered subquery (the event names the features use, the anchor persons, and the anchors' widest window) before it joins, because ClickHouse builds the hash table from the right side of a join and a direct events join reads the whole team's events.@@ -21,6 +22,12 @@ The other half is `../inference/`, which consumes what this package produces and`feature_sql_hints()` in `recipe_validation.py` returns a non-blocking hint when a query reads `persons` or `raw_persons` in a SELECT whose `WHERE` does not refer to `{anchors}`. The `materialize-features` response carries the hints, with the `elapsed_s` and `rows_read` of the materialization.Step 0 of the brief carries the realized results that `realized_context.py` computes, wrapped as untrusted data, with guidance on how to read the gap between holdout and realized AUC. The brief presents realized AUC as evidence for a direction, never as a target: the next run's holdout covers the same recent dates, so tuning against realized results tunes against the holdout. A pipeline with no validated dates gets one line instead of tables. `report.md` asks for one line on how the run used these results.The agent drives the rest _itself_ through the `autoresearch-*` MCP tools: it records each iteration, uploads the bundle, and calls complete. Nothing polls it.+- `agent_model.py`+ Which model and reasoning effort the training agent runs on. Training is an internal task, and internal tasks skip team and user run preferences, so without an explicit model the run would take the Tasks default and change with it.+ A pipeline's null `agent_model` resolves to `AUTORESEARCH_DEFAULT_MODEL` (`claude-opus-5-5`), and a null `agent_reasoning_effort` to `AUTORESEARCH_DEFAULT_REASONING_EFFORT` (`medium`). The runtime adapter comes from the model, so a Codex model runs on the Codex adapter.+ A stored model the catalogue no longer serves resolves to the default model, and an effort the model does not support resolves to the default effort, so a stale row never fails a paid run at dispatch.+ The write path is stricter: `validate_agent_settings()` rejects a model outside `agent_model_choices()` and an effort the model does not support. The choices are the offered Tasks catalogue models without an access flag, read through the tasks facade only.+ Opus 5.5 lists at twice Sonnet 5.5's token price, so a run on the default costs roughly twice what a Sonnet run costs. The brief must read the same under every runtime, so keep harness-specific wording out of it.- `stub.py``run_stub_training()` — a hand-authored champion recipe with universal engagement features (event counts, distinct event types, days since first seen) that apply to any team and any target.No agent, no LLM spend, deterministic. This is what `--stub` on `autoresearch_train` uses, and it is the right tool for testing anything downstream of training.diff --git a/products/autoresearch/backend/training/agent_model.py b/products/autoresearch/backend/training/agent_model.pynew file mode 100644index 000000000000..92903b1335cb--- /dev/null+++ b/products/autoresearch/backend/training/agent_model.py@@ -0,0 +1,76 @@+"""Which model and reasoning effort a pipeline's training agent runs on.++Autoresearch sets its own default rather than inheriting the Tasks one: training runs as an+internal task, which skips team and user run preferences, so a change to the Tasks default+would otherwise change the training model and its cost without anyone choosing it.+"""++from __future__ import annotations++from django.core.exceptions import ValidationError as DjangoValidationError++from posthog.dataclasses import frozen++from products.autoresearch.backend.models import AutoresearchPipeline+from products.tasks.backend.facade.ai_run_defaults import validate_ai_run_preferences+from products.tasks.backend.facade.model_catalogue import ModelChoice, filter_unsupported_effort, offered_model_choices+from products.tasks.backend.facade.run_config import get_required_model_flag, get_runtime_adapter_for_model++AUTORESEARCH_DEFAULT_MODEL = "claude-opus-5-5"+AUTORESEARCH_DEFAULT_REASONING_EFFORT = "medium"+++class AgentModelError(ValueError):+ pass+++@frozen+class AgentRunConfig:+ runtime_adapter: str+ model: str+ reasoning_effort: str | None+++def agent_model_choices() -> tuple[ModelChoice, ...]:+ """The models a pipeline may pick.++ A model behind an access flag is left out, because the training task is internal and no+ person's flag decides whether it may run.+ """+ return tuple(choice for choice in offered_model_choices() if get_required_model_flag(choice.model) is None)+++def resolve_agent_run_config(model: str | None, reasoning_effort: str | None) -> AgentRunConfig:+ """Turn stored settings into what the training task runs with. Blank settings take the defaults.++ A stored model the catalogue no longer serves falls back to the default model, and an+ effort the resolved model does not support falls back to the default effort, so a stale+ row never fails a paid run at dispatch.+ """+ resolved_model = model or AUTORESEARCH_DEFAULT_MODEL+ adapter = get_runtime_adapter_for_model(resolved_model)+ if adapter is None:+ resolved_model = AUTORESEARCH_DEFAULT_MODEL+ adapter = get_runtime_adapter_for_model(resolved_model)+ assert adapter is not None+ resolved_effort = filter_unsupported_effort(+ adapter.value, resolved_model, reasoning_effort+ ) or filter_unsupported_effort(adapter.value, resolved_model, AUTORESEARCH_DEFAULT_REASONING_EFFORT)+ return AgentRunConfig(runtime_adapter=adapter.value, model=resolved_model, reasoning_effort=resolved_effort)+++def agent_run_config_for(pipeline: AutoresearchPipeline) -> AgentRunConfig:+ return resolve_agent_run_config(pipeline.agent_model, pipeline.agent_reasoning_effort)+++def validate_agent_settings(model: str | None, reasoning_effort: str | None) -> None:+ """Raise ``AgentModelError`` unless the pair may be stored. An effort without a model is checked against the default model."""+ if model is not None and model not in {choice.model for choice in agent_model_choices()}:+ offered = ", ".join(choice.model for choice in agent_model_choices())+ raise AgentModelError(f"Unknown model '{model}'. Choose one of: {offered}.")+ resolved_model = model or AUTORESEARCH_DEFAULT_MODEL+ adapter = get_runtime_adapter_for_model(resolved_model)+ try:+ validate_ai_run_preferences(adapter.value if adapter else None, resolved_model, reasoning_effort)+ except DjangoValidationError as exc:+ raise AgentModelError(" ".join(exc.messages)) from excdiff --git a/products/autoresearch/backend/training/runner.py b/products/autoresearch/backend/training/runner.pyindex 195a02b35735..0407ffb32f7a 100644--- a/products/autoresearch/backend/training/runner.py+++ b/products/autoresearch/backend/training/runner.py@@ -46,6 +46,7 @@ from products.autoresearch.backend.models import (AutoresearchSuggestion,AutoresearchTrainingRun,)+from products.autoresearch.backend.training.agent_model import agent_run_config_forfrom products.autoresearch.backend.training.explanation import MAX_TOP_FEATURESfrom products.autoresearch.backend.training.realized_context import (RealizedContext,@@ -232,7 +233,7 @@ def build_agent_description(realized_context: RealizedContext | None = None,rescue: bool = False,) -> str:- """Build the Claude Code agent prompt for the autoresearch training loop."""+ """Build the agent brief for the autoresearch training loop. It must read the same under every runtime adapter."""pop_clause = ""if pipeline.training_population:pop_clause = (@@ -967,6 +968,7 @@ def run_training(build_target_condition(target_event=pipeline.target_event, target_definition=pipeline.target_definition, team=pipeline.team)+ agent_config = agent_run_config_for(pipeline)now = django_timezone.now()with transaction.atomic():@@ -976,6 +978,9 @@ def run_training(kickoff_reason=kickoff_reason,iteration_budget=iteration_budget,started_at=now,+ agent_runtime_adapter=agent_config.runtime_adapter,+ agent_model=agent_config.model,+ agent_reasoning_effort=agent_config.reasoning_effort,)# Surface the inaugural training run in the pipeline badge. A DRAFT pipeline has no@@ -1017,6 +1022,11 @@ def run_training(create_pr=False,mode="background",internal=True,+ # Internal tasks skip team and user run preferences, so without these the run would+ # take whatever the Tasks default is.+ runtime_adapter=agent_config.runtime_adapter,+ model=agent_config.model,+ reasoning_effort=agent_config.reasoning_effort,posthog_mcp_scopes=mcp_scopes,# The autoresearch image is the agent-capable base plus pandas/numpy/# scikit-learn/pyarrow at system site. The base image lacks the ML libs; thediff --git a/products/autoresearch/backend/training/test_training.py b/products/autoresearch/backend/training/test_training.pyindex 88471237203d..377f5ba2c912 100644--- a/products/autoresearch/backend/training/test_training.py+++ b/products/autoresearch/backend/training/test_training.py@@ -380,6 +380,40 @@ class TestRunTraining(TeamScopedTestMixin, BaseTest):self.pipeline.refresh_from_db()assert self.pipeline.status == AutoresearchPipeline.Status.BOOTSTRAPPING+ @parameterized.expand(+ [+ ("blank_settings", None, None, ("claude", "claude-opus-5-5", "medium")),+ ("sonnet_override", "claude-sonnet-5-5", "high", ("claude", "claude-sonnet-5-5", "high")),+ ("codex_override", "gpt-6.1-sol", None, ("codex", "gpt-6.1-sol", "medium")),+ ("stale_stored_model", "claude-retired-model", "low", ("claude", "claude-opus-5-5", "low")),+ ("effort_the_model_lacks", "gpt-5", "max", ("codex", "gpt-5", "medium")),+ ]+ )+ def test_dispatch_runs_on_the_pipeline_model(+ self,+ facade: MagicMock,+ _name: str,+ agent_model: str | None,+ agent_reasoning_effort: str | None,+ expected: tuple[str, str, str],+ ) -> None:+ self._dispatched(facade)+ AutoresearchPipeline.objects.filter(pk=self.pipeline.pk).update(+ agent_model=agent_model, agent_reasoning_effort=agent_reasoning_effort+ )+ self.pipeline.refresh_from_db()++ training_run = run_training(self.pipeline, iteration_budget=5, user_id=self.user.id)++ kwargs = facade.create_and_run_task.call_args.kwargs+ assert (kwargs["runtime_adapter"], kwargs["model"], kwargs["reasoning_effort"]) == expected+ training_run.refresh_from_db()+ assert (+ training_run.agent_runtime_adapter,+ training_run.agent_model,+ training_run.agent_reasoning_effort,+ ) == expected+def test_a_task_run_that_ended_at_dispatch_fails_the_training_run(self, facade: MagicMock) -> None:self._dispatched(facade)facade.task_run_is_terminal.return_value = Truediff --git a/products/autoresearch/frontend/AGENTS.md b/products/autoresearch/frontend/AGENTS.mdindex f2fbee90fcb0..dddc52ef124e 100644--- a/products/autoresearch/frontend/AGENTS.md+++ b/products/autoresearch/frontend/AGENTS.md@@ -18,7 +18,7 @@ The product is mostly a backend, and the UI is deliberately thin — it reads st| `newModel/` | Create-form parts: template chips, definition sentence, Advanced section, readiness checklist, "What happens next". || `autoresearchPipelineLogic.ts` | Detail logic. Also maps the old `?tab=` keys to the four tabs, so saved links still open. || `pipelineLifecycle.ts` | The five lifecycle steps (question set to checked against reality) and which one is current. |-| `trainingScheduleLogic.ts` | Setup tab training schedule: the research interval and experiments per run, their save, and the one-line phase and next run status. |+| `trainingScheduleLogic.ts` | Setup tab training settings: research interval, experiments per run, research model and thinking effort, their save, and the status line. || `agentSearch.ts` | The agent's search across training runs: chart points, best score so far, change per experiment within a run, log groups and status brief. || `onlinePerformance.ts` | Accuracy tab helpers over the `online_performance` endpoint: the stat tiles, the per-metric accuracy trend, predicted against actual. || `predictionCoverage.ts` | Predictions tab coverage from the runs list: the measured summary and the coverage and score age per day. |@@ -53,7 +53,7 @@ Follow `frontend/src/AGENTS.md` — it applies to product frontends too.- TypeScript with explicit return types; Tailwind utilities rather than inline styles.- Reuse Lemon / quill components instead of hand-rolling tables, badges, or tags.- Any button that fires a request must guard against double-submission — `loading` / `disabledReason` on `LemonButton`, reset on both success and error paths. The lifecycle actions here (train, score, archive, pause, resume) are all network calls, and several are expensive: firing `train` twice starts two sandbox agent runs and spends the budget twice.-- Usage events are part of the API: renaming one breaks every insight built on it. The list logic captures `autoresearch model list viewed`, `autoresearch model list load failed`, `autoresearch model deleted` / `paused` / `resumed`, `autoresearch model training started` (with `source: 'list'` from a card), `autoresearch model card clicked`, and `autoresearch model action failed` (with `action`). The create logic captures `autoresearch model template selected` (with `template_key`), `autoresearch model custom chosen`, `autoresearch model advanced opened`, `autoresearch model created` (with `action`: `start_training` or `save_draft`), and `autoresearch model training started` / `training start failed`. The detail logic captures `autoresearch model tab changed` (with `tab`) when a person picks a tab, `autoresearch model experiment log filter changed` (with `filter`), `autoresearch model accuracy cutoff changed` (with `cutoff`, and `source`: `flagged` or `trend` for the card that changed it), `autoresearch model accuracy trend metric changed` (with `metric`), `autoresearch model accuracy trend challengers toggled` (with `shown`), `autoresearch model search point clicked` (with `run_id`, `iteration_number`, `status`), `autoresearch model experiment details opened` (with `run_id`, `iteration_number`) when a person opens an experiment's working notes, `autoresearch model suggestion sent` (with `priority`), `autoresearch agent research experiment opened` (with `run_id`, `iteration_number`, `status`, `source`: `chart` or `log`) when a person opens the experiment drawer, `autoresearch agent research steer opened` (with `queued_count`) `autoresearch agent research full notes opened` (with `run_number`) and `autoresearch training schedule changed` (with `research_interval_days` and `iterations_per_run`); buttons carry a `data-attr` for autocapture. Extend the same names when you add a scene.+- Usage events are part of the API: renaming one breaks every insight built on it. The list logic captures `autoresearch model list viewed`, `autoresearch model list load failed`, `autoresearch model deleted` / `paused` / `resumed`, `autoresearch model training started` (with `source: 'list'` from a card), `autoresearch model card clicked`, and `autoresearch model action failed` (with `action`). The create logic captures `autoresearch model template selected` (with `template_key`), `autoresearch model custom chosen`, `autoresearch model advanced opened`, `autoresearch model created` (with `action`: `start_training` or `save_draft`), and `autoresearch model training started` / `training start failed`. The detail logic captures `autoresearch model tab changed` (with `tab`) when a person picks a tab, `autoresearch model experiment log filter changed` (with `filter`), `autoresearch model accuracy cutoff changed` (with `cutoff`, and `source`: `flagged` or `trend` for the card that changed it), `autoresearch model accuracy trend metric changed` (with `metric`), `autoresearch model accuracy trend challengers toggled` (with `shown`), `autoresearch model search point clicked` (with `run_id`, `iteration_number`, `status`), `autoresearch model experiment details opened` (with `run_id`, `iteration_number`) when a person opens an experiment's working notes, `autoresearch model suggestion sent` (with `priority`), `autoresearch agent research experiment opened` (with `run_id`, `iteration_number`, `status`, `source`: `chart` or `log`) when a person opens the experiment drawer, `autoresearch agent research steer opened` (with `queued_count`) `autoresearch agent research full notes opened` (with `run_number`) `autoresearch training schedule changed` (with `research_interval_days` and `iterations_per_run`), and `autoresearch research model changed` (with `agent_model` and `agent_reasoning_effort`, null meaning the default) when a save changes either; buttons carry a `data-attr` for autocapture. Extend the same names when you add a scene.## Copydiff --git a/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsx b/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsxindex e9b905e65305..7da94448591a 100644--- a/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsx+++ b/products/autoresearch/frontend/AutoresearchPipelineScene.stories.tsx@@ -34,6 +34,10 @@ const pipeline = {iteration_budget_remaining: 6,iterations_per_run: 5,research_interval_days: 7,+ agent_model: null,+ agent_reasoning_effort: null,+ effective_agent_model: 'claude-opus-5-5',+ effective_agent_reasoning_effort: 'medium',training_phase: 'maintain',next_research_at: '2026-11-12T00:00:00Z',success_auc: null,@@ -313,6 +317,9 @@ const trainingRuns = [id: 'training-2',pipeline: PIPELINE_ID,kickoff_reason: 'explore',+ agent_model: 'claude-opus-5-5',+ agent_model_label: 'Claude Opus 5.5',+ agent_reasoning_effort: 'medium',task_url: null,status: 'completed',iteration_count: 5,@@ -337,6 +344,9 @@ const trainingRuns = [id: 'training-1',pipeline: PIPELINE_ID,kickoff_reason: 'manual',+ agent_model: 'claude-opus-5-5',+ agent_model_label: 'Claude Opus 5.5',+ agent_reasoning_effort: 'medium',task_url: null,status: 'completed',iteration_count: 4,diff --git a/products/autoresearch/frontend/generated/api.schemas.ts b/products/autoresearch/frontend/generated/api.schemas.tsindex ef897e7f95e8..53b4aa5b65ae 100644--- a/products/autoresearch/frontend/generated/api.schemas.ts+++ b/products/autoresearch/frontend/generated/api.schemas.ts@@ -263,6 +263,23 @@ export interface AutoresearchPipelineApi {* * `60` - 60* * `90` - 90 */readonly research_interval_days: ResearchIntervalDaysEnumApi | null+ /**+ * Model the training agent runs on, as set on this pipeline. Null uses the autoresearch default.+ * @nullable+ */+ readonly agent_model: string | null+ /**+ * Reasoning effort for the training agent, as set on this pipeline. Null uses the autoresearch default.+ * @nullable+ */+ readonly agent_reasoning_effort: string | null+ /** Model the next training run uses: agent_model, or the autoresearch default when that is null. */+ readonly effective_agent_model: string+ /**+ * Reasoning effort the next training run uses: agent_reasoning_effort, or the autoresearch default when that is null. Null when the model has no effort setting.+ * @nullable+ */+ readonly effective_agent_reasoning_effort: string | null/** explore: a research run on each scoring day until a run does not promote a better model, or until 5 research runs have run. maintain: one research run every research_interval_days.** * `explore` - Explore@@ -454,6 +471,18 @@ export interface AutoresearchPipelineCreateApi {* * `60` - 60* * `90` - 90 */research_interval_days?: ResearchIntervalDaysEnumApi | null+ /**+ * Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it.+ * @maxLength 100+ * @nullable+ */+ agent_model?: string | null+ /**+ * Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run.+ * @maxLength 20+ * @nullable+ */+ agent_reasoning_effort?: string | null/*** Target AUC threshold (0-1). Training stops early if reached. Default: 0.75.* @minimum 0@@ -1031,6 +1060,26 @@ export interface AutoresearchTrainingRunApi {* * `rescue` - Rescue* * `manual` - Manual */readonly kickoff_reason: AutoresearchTrainingRunKickoffReasonEnumApi | null+ /**+ * Runtime that drove the training agent, 'claude' or 'codex'. Null for older runs and runs with no task.+ * @nullable+ */+ readonly agent_runtime_adapter: string | null+ /**+ * Model the training agent ran on. Null for older runs and runs with no task.+ * @nullable+ */+ readonly agent_model: string | null+ /**+ * Display name of agent_model, e.g. 'Claude Opus 5.5'. Null when agent_model is null.+ * @nullable+ */+ readonly agent_model_label: string | null+ /**+ * Reasoning effort the training agent ran at. Null for older runs, runs with no task, and models with no effort setting.+ * @nullable+ */+ readonly agent_reasoning_effort: string | null/*** Maximum iterations allowed for this run.* @minimum -2147483648@@ -1639,6 +1688,18 @@ export interface PatchedAutoresearchPipelineCreateApi {* * `60` - 60* * `90` - 90 */research_interval_days?: ResearchIntervalDaysEnumApi | null+ /**+ * Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it.+ * @maxLength 100+ * @nullable+ */+ agent_model?: string | null+ /**+ * Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run.+ * @maxLength 20+ * @nullable+ */+ agent_reasoning_effort?: string | null/*** Target AUC threshold (0-1). Training stops early if reached. Default: 0.75.* @minimum 0@@ -1855,6 +1916,43 @@ export interface StartTrainingRequestApi {iteration_budget?: number}+export interface AgentReasoningEffortOptionApi {+ /** Effort id to pass as agent_reasoning_effort, e.g. 'medium'. */+ value: string+ /** Display name, e.g. 'Medium'. */+ label: string+}++export interface AgentModelOptionApi {+ /** Model id to pass as agent_model, e.g. 'claude-sonnet-5-5'. */+ model: string+ /** Display name, e.g. 'Claude Sonnet 5.5'. */+ label: string+ /** Runtime that drives the model: 'claude' or 'codex'. */+ runtime_adapter: string+ /** Reasoning efforts this model supports. Empty when it has no effort setting. */+ supported_efforts: AgentReasoningEffortOptionApi[]+ /**+ * Token price relative to Claude Sonnet 5, e.g. '2×'. Null when no rate is known.+ * @nullable+ */+ cost_multiplier: string | null+}++export interface AgentModelOptionsApi {+ /** Model a pipeline with a null agent_model trains on. */+ default_model: string+ /** Display name of default_model. */+ default_model_label: string+ /**+ * Reasoning effort a pipeline with a null agent_reasoning_effort trains at.+ * @nullable+ */+ default_reasoning_effort: string | null+ /** Models a pipeline may set as agent_model. */+ models: AgentModelOptionApi[]+}+/*** * `likely_active_soon` - Likely Active Soon* * `at_risk_of_inactivity` - At Risk Of Inactivitydiff --git a/products/autoresearch/frontend/generated/api.ts b/products/autoresearch/frontend/generated/api.tsindex 3efd4fdcf0cb..9bb59bb9431d 100644--- a/products/autoresearch/frontend/generated/api.ts+++ b/products/autoresearch/frontend/generated/api.ts@@ -9,6 +9,7 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'* OpenAPI spec version: 1.0.0*/import type {+ AgentModelOptionsApi,ArtifactContentApi,ArtifactDeleteResultApi,ArtifactListApi,@@ -885,6 +886,24 @@ export const autoresearchValidateOnlineCreate = async (})}+export const getAutoresearchAgentModelsRetrieveUrl = (projectId: string) => {+ return `/api/projects/${projectId}/autoresearch/agent_models/`+}++/**+ * Return the models a pipeline's training agent may run on, with the reasoning efforts each supports and its relative token cost, plus the model and effort a pipeline with blank settings uses. Pass a model id as agent_model and an effort as agent_reasoning_effort on create or update.+ * @summary List training agent models+ */+export const autoresearchAgentModelsRetrieve = async (+ projectId: string,+ options?: RequestInit+): Promise<AgentModelOptionsApi> => {+ return apiMutator<AgentModelOptionsApi>(getAutoresearchAgentModelsRetrieveUrl(projectId), {+ ...options,+ method: 'GET',+ })+}+export const getAutoresearchResolveTemplateCreateUrl = (projectId: string) => {return `/api/projects/${projectId}/autoresearch/resolve-template/`}diff --git a/products/autoresearch/frontend/generated/api.zod.ts b/products/autoresearch/frontend/generated/api.zod.tsindex 540a635bb9f5..4728b6ac8fab 100644--- a/products/autoresearch/frontend/generated/api.zod.ts+++ b/products/autoresearch/frontend/generated/api.zod.ts@@ -31,6 +31,10 @@ export const autoresearchCreateBodyIterationBudgetMax = 500export const autoresearchCreateBodyIterationsPerRunMax = 50+export const autoresearchCreateBodyAgentModelMax = 100++export const autoresearchCreateBodyAgentReasoningEffortMax = 20+export const autoresearchCreateBodySuccessAucMin = 0export const autoresearchCreateBodySuccessAucMax = 1@@ -121,6 +125,20 @@ export const AutoresearchCreateBody = /* @__PURE__ */ zod.object({.describe('Days between scheduled research runs once the first burst of daily runs ends: 7, 14, 30, 60 or 90. Null means only when asked: no scheduled research, so the only training cost comes from runs you start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7.\n\n\* `7` - 7\n\* `14` - 14\n\* `30` - 30\n\* `60` - 60\n\* `90` - 90'),+ agent_model: zod+ .string()+ .max(autoresearchCreateBodyAgentModelMax)+ .nullish()+ .describe(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ agent_reasoning_effort: zod+ .string()+ .max(autoresearchCreateBodyAgentReasoningEffortMax)+ .nullish()+ .describe(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run."+ ),success_auc: zod.number().min(autoresearchCreateBodySuccessAucMin)@@ -529,6 +547,10 @@ export const autoresearchUpdateBodyIterationBudgetMax = 500export const autoresearchUpdateBodyIterationsPerRunMax = 50+export const autoresearchUpdateBodyAgentModelMax = 100++export const autoresearchUpdateBodyAgentReasoningEffortMax = 20+export const autoresearchUpdateBodySuccessAucMin = 0export const autoresearchUpdateBodySuccessAucMax = 1@@ -619,6 +641,20 @@ export const AutoresearchUpdateBody = /* @__PURE__ */ zod.object({.describe('Days between scheduled research runs once the first burst of daily runs ends: 7, 14, 30, 60 or 90. Null means only when asked: no scheduled research, so the only training cost comes from runs you start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7.\n\n\* `7` - 7\n\* `14` - 14\n\* `30` - 30\n\* `60` - 60\n\* `90` - 90'),+ agent_model: zod+ .string()+ .max(autoresearchUpdateBodyAgentModelMax)+ .nullish()+ .describe(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ agent_reasoning_effort: zod+ .string()+ .max(autoresearchUpdateBodyAgentReasoningEffortMax)+ .nullish()+ .describe(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run."+ ),success_auc: zod.number().min(autoresearchUpdateBodySuccessAucMin)@@ -668,6 +704,10 @@ export const autoresearchPartialUpdateBodyIterationBudgetMax = 500export const autoresearchPartialUpdateBodyIterationsPerRunMax = 50+export const autoresearchPartialUpdateBodyAgentModelMax = 100++export const autoresearchPartialUpdateBodyAgentReasoningEffortMax = 20+export const autoresearchPartialUpdateBodySuccessAucMin = 0export const autoresearchPartialUpdateBodySuccessAucMax = 1@@ -758,6 +798,20 @@ export const AutoresearchPartialUpdateBody = /* @__PURE__ */ zod.object({.describe('Days between scheduled research runs once the first burst of daily runs ends: 7, 14, 30, 60 or 90. Null means only when asked: no scheduled research, so the only training cost comes from runs you start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7.\n\n\* `7` - 7\n\* `14` - 14\n\* `30` - 30\n\* `60` - 60\n\* `90` - 90'),+ agent_model: zod+ .string()+ .max(autoresearchPartialUpdateBodyAgentModelMax)+ .nullish()+ .describe(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ agent_reasoning_effort: zod+ .string()+ .max(autoresearchPartialUpdateBodyAgentReasoningEffortMax)+ .nullish()+ .describe(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run."+ ),success_auc: zod.number().min(autoresearchPartialUpdateBodySuccessAucMin)diff --git a/products/autoresearch/frontend/pipeline/SetupTab.tsx b/products/autoresearch/frontend/pipeline/SetupTab.tsxindex f021b5b85b7a..35f5357c1574 100644--- a/products/autoresearch/frontend/pipeline/SetupTab.tsx+++ b/products/autoresearch/frontend/pipeline/SetupTab.tsx@@ -5,7 +5,12 @@ import { LemonButton, LemonInput, LemonSelect, LemonSkeleton } from '@posthog/leimport { dayjs } from 'lib/dayjs'import { autoresearchPipelineLogic } from '../autoresearchPipelineLogic'-import { AutoresearchPipelineApi, ResearchIntervalDaysEnumApi } from '../generated/api.schemas'+import {+ AgentModelOptionsApi,+ AgentReasoningEffortOptionApi,+ AutoresearchPipelineApi,+ ResearchIntervalDaysEnumApi,+} from '../generated/api.schemas'import {MAX_ITERATIONS_PER_RUN,MIN_ITERATIONS_PER_RUN,@@ -23,6 +28,42 @@ const RESEARCH_INTERVAL_OPTIONS: { value: ResearchIntervalDaysEnumApi | typeof O{ value: ONLY_WHEN_ASKED, label: 'Only when I ask' },]+const DEFAULT_SETTING = 'default'++function modelSelectOptions(+ options: AgentModelOptionsApi | null,+ savedModel: string | null+): { value: string; label: string }[] {+ if (!options) {+ // Keep the saved model readable while the list loads.+ return [+ { value: DEFAULT_SETTING, label: 'Default' },+ ...(savedModel ? [{ value: savedModel, label: savedModel }] : []),+ ]+ }+ const withCost = (label: string, cost: string | null | undefined): string =>+ cost ? `${label} · ${cost} cost` : label+ const defaultCost = options.models.find((option) => option.model === options.default_model)?.cost_multiplier+ return [+ { value: DEFAULT_SETTING, label: withCost(`Default (${options.default_model_label})`, defaultCost) },+ ...options.models.map((option) => ({+ value: option.model,+ label: withCost(option.label, option.cost_multiplier),+ })),+ ]+}++function effortSelectOptions(+ efforts: AgentReasoningEffortOptionApi[],+ defaultEffort: string | null | undefined+): { value: string; label: string }[] {+ const defaultLabel = efforts.find((effort) => effort.value === defaultEffort)?.label+ return [+ { value: DEFAULT_SETTING, label: defaultLabel ? `Default (${defaultLabel})` : 'Default' },+ ...efforts.map((effort) => ({ value: effort.value, label: effort.label })),+ ]+}+export function SetupTab(): JSX.Element {const { pipeline } = useValues(autoresearchPipelineLogic)if (!pipeline) {@@ -67,10 +108,10 @@ export function SetupTab(): JSX.Element {}function TrainingScheduleSetting({ pipeline }: { pipeline: AutoresearchPipelineApi }): JSX.Element {- const { schedule, savingSchedule, saveDisabledReason } = useValues(trainingScheduleLogic({ id: pipeline.id }))- const { setResearchIntervalDays, setIterationsPerRun, saveSchedule } = useActions(- trainingScheduleLogic({ id: pipeline.id })- )+ const { schedule, savingSchedule, saveDisabledReason, agentModelOptions, agentModelOptionsLoading, effortOptions } =+ useValues(trainingScheduleLogic({ id: pipeline.id }))+ const { setResearchIntervalDays, setIterationsPerRun, setAgentModel, setAgentReasoningEffort, saveSchedule } =+ useActions(trainingScheduleLogic({ id: pipeline.id }))return (<div className="flex flex-col gap-2"><div className="flex flex-wrap items-end gap-3">@@ -97,6 +138,30 @@ function TrainingScheduleSetting({ pipeline }: { pipeline: AutoresearchPipelineAdata-attr="autoresearch-iterations-per-run"/></label>+ <label className="flex flex-col gap-1">+ <span className="text-sm font-semibold">Research model</span>+ <LemonSelect+ size="small"+ options={modelSelectOptions(agentModelOptions, pipeline.agent_model)}+ value={schedule?.agent_model ?? DEFAULT_SETTING}+ onChange={(value) => setAgentModel(value === DEFAULT_SETTING ? null : value)}+ loading={agentModelOptionsLoading}+ dropdownMatchSelectWidth={false}+ data-attr="autoresearch-research-model"+ />+ </label>+ {effortOptions.length > 0 && (+ <label className="flex flex-col gap-1">+ <span className="text-sm font-semibold">Thinking effort</span>+ <LemonSelect+ size="small"+ options={effortSelectOptions(effortOptions, agentModelOptions?.default_reasoning_effort)}+ value={schedule?.agent_reasoning_effort ?? DEFAULT_SETTING}+ onChange={(value) => setAgentReasoningEffort(value === DEFAULT_SETTING ? null : value)}+ data-attr="autoresearch-thinking-effort"+ />+ </label>+ )}<LemonButtontype="primary"size="small"@@ -105,10 +170,12 @@ function TrainingScheduleSetting({ pipeline }: { pipeline: AutoresearchPipelineAdisabledReason={saveDisabledReason}data-attr="autoresearch-training-schedule-save">- Save schedule+ Save settings</LemonButton></div>- <p className="text-xs text-secondary mb-0">{trainingScheduleStatus(pipeline)}</p>+ <p className="text-xs text-secondary mb-0">+ {trainingScheduleStatus(pipeline)} A larger model or more thinking effort costs more per training run.+ </p></div>)}diff --git a/products/autoresearch/frontend/pipeline/TrainingRunRow.tsx b/products/autoresearch/frontend/pipeline/TrainingRunRow.tsxindex d55d04eecc28..2a19b73a98fc 100644--- a/products/autoresearch/frontend/pipeline/TrainingRunRow.tsx+++ b/products/autoresearch/frontend/pipeline/TrainingRunRow.tsx@@ -133,6 +133,11 @@ export function TrainingRunRow({<span>· {KICKOFF_REASON[run.kickoff_reason].label}</span></Tooltip>)}+ {run.agent_model_label && (+ <Tooltip title="The model the research agent ran on">+ <span>· {run.agent_model_label}</span>+ </Tooltip>+ )}{run.task_url && (<Linkto={run.task_url}diff --git a/products/autoresearch/frontend/trainingScheduleLogic.ts b/products/autoresearch/frontend/trainingScheduleLogic.tsindex ceedd191bcd4..a1ce313dc358 100644--- a/products/autoresearch/frontend/trainingScheduleLogic.ts+++ b/products/autoresearch/frontend/trainingScheduleLogic.ts@@ -1,4 +1,5 @@-import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'import posthog from 'posthog-js'import { dayjs } from 'lib/dayjs'@@ -6,8 +7,13 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast'import { teamLogic } from 'scenes/teamLogic'import { AutoresearchPipelineLogicProps, autoresearchPipelineLogic } from './autoresearchPipelineLogic'-import { autoresearchPartialUpdate } from './generated/api'-import type { AutoresearchPipelineApi, ResearchIntervalDaysEnumApi } from './generated/api.schemas'+import { autoresearchAgentModelsRetrieve, autoresearchPartialUpdate } from './generated/api'+import type {+ AgentModelOptionsApi,+ AgentReasoningEffortOptionApi,+ AutoresearchPipelineApi,+ ResearchIntervalDaysEnumApi,+} from './generated/api.schemas'export const MIN_ITERATIONS_PER_RUN = 1export const MAX_ITERATIONS_PER_RUN = 50@@ -15,6 +21,9 @@ export const MAX_ITERATIONS_PER_RUN = 50export interface TrainingScheduleDraft {research_interval_days: ResearchIntervalDaysEnumApi | nulliterations_per_run: number | undefined+ // Null means the autoresearch default.+ agent_model: string | null+ agent_reasoning_effort: string | null}/** One line on what training does next, from the saved schedule. */@@ -39,6 +48,9 @@ export interface trainingScheduleLogicValues {savingSchedule: booleanschedule: TrainingScheduleDraft | nullsaveDisabledReason: string | undefined+ agentModelOptions: AgentModelOptionsApi | null+ agentModelOptionsLoading: boolean+ effortOptions: AgentReasoningEffortOptionApi[]}export interface trainingScheduleLogicActions {@@ -50,6 +62,14 @@ export interface trainingScheduleLogicActions {days: ResearchIntervalDaysEnumApi | null}setIterationsPerRun: (iterations: number | undefined) => { iterations: number | undefined }+ setAgentModel: (model: string | null) => { model: string | null }+ setAgentReasoningEffort: (effort: string | null) => { effort: string | null }+ loadAgentModelOptions: () => { value: true }+ loadAgentModelOptionsSuccess: (agentModelOptions: AgentModelOptionsApi | null) => {+ agentModelOptions: AgentModelOptionsApi | null+ payload?: any+ }+ loadAgentModelOptionsFailure: (error: string) => { error: string }resetDraft: () => { value: true }saveSchedule: () => { value: true }saveScheduleFinished: () => { value: true }@@ -72,6 +92,8 @@ export const trainingScheduleLogic = kea<trainingScheduleLogicType>([actions({setResearchIntervalDays: (days: ResearchIntervalDaysEnumApi | null) => ({ days }),setIterationsPerRun: (iterations: number | undefined) => ({ iterations }),+ setAgentModel: (model: string | null) => ({ model }),+ setAgentReasoningEffort: (effort: string | null) => ({ effort }),resetDraft: true,saveSchedule: true,saveScheduleFinished: true,@@ -83,6 +105,9 @@ export const trainingScheduleLogic = kea<trainingScheduleLogicType>([{setResearchIntervalDays: (state, { days }) => ({ ...state, research_interval_days: days }),setIterationsPerRun: (state, { iterations }) => ({ ...state, iterations_per_run: iterations }),+ // Efforts differ per model, so a new model starts from its default effort.+ setAgentModel: (state, { model }) => ({ ...state, agent_model: model, agent_reasoning_effort: null }),+ setAgentReasoningEffort: (state, { effort }) => ({ ...state, agent_reasoning_effort: effort }),resetDraft: () => ({}),},],@@ -94,6 +119,19 @@ export const trainingScheduleLogic = kea<trainingScheduleLogicType>([},],}),+ loaders(({ values }) => ({+ agentModelOptions: [+ null as AgentModelOptionsApi | null,+ {+ loadAgentModelOptions: async () => {+ if (!values.currentTeamId) {+ return null+ }+ return autoresearchAgentModelsRetrieve(String(values.currentTeamId))+ },+ },+ ],+ })),selectors({schedule: [(s) => [s.pipeline, s.draft],@@ -125,13 +163,28 @@ export const trainingScheduleLogic = kea<trainingScheduleLogicType>([const saved = pickSchedule(pipeline)if (saved.iterations_per_run === iterations &&- saved.research_interval_days === schedule.research_interval_days+ saved.research_interval_days === schedule.research_interval_days &&+ saved.agent_model === schedule.agent_model &&+ saved.agent_reasoning_effort === schedule.agent_reasoning_effort) {return 'Change a setting to save'}return undefined},],+ effortOptions: [+ (s) => [s.agentModelOptions, s.schedule],+ (+ agentModelOptions: AgentModelOptionsApi | null,+ schedule: TrainingScheduleDraft | null+ ): AgentReasoningEffortOptionApi[] => {+ if (!agentModelOptions) {+ return []+ }+ const model = schedule?.agent_model ?? agentModelOptions.default_model+ return agentModelOptions.models.find((option) => option.model === model)?.supported_efforts ?? []+ },+ ],}),listeners(({ actions, values, props }) => ({saveSchedule: async () => {@@ -140,31 +193,61 @@ export const trainingScheduleLogic = kea<trainingScheduleLogicType>([actions.saveScheduleFinished()return}- const changes = {+ const scheduleChanges = {research_interval_days: schedule.research_interval_days,iterations_per_run: schedule.iterations_per_run,}+ const modelChanges = {+ agent_model: schedule.agent_model,+ agent_reasoning_effort: schedule.agent_reasoning_effort,+ }+ const saved = values.pipeline ? pickSchedule(values.pipeline) : null+ const scheduleChanged =+ saved?.research_interval_days !== scheduleChanges.research_interval_days ||+ saved?.iterations_per_run !== scheduleChanges.iterations_per_run+ const modelChanged =+ saved?.agent_model !== modelChanges.agent_model ||+ saved?.agent_reasoning_effort !== modelChanges.agent_reasoning_efforttry {- actions.loadPipelineSuccess(await autoresearchPartialUpdate(String(currentTeamId), props.id, changes))+ actions.loadPipelineSuccess(+ await autoresearchPartialUpdate(String(currentTeamId), props.id, {+ ...scheduleChanges,+ ...modelChanges,+ })+ )actions.resetDraft()- posthog.capture('autoresearch training schedule changed', { pipeline_id: props.id, ...changes })- lemonToast.success('Training schedule saved.')+ // pinned: analytics event names. Renaming breaks insights built on them.+ if (scheduleChanged) {+ posthog.capture('autoresearch training schedule changed', {+ pipeline_id: props.id,+ ...scheduleChanges,+ })+ }+ if (modelChanged) {+ posthog.capture('autoresearch research model changed', { pipeline_id: props.id, ...modelChanges })+ }+ lemonToast.success('Training settings saved.')} catch {posthog.capture('autoresearch model action failed', {action: 'training_schedule',pipeline_id: props.id,})- lemonToast.error("Couldn't save the training schedule. Try again.")+ lemonToast.error("Couldn't save the training settings. Try again.")} finally {actions.saveScheduleFinished()}},})),+ afterMount(({ actions }) => {+ actions.loadAgentModelOptions()+ }),])function pickSchedule(pipeline: AutoresearchPipelineApi): TrainingScheduleDraft {return {research_interval_days: pipeline.research_interval_days,iterations_per_run: pipeline.iterations_per_run,+ agent_model: pipeline.agent_model,+ agent_reasoning_effort: pipeline.agent_reasoning_effort,}}diff --git a/products/autoresearch/mcp/tools.yaml b/products/autoresearch/mcp/tools.yamlindex f4c631233a23..0536e0432fc1 100644--- a/products/autoresearch/mcp/tools.yaml+++ b/products/autoresearch/mcp/tools.yaml@@ -7,6 +7,23 @@ feature: autoresearchurl_prefix: /autoresearchui_apps: {}tools:+ autoresearch-agent-models-retrieve:+ operation: autoresearch_agent_models_retrieve+ enabled: false+ disabled_reason: Feeds the Setup tab model picker. Agents set agent_model on autoresearch-create or+ autoresearch-partial-update, and an invalid value returns the valid choices, which keeps the family under+ its tool cap+ scopes:+ - autoresearch:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ title: List training agent models+ description: >+ List the models a pipeline's training agent may run on, with the reasoning efforts each supports, its+ relative token cost, and the default a pipeline with blank settings uses.+ feature_flag: autoresearchautoresearch-archive-create:operation: autoresearch_archive_createenabled: false@@ -46,8 +63,11 @@ tools:write_person_property is true (default false); prediction events, validation and segments work without it.iterations_per_run (default 5) sets the experiments in each training run. research_interval_days (7, 14, 30,60 or 90, default 7; null means only when asked) sets how often scheduled research runs once the first burst- of daily runs ends. After creating, call autoresearch-train-create to start an asynchronous agent training- run.+ of daily runs ends. agent_model and agent_reasoning_effort choose the model and effort the training agent+ runs on; leave them out to use the autoresearch default (Claude Opus 5.5 at medium effort). A larger model+ or higher effort costs more per training run, and an unknown model or an effort the model does not support+ returns 400 with the valid choices. After creating, call autoresearch-train-create to start an asynchronous+ agent training run.exclude_params:- id- created_by@@ -83,6 +103,8 @@ tools:- status- iterations_per_run- research_interval_days+ - effective_agent_model+ - effective_agent_reasoning_effort- training_phase- next_research_at- last_scored_at@@ -195,7 +217,9 @@ tools:cleanup run that removes the property from the people this pipeline scored (see autoresearch-runs-list).Changing write_person_property needs the person:write scope. Prediction events, online validation andsegments work with it off. Use iterations_per_run and research_interval_days to change the training- schedule; null research_interval_days stops scheduled research. target_event, target_definition,+ schedule; null research_interval_days stops scheduled research. Use agent_model and agent_reasoning_effort+ to change the model the training agent runs on; null returns a field to the autoresearch default, and+ effective_agent_model in the response shows what the next run uses. target_event, target_definition,horizon_days, training_lookback_days and the two populations cannot change once a model has been trained.exclude_params:- id@@ -675,6 +699,8 @@ tools:- pipeline- status- kickoff_reason+ - agent_model+ - agent_reasoning_effort- iteration_budget- iteration_count- best_holdout_scorediff --git a/products/autoresearch/skills/working-with-autoresearch/SKILL.md b/products/autoresearch/skills/working-with-autoresearch/SKILL.mdindex d44ad93df16c..61af2561e94c 100644--- a/products/autoresearch/skills/working-with-autoresearch/SKILL.md+++ b/products/autoresearch/skills/working-with-autoresearch/SKILL.md@@ -89,6 +89,7 @@ A healthy run can show 0 iterations while its experiments are already recorded,- **Autoresearch trains on identified users only.** Anonymous traffic does not count toward training data, so raw event volume can overstate what is available. Trust the validation counts.- **Scores are keyed on the person.** A model whose scores are almost all the same value usually has an identifier problem, not a weak signal. See [troubleshooting-and-steering.md](references/troubleshooting-and-steering.md).- **Read the output property name, do not guess it.** Take `output_person_property` from `posthog:autoresearch-retrieve`. A derived name includes the target and the horizon (`predicted_p_<target>_<horizon>d`), and templates use their own prefix, so two models on one target do not overwrite each other.+- **The research model sets most of the training cost.** A training run uses the model's `agent_model` and `agent_reasoning_effort`. Null uses the default, Claude Opus 5.5 at medium effort, which costs about twice what Claude Sonnet 5.5 costs per run. `effective_agent_model` on `posthog:autoresearch-retrieve` shows what the next run uses, and `posthog:autoresearch-partial-update` changes it. An unknown model or an effort the model does not support returns 400 with the valid choices. `posthog:autoresearch-training-runs-list` shows the model each run used.- **A model costs money to train and query to score.** A very large population scores in rolling batches (about 45,000 people per run), so not everyone gets a fresh score every day. Validation tells you how many runs a full rescore takes.## Bring your own agentdiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 51f6a9bd38dc..13558db99476 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -1176,7 +1176,7 @@}},"autoresearch-create": {- "description": "Create a new autoresearch prediction pipeline. Always call autoresearch-validate-create first — this endpoint does not block on validation errors. The prediction target is either an event (pass target_event, e.g. '$pageview') or a PostHog action (pass target_definition = {\"type\": \"action\", \"action_id\": N} to predict a multi-step / property / autocapture matcher; target_event is then optional; it is the display label and the source of the derived output property name). An action target needs the action:read scope. horizon_days defaults to 7. The output person property (e.g. 'predicted_p_pageview') is auto-derived from target_event, or from the action name when target_event is omitted, if you do not set it. It must be unique among the project's non-archived pipelines. Scores are written to that person property only when write_person_property is true (default false); prediction events, validation and segments work without it. iterations_per_run (default 5) sets the experiments in each training run. research_interval_days (7, 14, 30, 60 or 90, default 7; null means only when asked) sets how often scheduled research runs once the first burst of daily runs ends. After creating, call autoresearch-train-create to start an asynchronous agent training run.",+ "description": "Create a new autoresearch prediction pipeline. Always call autoresearch-validate-create first — this endpoint does not block on validation errors. The prediction target is either an event (pass target_event, e.g. '$pageview') or a PostHog action (pass target_definition = {\"type\": \"action\", \"action_id\": N} to predict a multi-step / property / autocapture matcher; target_event is then optional; it is the display label and the source of the derived output property name). An action target needs the action:read scope. horizon_days defaults to 7. The output person property (e.g. 'predicted_p_pageview') is auto-derived from target_event, or from the action name when target_event is omitted, if you do not set it. It must be unique among the project's non-archived pipelines. Scores are written to that person property only when write_person_property is true (default false); prediction events, validation and segments work without it. iterations_per_run (default 5) sets the experiments in each training run. research_interval_days (7, 14, 30, 60 or 90, default 7; null means only when asked) sets how often scheduled research runs once the first burst of daily runs ends. agent_model and agent_reasoning_effort choose the model and effort the training agent runs on; leave them out to use the autoresearch default (Claude Opus 5.5 at medium effort). A larger model or higher effort costs more per training run, and an unknown model or an effort the model does not support returns 400 with the valid choices. After creating, call autoresearch-train-create to start an asynchronous agent training run.","category": "Autoresearch","feature": "autoresearch","summary": "Create a pipeline",@@ -1274,7 +1274,7 @@"feature_flag": "autoresearch"},"autoresearch-partial-update": {- "description": "Change fields of an existing pipeline. Send only the fields to change. Use write_person_property to turn person profile writes on or off. When it is on, each live scoring run writes the champion's score to output_person_property on the people it scores, so feature flags, cohorts, workflows and insights can target people by score. Scores fill in over the next few scoring runs, not all at once. Turning it off starts a cleanup run that removes the property from the people this pipeline scored (see autoresearch-runs-list). Changing write_person_property needs the person:write scope. Prediction events, online validation and segments work with it off. Use iterations_per_run and research_interval_days to change the training schedule; null research_interval_days stops scheduled research. target_event, target_definition, horizon_days, training_lookback_days and the two populations cannot change once a model has been trained.",+ "description": "Change fields of an existing pipeline. Send only the fields to change. Use write_person_property to turn person profile writes on or off. When it is on, each live scoring run writes the champion's score to output_person_property on the people it scores, so feature flags, cohorts, workflows and insights can target people by score. Scores fill in over the next few scoring runs, not all at once. Turning it off starts a cleanup run that removes the property from the people this pipeline scored (see autoresearch-runs-list). Changing write_person_property needs the person:write scope. Prediction events, online validation and segments work with it off. Use iterations_per_run and research_interval_days to change the training schedule; null research_interval_days stops scheduled research. Use agent_model and agent_reasoning_effort to change the model the training agent runs on; null returns a field to the autoresearch default, and effective_agent_model in the response shows what the next run uses. target_event, target_definition, horizon_days, training_lookback_days and the two populations cannot change once a model has been trained.","category": "Autoresearch","feature": "autoresearch","summary": "Update a pipeline",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 6b5ab153a45f..6862993d8f53 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -1191,7 +1191,7 @@}},"autoresearch-create": {- "description": "Create a new autoresearch prediction pipeline. Always call autoresearch-validate-create first — this endpoint does not block on validation errors. The prediction target is either an event (pass target_event, e.g. '$pageview') or a PostHog action (pass target_definition = {\"type\": \"action\", \"action_id\": N} to predict a multi-step / property / autocapture matcher; target_event is then optional; it is the display label and the source of the derived output property name). An action target needs the action:read scope. horizon_days defaults to 7. The output person property (e.g. 'predicted_p_pageview') is auto-derived from target_event, or from the action name when target_event is omitted, if you do not set it. It must be unique among the project's non-archived pipelines. Scores are written to that person property only when write_person_property is true (default false); prediction events, validation and segments work without it. iterations_per_run (default 5) sets the experiments in each training run. research_interval_days (7, 14, 30, 60 or 90, default 7; null means only when asked) sets how often scheduled research runs once the first burst of daily runs ends. After creating, call autoresearch-train-create to start an asynchronous agent training run.",+ "description": "Create a new autoresearch prediction pipeline. Always call autoresearch-validate-create first — this endpoint does not block on validation errors. The prediction target is either an event (pass target_event, e.g. '$pageview') or a PostHog action (pass target_definition = {\"type\": \"action\", \"action_id\": N} to predict a multi-step / property / autocapture matcher; target_event is then optional; it is the display label and the source of the derived output property name). An action target needs the action:read scope. horizon_days defaults to 7. The output person property (e.g. 'predicted_p_pageview') is auto-derived from target_event, or from the action name when target_event is omitted, if you do not set it. It must be unique among the project's non-archived pipelines. Scores are written to that person property only when write_person_property is true (default false); prediction events, validation and segments work without it. iterations_per_run (default 5) sets the experiments in each training run. research_interval_days (7, 14, 30, 60 or 90, default 7; null means only when asked) sets how often scheduled research runs once the first burst of daily runs ends. agent_model and agent_reasoning_effort choose the model and effort the training agent runs on; leave them out to use the autoresearch default (Claude Opus 5.5 at medium effort). A larger model or higher effort costs more per training run, and an unknown model or an effort the model does not support returns 400 with the valid choices. After creating, call autoresearch-train-create to start an asynchronous agent training run.","category": "Autoresearch","feature": "autoresearch","summary": "Create a pipeline",@@ -1289,7 +1289,7 @@"feature_flag": "autoresearch"},"autoresearch-partial-update": {- "description": "Change fields of an existing pipeline. Send only the fields to change. Use write_person_property to turn person profile writes on or off. When it is on, each live scoring run writes the champion's score to output_person_property on the people it scores, so feature flags, cohorts, workflows and insights can target people by score. Scores fill in over the next few scoring runs, not all at once. Turning it off starts a cleanup run that removes the property from the people this pipeline scored (see autoresearch-runs-list). Changing write_person_property needs the person:write scope. Prediction events, online validation and segments work with it off. Use iterations_per_run and research_interval_days to change the training schedule; null research_interval_days stops scheduled research. target_event, target_definition, horizon_days, training_lookback_days and the two populations cannot change once a model has been trained.",+ "description": "Change fields of an existing pipeline. Send only the fields to change. Use write_person_property to turn person profile writes on or off. When it is on, each live scoring run writes the champion's score to output_person_property on the people it scores, so feature flags, cohorts, workflows and insights can target people by score. Scores fill in over the next few scoring runs, not all at once. Turning it off starts a cleanup run that removes the property from the people this pipeline scored (see autoresearch-runs-list). Changing write_person_property needs the person:write scope. Prediction events, online validation and segments work with it off. Use iterations_per_run and research_interval_days to change the training schedule; null research_interval_days stops scheduled research. Use agent_model and agent_reasoning_effort to change the model the training agent runs on; null returns a field to the autoresearch default, and effective_agent_model in the response shows what the next run uses. target_event, target_definition, horizon_days, training_lookback_days and the two populations cannot change once a model has been trained.","category": "Autoresearch","feature": "autoresearch","summary": "Update a pipeline",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 4443c5ee95d1..1d229f09f2ec 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -11699,6 +11699,43 @@ export namespace Schemas {CustomerAnalytics: 'customer_analytics',} as const;+ export interface AgentReasoningEffortOption {+ /** Effort id to pass as agent_reasoning_effort, e.g. 'medium'. */+ value: string;+ /** Display name, e.g. 'Medium'. */+ label: string;+ }++ export interface AgentModelOption {+ /** Model id to pass as agent_model, e.g. 'claude-sonnet-5-5'. */+ model: string;+ /** Display name, e.g. 'Claude Sonnet 5.5'. */+ label: string;+ /** Runtime that drives the model: 'claude' or 'codex'. */+ runtime_adapter: string;+ /** Reasoning efforts this model supports. Empty when it has no effort setting. */+ supported_efforts: AgentReasoningEffortOption[];+ /**+ * Token price relative to Claude Sonnet 5, e.g. '2×'. Null when no rate is known.+ * @nullable+ */+ cost_multiplier: string | null;+ }++ export interface AgentModelOptions {+ /** Model a pipeline with a null agent_model trains on. */+ default_model: string;+ /** Display name of default_model. */+ default_model_label: string;+ /**+ * Reasoning effort a pipeline with a null agent_reasoning_effort trains at.+ * @nullable+ */+ default_reasoning_effort: string | null;+ /** Models a pipeline may set as agent_model. */+ models: AgentModelOption[];+ }+export interface AggregatedSpanRow {avg_duration_nano: number;count: number;@@ -14184,6 +14221,23 @@ export namespace Schemas {* * `60` - 60* * `90` - 90 */readonly research_interval_days: ResearchIntervalDaysEnum | null;+ /**+ * Model the training agent runs on, as set on this pipeline. Null uses the autoresearch default.+ * @nullable+ */+ readonly agent_model: string | null;+ /**+ * Reasoning effort for the training agent, as set on this pipeline. Null uses the autoresearch default.+ * @nullable+ */+ readonly agent_reasoning_effort: string | null;+ /** Model the next training run uses: agent_model, or the autoresearch default when that is null. */+ readonly effective_agent_model: string;+ /**+ * Reasoning effort the next training run uses: agent_reasoning_effort, or the autoresearch default when that is null. Null when the model has no effort setting.+ * @nullable+ */+ readonly effective_agent_reasoning_effort: string | null;/** explore: a research run on each scoring day until a run does not promote a better model, or until 5 research runs have run. maintain: one research run every research_interval_days.** * `explore` - Explore@@ -14364,6 +14418,18 @@ export namespace Schemas {* * `60` - 60* * `90` - 90 */research_interval_days?: ResearchIntervalDaysEnum | null;+ /**+ * Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it.+ * @maxLength 100+ * @nullable+ */+ agent_model?: string | null;+ /**+ * Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run.+ * @maxLength 20+ * @nullable+ */+ agent_reasoning_effort?: string | null;/*** Target AUC threshold (0-1). Training stops early if reached. Default: 0.75.* @minimum 0@@ -14701,6 +14767,26 @@ export namespace Schemas {* * `rescue` - Rescue* * `manual` - Manual */readonly kickoff_reason: AutoresearchTrainingRunKickoffReasonEnum | null;+ /**+ * Runtime that drove the training agent, 'claude' or 'codex'. Null for older runs and runs with no task.+ * @nullable+ */+ readonly agent_runtime_adapter: string | null;+ /**+ * Model the training agent ran on. Null for older runs and runs with no task.+ * @nullable+ */+ readonly agent_model: string | null;+ /**+ * Display name of agent_model, e.g. 'Claude Opus 5.5'. Null when agent_model is null.+ * @nullable+ */+ readonly agent_model_label: string | null;+ /**+ * Reasoning effort the training agent ran at. Null for older runs, runs with no task, and models with no effort setting.+ * @nullable+ */+ readonly agent_reasoning_effort: string | null;/*** Maximum iterations allowed for this run.* @minimum -2147483648@@ -80500,6 +80586,18 @@ export namespace Schemas {* * `60` - 60* * `90` - 90 */research_interval_days?: ResearchIntervalDaysEnum | null;+ /**+ * Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it.+ * @maxLength 100+ * @nullable+ */+ agent_model?: string | null;+ /**+ * Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run.+ * @maxLength 20+ * @nullable+ */+ agent_reasoning_effort?: string | null;/*** Target AUC threshold (0-1). Training stops early if reached. Default: 0.75.* @minimum 0diff --git a/services/mcp/src/generated/autoresearch/api.ts b/services/mcp/src/generated/autoresearch/api.tsindex d1816a99038b..8e63e401cde9 100644--- a/services/mcp/src/generated/autoresearch/api.ts+++ b/services/mcp/src/generated/autoresearch/api.ts@@ -58,6 +58,10 @@ export const autoresearchCreateBodyIterationBudgetMax = 500export const autoresearchCreateBodyIterationsPerRunMax = 50+export const autoresearchCreateBodyAgentModelMax = 100++export const autoresearchCreateBodyAgentReasoningEffortMax = 20+export const autoresearchCreateBodySuccessAucMin = 0export const autoresearchCreateBodySuccessAucMax = 1@@ -148,6 +152,20 @@ export const AutoresearchCreateBody = () => zod.object({.describe('Days between scheduled research runs once the first burst of daily runs ends: 7, 14, 30, 60 or 90. Null means only when asked: no scheduled research, so the only training cost comes from runs you start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7.\n\n\* `7` - 7\n\* `14` - 14\n\* `30` - 30\n\* `60` - 60\n\* `90` - 90'),+ agent_model: zod+ .string()+ .max(autoresearchCreateBodyAgentModelMax)+ .nullish()+ .describe(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ agent_reasoning_effort: zod+ .string()+ .max(autoresearchCreateBodyAgentReasoningEffortMax)+ .nullish()+ .describe(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run."+ ),success_auc: zod.number().min(autoresearchCreateBodySuccessAucMin)@@ -776,6 +794,10 @@ export const autoresearchPartialUpdateBodyIterationBudgetMax = 500export const autoresearchPartialUpdateBodyIterationsPerRunMax = 50+export const autoresearchPartialUpdateBodyAgentModelMax = 100++export const autoresearchPartialUpdateBodyAgentReasoningEffortMax = 20+export const autoresearchPartialUpdateBodySuccessAucMin = 0export const autoresearchPartialUpdateBodySuccessAucMax = 1@@ -866,6 +888,20 @@ export const AutoresearchPartialUpdateBody = () => zod.object({.describe('Days between scheduled research runs once the first burst of daily runs ends: 7, 14, 30, 60 or 90. Null means only when asked: no scheduled research, so the only training cost comes from runs you start and from rescue runs for a model that cannot score. A shorter interval costs more. Default: 7.\n\n\* `7` - 7\n\* `14` - 14\n\* `30` - 30\n\* `60` - 60\n\* `90` - 90'),+ agent_model: zod+ .string()+ .max(autoresearchPartialUpdateBodyAgentModelMax)+ .nullish()+ .describe(+ "Model the training agent runs on, a model id from the PostHog Tasks catalogue such as 'claude-opus-5-5', 'claude-sonnet-5-5' or 'gpt-6.1-sol'. Null or omitted uses the autoresearch default, Claude Opus 5.5. A larger model costs more per training run. Scheduled runs and Train now use it."+ ),+ agent_reasoning_effort: zod+ .string()+ .max(autoresearchPartialUpdateBodyAgentReasoningEffortMax)+ .nullish()+ .describe(+ "Reasoning effort for the training agent, such as 'low', 'medium' or 'high'. It must be one the model supports, and without agent_model it is checked against the default model. Null or omitted uses the autoresearch default, medium. Higher effort costs more per training run."+ ),success_auc: zod.number().min(autoresearchPartialUpdateBodySuccessAucMin)diff --git a/services/mcp/src/tools/generated/autoresearch.ts b/services/mcp/src/tools/generated/autoresearch.tsindex a48ec4ea51d0..620a44727aa9 100644--- a/services/mcp/src/tools/generated/autoresearch.ts+++ b/services/mcp/src/tools/generated/autoresearch.ts@@ -56,6 +56,12 @@ const autoresearchCreate = (): ToolBase<if (params.research_interval_days !== undefined) {body['research_interval_days'] = params.research_interval_days}+ if (params.agent_model !== undefined) {+ body['agent_model'] = params.agent_model+ }+ if (params.agent_reasoning_effort !== undefined) {+ body['agent_reasoning_effort'] = params.agent_reasoning_effort+ }if (params.success_auc !== undefined) {body['success_auc'] = params.success_auc}@@ -110,6 +116,8 @@ const autoresearchList = (): ToolBase<'status','iterations_per_run','research_interval_days',+ 'effective_agent_model',+ 'effective_agent_reasoning_effort','training_phase','next_research_at','last_scored_at',@@ -301,6 +309,12 @@ const autoresearchPartialUpdate = (): ToolBase<if (params.research_interval_days !== undefined) {body['research_interval_days'] = params.research_interval_days}+ if (params.agent_model !== undefined) {+ body['agent_model'] = params.agent_model+ }+ if (params.agent_reasoning_effort !== undefined) {+ body['agent_reasoning_effort'] = params.agent_reasoning_effort+ }if (params.success_auc !== undefined) {body['success_auc'] = params.success_auc}@@ -901,6 +915,8 @@ const autoresearchTrainingRunsList = (): ToolBase<'pipeline','status','kickoff_reason',+ 'agent_model',+ 'agent_reasoning_effort','iteration_budget','iteration_count','best_holdout_score',