Skip to content

: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.

fix(autoresearch): record the model each training run used (#125959)

posthog[bot]fd108f404204
diff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.py
index 923718833797..9d78e65959b4 100644
--- a/posthog/hogql/database/schema/system.py
+++ b/posthog/hogql/database/schema/system.py
@@ -1074,6 +1074,16 @@ autoresearch_pipelines: PostgresTable = PostgresTable(
"iteration_budget": IntegerDatabaseField(
name="iteration_budget", description="Maximum training iterations the agent loop may spend."
),
+ "agent_model": StringDatabaseField(
+ name="agent_model",
+ nullable=True,
+ description="Model override for the training agent (NULL uses the autoresearch default model).",
+ ),
+ "agent_reasoning_effort": StringDatabaseField(
+ name="agent_reasoning_effort",
+ nullable=True,
+ description="Reasoning effort override for the training agent (NULL uses the autoresearch default).",
+ ),
"iteration_budget_remaining": IntegerDatabaseField(
name="iteration_budget_remaining",
nullable=True,
@@ -1109,6 +1119,26 @@ autoresearch_training_runs: PostgresTable = PostgresTable(
name="task_run_id", nullable=True, description="Task run of the agent sandbox; joins to task_runs.id."
),
"status": StringDatabaseField(name="status", description="One of pending, running, completed, failed."),
+ "kickoff_reason": StringDatabaseField(
+ name="kickoff_reason",
+ nullable=True,
+ description="Why the run started: explore, scheduled, rescue, or manual (NULL for older runs).",
+ ),
+ "agent_runtime_adapter": StringDatabaseField(
+ name="agent_runtime_adapter",
+ nullable=True,
+ description="Agent runtime the run was dispatched with, for example claude or codex (NULL for older runs).",
+ ),
+ "agent_model": StringDatabaseField(
+ name="agent_model",
+ nullable=True,
+ description="Model the training agent ran on, for example claude-opus-5-5 (NULL for older runs).",
+ ),
+ "agent_reasoning_effort": StringDatabaseField(
+ name="agent_reasoning_effort",
+ nullable=True,
+ description="Reasoning effort the training agent ran with (NULL for older runs or when the model has none).",
+ ),
"iteration_budget": IntegerDatabaseField(
name="iteration_budget", description="Maximum iterations the run may record."
),
diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambr
index 0908cc96bd17..ceadba403c64 100644
--- a/posthog/hogql/database/test/__snapshots__/test_database.ambr
+++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr
@@ -14193,6 +14193,26 @@
"table": null,
"type": "integer"
},
+ "agent_model": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_model",
+ "id": null,
+ "name": "agent_model",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_reasoning_effort": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_reasoning_effort",
+ "id": null,
+ "name": "agent_reasoning_effort",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
"iteration_budget_remaining": {
"chain": null,
"fields": null,
@@ -14302,6 +14322,46 @@
"table": null,
"type": "string"
},
+ "kickoff_reason": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "kickoff_reason",
+ "id": null,
+ "name": "kickoff_reason",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_runtime_adapter": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_runtime_adapter",
+ "id": null,
+ "name": "agent_runtime_adapter",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_model": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_model",
+ "id": null,
+ "name": "agent_model",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_reasoning_effort": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_reasoning_effort",
+ "id": null,
+ "name": "agent_reasoning_effort",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
"iteration_budget": {
"chain": null,
"fields": null,
@@ -28861,6 +28921,26 @@
"table": null,
"type": "integer"
},
+ "agent_model": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_model",
+ "id": null,
+ "name": "agent_model",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_reasoning_effort": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_reasoning_effort",
+ "id": null,
+ "name": "agent_reasoning_effort",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
"iteration_budget_remaining": {
"chain": null,
"fields": null,
@@ -28970,6 +29050,46 @@
"table": null,
"type": "string"
},
+ "kickoff_reason": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "kickoff_reason",
+ "id": null,
+ "name": "kickoff_reason",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_runtime_adapter": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_runtime_adapter",
+ "id": null,
+ "name": "agent_runtime_adapter",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_model": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_model",
+ "id": null,
+ "name": "agent_model",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
+ "agent_reasoning_effort": {
+ "chain": null,
+ "fields": null,
+ "hogql_value": "agent_reasoning_effort",
+ "id": null,
+ "name": "agent_reasoning_effort",
+ "schema_valid": true,
+ "table": null,
+ "type": "string"
+ },
"iteration_budget": {
"chain": null,
"fields": null,
diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.py
index 1725b5ca17b4..0655210ba011 100644
--- a/products/tasks/backend/models.py
+++ b/products/tasks/backend/models.py
@@ -1060,6 +1060,10 @@ class Task(Taggable, DeletedMetaFields, models.Model):
"startup_requested_at": startup_requested_at.isoformat(),
"startup_run_created_at": task_run.created_at.isoformat(),
"startup_scheduled_at": scheduled_at.isoformat() if scheduled_at else None,
+ # NULL when the caller pinned nothing and the run takes the Tasks default.
+ "model": state.get("model"),
+ "runtime_adapter": state.get("runtime_adapter"),
+ "reasoning_effort": state.get("reasoning_effort"),
},
)
diff --git a/products/tasks/backend/tests/test_task_run_metrics.py b/products/tasks/backend/tests/test_task_run_metrics.py
index a8853a8f5e0a..96cd52735be2 100644
--- a/products/tasks/backend/tests/test_task_run_metrics.py
+++ b/products/tasks/backend/tests/test_task_run_metrics.py
@@ -196,12 +196,18 @@ class TestTaskRunMetrics(TestCase):
):
self.task.create_run(
environment=TaskRun.Environment.CLOUD,
- extra_state={"run_source": "manual", "runtime_adapter": "codex"},
+ extra_state={"run_source": "manual", "runtime_adapter": "codex", "model": "gpt-5.5"},
)
assert _sample_value("posthog_tasks_task_run_created_total", labels) == before + 1
created_event = next(call for call in capture.call_args_list if call.kwargs.get("event") == "task_run_created")
assert created_event.kwargs["send_feature_flags"] is False
+ properties = created_event.kwargs["properties"]
+ assert (properties["model"], properties["runtime_adapter"], properties["reasoning_effort"]) == (
+ "gpt-5.5",
+ "codex",
+ None,
+ )
def test_create_run_bounds_unexpected_state_labels(self) -> None:
labels = {