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.

chore(signals): support specifying harness for implementation tasks (#69833)

Joshua Snyderc0067304c314
diff --git a/products/signals/backend/agent_runtime.py b/products/signals/backend/agent_runtime.py
index c2d2eb6d4a86..9ebf81dee4af 100644
--- a/products/signals/backend/agent_runtime.py
+++ b/products/signals/backend/agent_runtime.py
@@ -61,6 +61,7 @@ WILDCARD = "*"
STEP_SCOUT = "scout"
STEP_RESEARCH = "research"
STEP_REPO_SELECTION = "repo_selection"
+STEP_IMPLEMENTATION = "implementation"
STEP_CUSTOM_AGENT = "custom_agent"
diff --git a/products/signals/backend/auto_start.py b/products/signals/backend/auto_start.py
index a94764da4879..06200ca2117e 100644
--- a/products/signals/backend/auto_start.py
+++ b/products/signals/backend/auto_start.py
@@ -12,6 +12,7 @@ from posthog.models import Team, User
from posthog.models.organization import OrganizationMembership
from posthog.sync import database_sync_to_async
+from products.signals.backend.agent_runtime import STEP_IMPLEMENTATION, resolve_agent_runtime
from products.signals.backend.models import (
SignalReport,
SignalReportArtefact,
@@ -130,6 +131,9 @@ def _create_implementation_task_if_absent(
returns ``False``. Returns ``True`` if it created the task, ``False`` if one already exists / the
report is gone.
"""
+ # Resolved outside the transaction: the flag read does network I/O and must not hold the row lock.
+ agent_runtime = resolve_agent_runtime(team_id, STEP_IMPLEMENTATION)
+
with transaction.atomic():
report = SignalReport.objects.select_for_update().filter(id=report_id, team_id=team_id).first()
if report is None:
@@ -163,6 +167,9 @@ def _create_implementation_task_if_absent(
ai_stage="implementation",
# Internal so the run stays out of the default task list; the report surfaces it by id.
internal=True,
+ runtime_adapter=agent_runtime.runtime_adapter,
+ model=agent_runtime.model,
+ reasoning_effort=agent_runtime.reasoning_effort,
)
if created.latest_run is None:
raise RuntimeError(f"Task {created.task_id} auto-started without producing a TaskRun")
diff --git a/products/signals/backend/test/test_auto_start.py b/products/signals/backend/test/test_auto_start.py
index 32af119b0b64..1b26d187c3c2 100644
--- a/products/signals/backend/test/test_auto_start.py
+++ b/products/signals/backend/test/test_auto_start.py
@@ -10,6 +10,7 @@ from social_django.models import UserSocialAuth
from posthog.models import Organization, Team, User
from posthog.models.organization import OrganizationMembership
+from products.signals.backend.agent_runtime import AgentRuntime
from products.signals.backend.auto_start import (
ReviewerContent,
_create_implementation_task_if_absent,
@@ -253,3 +254,45 @@ def test_create_implementation_task_if_absent_is_idempotent(organization, team):
SignalReportArtefact.objects.filter(report=report, type=SignalReportArtefact.ArtefactType.TASK_RUN).count() == 1
)
assert signals_task_ids(report_id=str(report.id), type=TASK_RUN_TYPE_IMPLEMENTATION) == [str(created_tasks[0].id)]
+
+
+def test_create_implementation_task_threads_resolved_runtime(organization, team):
+ Task = apps.get_model("tasks", "Task")
+ TaskRun = apps.get_model("tasks", "TaskRun")
+ user = _create_org_member_with_github("[email protected]", organization, "OctoCat")
+ report = SignalReport.objects.create(
+ team=team, status=SignalReport.Status.READY, title="t", summary="s", signal_count=0, total_weight=0.0
+ )
+
+ def _fake_create_and_run_task(**kwargs):
+ task = Task.objects.create(
+ team=team,
+ title=kwargs["title"],
+ description=kwargs["description"],
+ created_by=user,
+ origin_product=Task.OriginProduct.SIGNAL_REPORT,
+ )
+ run = TaskRun.objects.create(task=task, team=team)
+ return SimpleNamespace(task_id=task.id, team_id=team.id, latest_run=SimpleNamespace(id=run.id))
+
+ kwargs = {
+ "team_id": team.id,
+ "report_id": str(report.id),
+ "title": "t",
+ "description": "d",
+ "user_id": user.id,
+ "repository": "owner/repo",
+ "base_branch": None,
+ }
+ pinned = AgentRuntime(runtime_adapter="codex", model="gpt-5.6-terra", reasoning_effort="medium")
+ with (
+ patch.object(tasks_facade, "create_and_run_task", side_effect=_fake_create_and_run_task) as mock_create,
+ patch("products.signals.backend.auto_start.resolve_agent_runtime", return_value=pinned),
+ ):
+ _create_implementation_task_if_absent(**kwargs)
+
+ call_kwargs = mock_create.call_args.kwargs
+ assert call_kwargs["runtime_adapter"] == "codex"
+ assert call_kwargs["model"] == "gpt-5.6-terra"
+ assert call_kwargs["reasoning_effort"] == "medium"