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(tasks): reuse prewarm across reasoning changes (#81681)

Alessandro Pogliaghieffe3eab2bed
diff --git a/products/desktop/packages/agent/src/server/agent-server.test.ts b/products/desktop/packages/agent/src/server/agent-server.test.ts
index d3fc462a727c..4c3dbb2851c9 100644
--- a/products/desktop/packages/agent/src/server/agent-server.test.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.test.ts
@@ -4345,19 +4345,28 @@ describe("AgentServer HTTP Mode", () => {
// resolved from run state when the first message arrives.
type WarmTestable = {
prewarmedRun: boolean;
- session: { payload: { task_id: string; run_id: string } } | null;
+ session: {
+ payload: { task_id: string; run_id: string };
+ acpSessionId: string;
+ clientConnection: {
+ setSessionConfigOption: ReturnType<typeof vi.fn>;
+ };
+ } | null;
posthogAPI: { getTaskRun: ReturnType<typeof vi.fn> };
- resolveWarmAutoPublishUpgrade(): Promise<string | null>;
+ resolveWarmActivationSettings(): Promise<string | null>;
buildCloudSystemPrompt(): string;
};
const makeWarmServer = (
state: Record<string, unknown> | Error,
overrides: Partial<ConstructorParameters<typeof AgentServer>[0]> = {},
+ setSessionConfigOption = vi.fn(async () => ({ configOptions: [] })),
): WarmTestable => {
const t = createServer(overrides) as unknown as WarmTestable;
t.prewarmedRun = true;
t.session = {
payload: { task_id: "test-task-id", run_id: "test-run-id" },
+ acpSessionId: "test-session-id",
+ clientConnection: { setSessionConfigOption },
};
t.posthogAPI = {
getTaskRun:
@@ -4370,27 +4379,65 @@ describe("AgentServer HTTP Mode", () => {
return t;
};
+ it("applies activation-time reasoning before a prewarmed run's first turn", async () => {
+ const setSessionConfigOption = vi.fn(async () => ({ configOptions: [] }));
+ const t = createServer({ reasoningEffort: "high" }) as unknown as {
+ prewarmedRun: boolean;
+ session: {
+ payload: { task_id: string; run_id: string };
+ acpSessionId: string;
+ clientConnection: {
+ setSessionConfigOption: typeof setSessionConfigOption;
+ };
+ };
+ posthogAPI: { getTaskRun: ReturnType<typeof vi.fn> };
+ resolveWarmActivationSettings(): Promise<string | null>;
+ };
+ t.prewarmedRun = true;
+ t.session = {
+ payload: { task_id: "test-task-id", run_id: "test-run-id" },
+ acpSessionId: "test-session-id",
+ clientConnection: { setSessionConfigOption },
+ };
+ t.posthogAPI = {
+ getTaskRun: vi.fn(async () => ({
+ state: { prewarmed: true, reasoning_effort: "xhigh" },
+ })),
+ };
+
+ await t.resolveWarmActivationSettings();
+ await t.resolveWarmActivationSettings();
+
+ expect(setSessionConfigOption).toHaveBeenCalledOnce();
+ expect(setSessionConfigOption).toHaveBeenCalledWith({
+ sessionId: "test-session-id",
+ configId: "effort",
+ value: "xhigh",
+ });
+ expect(t.posthogAPI.getTaskRun).toHaveBeenCalledOnce();
+ });
+
it("upgrades a prewarmed run to auto-publish from run state on the first message", async () => {
const t = makeWarmServer({ prewarmed: true, auto_publish: true });
- const override = await t.resolveWarmAutoPublishUpgrade();
+ const override = await t.resolveWarmActivationSettings();
expect(override).toContain("OVERRIDE PREVIOUS INSTRUCTIONS");
expect(override).toContain("gh pr create --draft");
// The flip persists for the rest of the session...
expect(t.buildCloudSystemPrompt()).toContain("gh pr create --draft");
// ...and the override is injected only once.
- expect(await t.resolveWarmAutoPublishUpgrade()).toBeNull();
+ expect(await t.resolveWarmActivationSettings()).toBeNull();
expect(t.posthogAPI.getTaskRun).toHaveBeenCalledTimes(1);
});
it("keeps a prewarmed run review-first when run state has no auto_publish", async () => {
const t = makeWarmServer({ prewarmed: true });
- expect(await t.resolveWarmAutoPublishUpgrade()).toBeNull();
+ expect(await t.resolveWarmActivationSettings()).toBeNull();
expect(t.buildCloudSystemPrompt()).toContain(
"stop with local changes ready for review",
);
- expect(await t.resolveWarmAutoPublishUpgrade()).toBeNull();
+ expect(await t.resolveWarmActivationSettings()).toBeNull();
expect(t.posthogAPI.getTaskRun).toHaveBeenCalledTimes(1);
});
@@ -4402,8 +4449,8 @@ describe("AgentServer HTTP Mode", () => {
{ createPr: false },
);
- expect(await t.resolveWarmAutoPublishUpgrade()).toBeNull();
- expect(t.posthogAPI.getTaskRun).not.toHaveBeenCalled();
+ expect(await t.resolveWarmActivationSettings()).toBeNull();
+ expect(t.posthogAPI.getTaskRun).toHaveBeenCalledOnce();
expect(t.buildCloudSystemPrompt()).toContain(
"stop with local changes ready for review",
);
@@ -4411,16 +4458,34 @@ describe("AgentServer HTTP Mode", () => {
it("retries the state fetch on a later message when it fails", async () => {
const t = makeWarmServer(new Error("fetch failed"));
- expect(await t.resolveWarmAutoPublishUpgrade()).toBeNull();
+ expect(await t.resolveWarmActivationSettings()).toBeNull();
t.posthogAPI.getTaskRun = vi.fn(async () => ({
state: { prewarmed: true, auto_publish: true },
}));
- expect(await t.resolveWarmAutoPublishUpgrade()).toContain(
+ expect(await t.resolveWarmActivationSettings()).toContain(
"gh pr create --draft",
);
});
+ it("retries reasoning configuration without blocking the first prompt", async () => {
+ const setSessionConfigOption = vi
+ .fn()
+ .mockRejectedValueOnce(new Error("adapter unavailable"))
+ .mockResolvedValueOnce({ configOptions: [] });
+ const t = makeWarmServer(
+ { prewarmed: true, reasoning_effort: "xhigh" },
+ { reasoningEffort: "high" },
+ setSessionConfigOption,
+ );
+
+ await expect(t.resolveWarmActivationSettings()).resolves.toBeNull();
+ await expect(t.resolveWarmActivationSettings()).resolves.toBeNull();
+
+ expect(setSessionConfigOption).toHaveBeenCalledTimes(2);
+ expect(t.posthogAPI.getTaskRun).toHaveBeenCalledTimes(2);
+ });
+
it.each([
{ label: "Slack", origin: "slack" },
{ label: "signal_report", origin: "signal_report" },
diff --git a/products/desktop/packages/agent/src/server/agent-server.ts b/products/desktop/packages/agent/src/server/agent-server.ts
index 42b487cbce6f..afa3230e4866 100644
--- a/products/desktop/packages/agent/src/server/agent-server.ts
+++ b/products/desktop/packages/agent/src/server/agent-server.ts
@@ -412,9 +412,10 @@ export class AgentServer {
private oversizedResumeRetried = false;
// Prewarmed runs boot before the user's first message exists, so the boot-time
// --autoPublish flag can't carry the user's choice; it is resolved from run
- // state when the first message arrives (see resolveWarmAutoPublishUpgrade).
+ // state when the first message arrives (see resolveWarmActivationSettings).
private prewarmedRun = false;
private warmAutoPublishResolved = false;
+ private warmReasoningEffortResolved = false;
private installedSkillBundles = new Set<string>();
private installedSkillBundleInfo = new Map<string, InstalledSkillBundle>();
private installingSkillBundles = new Map<string, Promise<void>>();
@@ -1167,9 +1168,12 @@ export class AgentServer {
`Processing user message (detectedPrUrl=${this.detectedPrUrl ?? "none"}): ${promptPreview.substring(0, 100)}...`,
);
+ // Apply activation-time settings before the warmed agent sees its
+ // first prompt. The sandbox and session can be prepared with one
+ // effort while the final composer selection uses another.
// Resolve before buildDetectedPrContext so a warm auto-publish upgrade
// also flips the detected-PR context to its push variant.
- const autoPublishUpgrade = await this.resolveWarmAutoPublishUpgrade();
+ const autoPublishUpgrade = await this.resolveWarmActivationSettings();
const hostContext = [
...(autoPublishUpgrade ? [autoPublishUpgrade] : []),
...(this.detectedPrUrl
@@ -1566,6 +1570,7 @@ export class AgentServer {
this.preSessionEvents = [];
this.prewarmedRun = false;
this.warmAutoPublishResolved = false;
+ this.warmReasoningEffortResolved = false;
this.logger.debug("Initializing session", {
runId: payload.run_id,
@@ -3472,6 +3477,66 @@ export class AgentServer {
);
}
+ /** Apply activation-time settings before a prewarmed session's first turn. */
+ private async resolveWarmActivationSettings(): Promise<string | null> {
+ if (!this.prewarmedRun || !this.session) {
+ return null;
+ }
+ if (this.warmReasoningEffortResolved && this.warmAutoPublishResolved) {
+ return null;
+ }
+
+ let state: Record<string, unknown> | undefined;
+ try {
+ const run = await this.posthogAPI.getTaskRun(
+ this.session.payload.task_id,
+ this.session.payload.run_id,
+ );
+ state = run?.state as Record<string, unknown> | undefined;
+ } catch (error) {
+ // Keep both settings unresolved so a later message retries. A transient
+ // control-plane failure must not prevent the first prompt from running.
+ this.logger.debug("Failed to fetch warm activation settings", { error });
+ return null;
+ }
+
+ await this.resolveWarmReasoningEffort(state);
+ return this.resolveWarmAutoPublishUpgrade(state);
+ }
+
+ private async resolveWarmReasoningEffort(
+ state: Record<string, unknown> | undefined,
+ ): Promise<void> {
+ if (this.warmReasoningEffortResolved || !this.session) {
+ return;
+ }
+
+ const reasoningEffort = state?.reasoning_effort;
+ if (typeof reasoningEffort === "string" && reasoningEffort.length > 0) {
+ try {
+ await this.session.clientConnection.setSessionConfigOption({
+ sessionId: this.session.acpSessionId,
+ configId: "effort",
+ value: reasoningEffort,
+ });
+ } catch (error) {
+ // Keep this unresolved so a later message retries, but continue with
+ // the effort used to start the warm session for the current prompt.
+ this.logger.warn("Failed to apply warm activation reasoning effort", {
+ error,
+ reasoningEffort,
+ });
+ return;
+ }
+ this.config.reasoningEffort =
+ reasoningEffort as AgentServerConfig["reasoningEffort"];
+ this.logger.debug("Applied warm activation reasoning effort", {
+ reasoningEffort,
+ });
+ }
+ this.warmReasoningEffortResolved = true;
+ }
+
/**
* A prewarmed run boots before the user's first message exists, so the
* --autoPublish flag can't carry the user's choice; the backend persists it
@@ -3481,8 +3546,10 @@ export class AgentServer {
* buildDetectedPrContext see it) and return the auto-publish cloud
* instructions to inject into the first prompt as an override.
*/
- private async resolveWarmAutoPublishUpgrade(): Promise<string | null> {
- if (!this.prewarmedRun || this.warmAutoPublishResolved || !this.session) {
+ private resolveWarmAutoPublishUpgrade(
+ state: Record<string, unknown> | undefined,
+ ): string | null {
+ if (this.warmAutoPublishResolved) {
return null;
}
if (
@@ -3494,20 +3561,6 @@ export class AgentServer {
this.warmAutoPublishResolved = true;
return null;
}
- let state: Record<string, unknown> | undefined;
- try {
- const run = await this.posthogAPI.getTaskRun(
- this.session.payload.task_id,
- this.session.payload.run_id,
- );
- state = run?.state as Record<string, unknown> | undefined;
- } catch (error) {
- // Leave unresolved so the next message retries; stay review-first for now.
- this.logger.debug("Failed to fetch run state for auto-publish upgrade", {
- error,
- });
- return null;
- }
this.warmAutoPublishResolved = true;
if (state?.auto_publish !== true) {
return null;
diff --git a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx
index cf8b81ba41c1..9f279bbe9b7a 100644
--- a/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/hooks/useWarmTask.test.tsx
@@ -288,6 +288,37 @@ describe("useWarmTask", () => {
expect(mockClient.warmTask).toHaveBeenCalledTimes(2);
});
+ it("keeps the warm lease when only reasoning effort changes", async () => {
+ const { rerender } = renderHook((props: Props) => useWarmTask(props), {
+ initialProps: {
+ ...cloudTyping,
+ runtimeAdapter: "codex",
+ model: "gpt-5.6-sol",
+ reasoningEffort: "high",
+ },
+ });
+ await flushDebounce();
+
+ rerender({
+ ...cloudTyping,
+ runtimeAdapter: "codex",
+ model: "gpt-5.6-sol",
+ reasoningEffort: "xhigh",
+ });
+ await flushDebounce();
+
+ expect(mockClient.warmTask).toHaveBeenCalledOnce();
+ expect(
+ takeWarmTaskLease({
+ repository: "acme/repo",
+ branch: "main",
+ runtimeAdapter: "codex",
+ model: "gpt-5.6-sol",
+ reasoningEffort: "xhigh",
+ }),
+ ).toEqual({ taskId: "task-1", runId: "run-1" });
+ });
+
it("forwards sandbox configuration and re-warms when the image changes", async () => {
const { rerender } = renderHook((props: Props) => useWarmTask(props), {
initialProps: {
diff --git a/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts b/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts
index 48394687a1f3..7784b440d758 100644
--- a/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts
+++ b/products/desktop/packages/ui/src/features/task-detail/hooks/warmTaskLease.ts
@@ -22,7 +22,6 @@ export function buildWarmTaskLeaseKey(parts: WarmTaskLeaseKeyParts): string {
parts.branch ?? "",
parts.runtimeAdapter ?? "",
parts.model ?? "",
- parts.reasoningEffort ?? "",
parts.sandboxEnvironmentId ?? "",
parts.customImageId ?? "",
].join(":");
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index 6806e6360ef4..45f835acd26b 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -4706,6 +4706,7 @@ def create_task(
description=description or None,
artifact_ids=pending_user_artifact_ids,
auto_publish=warm_auto_publish,
+ reasoning_effort=warm_reasoning_effort,
)
return _task_detail_to_dto(_task_detail_queryset().get(pk=warm_task.pk))
@@ -5038,8 +5039,9 @@ def _find_idling_warm_run(
live Run instead of spawning a second) and lets the normal create+run path transparently reuse a
warm Run on submit. Team + user scoped; branch compared as ``None``-normalized exact match.
- Reuse also requires the warm Run's runtime, sandbox environment, and custom image selections to
- match the request. A mismatch returns ``None`` so the caller cold-creates on the correct sandbox.
+ Reuse also requires the warm Run's runtime, model, sandbox environment, and custom image selections to
+ match the request. Reasoning effort is deliberately excluded: activation applies the final effort before
+ the first turn. Other mismatches return ``None`` so the caller cold-creates on the correct sandbox.
The optional repo/branch/``await_user_message`` predicates stay in the query; the remaining selection is
matched in Python over the small candidate set.
"""
@@ -5065,7 +5067,6 @@ def _find_idling_warm_run(
wanted = (
runtime_adapter or None,
model or None,
- reasoning_effort or None,
str(sandbox_environment_id) if sandbox_environment_id else None,
str(custom_image_id) if custom_image_id else None,
)
@@ -5079,7 +5080,6 @@ def _find_idling_warm_run(
have = (
state.get("runtime_adapter") or None,
state.get("model") or None,
- state.get("reasoning_effort") or None,
state.get("sandbox_environment_id") or None,
state.get("custom_image_id") or None,
)
@@ -5158,6 +5158,7 @@ def _activate_warm_run(
artifact_ids: list[str],
description: str | None = None,
auto_publish: bool | None = None,
+ reasoning_effort: str | None = None,
) -> None:
"""Activate an idling warm Run: set the draft Task's visible description from raw task text,
forward the first message to the already-running agent, and drop the ``await_user_message`` marker
@@ -5174,10 +5175,18 @@ def _activate_warm_run(
if description and not (task.description or "").strip():
task.description = description
task.save(update_fields=["description", "updated_at"])
+ activation_state_updates: dict[str, object] = {}
if auto_publish is not None:
# Before the signal: the agent-server re-reads run state when the forwarded
# first message arrives, so the choice must already be persisted by then.
- TaskRun.update_state_atomic(run.id, updates={"auto_publish": auto_publish})
+ activation_state_updates["auto_publish"] = auto_publish
+ if reasoning_effort is not None:
+ activation_state_updates["reasoning_effort"] = reasoning_effort
+ TaskRun.update_state_atomic(
+ run.id,
+ updates=activation_state_updates,
+ remove_keys=["reasoning_effort"] if reasoning_effort is None else None,
+ )
signal_task_run_user_message(run.id, task.id, team_id, content=message, artifact_ids=artifact_ids)
TaskRun.update_state_atomic(run.id, remove_keys=["await_user_message"])
# Only count activations of Runs that actually carry the prewarmed marker, so the activation
@@ -5380,7 +5389,6 @@ def run_task(
warm_runtime_matches = (
warm_state.get("runtime_adapter") or None,
warm_state.get("model") or None,
- warm_state.get("reasoning_effort") or None,
warm_state.get("context_window") or None,
warm_state.get("fast_mode") or None,
warm_state.get("sandbox_environment_id") or None,
@@ -5388,7 +5396,6 @@ def run_task(
) == (
validated_data.get("runtime_adapter") or None,
validated_data.get("model") or None,
- validated_data.get("reasoning_effort") or None,
validated_data.get("context_window") or None,
validated_data.get("fast_mode") or None,
str(validated_data["sandbox_environment_id"]) if validated_data.get("sandbox_environment_id") else None,
@@ -5421,6 +5428,7 @@ def run_task(
description=task.description or None,
artifact_ids=pending_user_artifact_ids,
auto_publish=validated_data.get("auto_publish"),
+ reasoning_effort=validated_data.get("reasoning_effort"),
)
return contracts.TaskRunResult(task=get_task_detail(task.id, team_id, user_id))
sandbox_environment_id = validated_data.get("sandbox_environment_id")
diff --git a/products/tasks/backend/temporal/process_task/README.md b/products/tasks/backend/temporal/process_task/README.md
index 94b63a4e6479..20f93dcd575c 100644
--- a/products/tasks/backend/temporal/process_task/README.md
+++ b/products/tasks/backend/temporal/process_task/README.md
@@ -52,7 +52,7 @@ User ─────────────────────────
### PostHog API
-`backend/presentation/views/api.py` (thin viewsets) over `backend/facade/api.py` (behavior) — every user-triggered cloud launch path, including prewarming and task automations, checks server-side PostHog Desktop access before provisioning or activating a run. Composer prewarming carries the complete ordered repository selection, so single- and multi-repository submissions can reuse only an exact matching sandbox. Scheduled automations repeat the entitlement check at execution time so revoked access cannot launch later. `TaskViewSet.run` creates a `TaskRun` (status=QUEUED) and starts the Temporal workflow. `TaskRunViewSet.partial_update` handles status transitions and signals the Temporal workflow on terminal statuses via `signal_workflow_completion`. `TaskRunViewSet.cancel` (`POST .../runs/{id}/cancel/`) is the user-facing kill switch: `cancel_task_run` interrupts the in-flight agent turn, signals `complete_task("cancelled")` so the workflow snapshots the session and tears down the sandbox, and falls back to finalizing the run directly when no workflow is running.
+`backend/presentation/views/api.py` (thin viewsets) over `backend/facade/api.py` (behavior) — every user-triggered cloud launch path, including prewarming and task automations, checks server-side PostHog Desktop access before provisioning or activating a run. Composer prewarming carries the complete ordered repository selection, so single- and multi-repository submissions can reuse only a matching sandbox. Runtime, model, branch, and sandbox configuration must match; reasoning effort may change and is applied before the warmed agent's first turn. Scheduled automations repeat the entitlement check at execution time so revoked access cannot launch later. `TaskViewSet.run` creates a `TaskRun` (status=QUEUED) and starts the Temporal workflow. `TaskRunViewSet.partial_update` handles status transitions and signals the Temporal workflow on terminal statuses via `signal_workflow_completion`. `TaskRunViewSet.cancel` (`POST .../runs/{id}/cancel/`) is the user-facing kill switch: `cancel_task_run` interrupts the in-flight agent turn, signals `complete_task("cancelled")` so the workflow snapshots the session and tears down the sandbox, and falls back to finalizing the run directly when no workflow is running.
### Temporal workflow
diff --git a/products/tasks/backend/tests/test_warm_facade.py b/products/tasks/backend/tests/test_warm_facade.py
index 87dfde72faf8..19707eb2062e 100644
--- a/products/tasks/backend/tests/test_warm_facade.py
+++ b/products/tasks/backend/tests/test_warm_facade.py
@@ -260,6 +260,20 @@ class TestWarmTaskSandbox(APIBaseTest):
m_warm.assert_called_once()
assert Task.objects.filter(team=self.team, deleted=False).count() == 1
+ def test_dedups_when_only_reasoning_effort_changes(self):
+ def fake_warm(self_warmer, **kwargs):
+ state = {"await_user_message": True, **kwargs["extra_state"]}
+ run = self_warmer.task.create_run(mode="interactive", extra_state=state, branch=state.get("branch"))
+ return WarmResult(run=run, just_created=True)
+
+ with patch(f"{WARM_SRC}.warm", autospec=True, side_effect=fake_warm) as mock_warm:
+ first = self._warm(runtime_adapter="codex", model="gpt-5.6-sol", reasoning_effort="high")
+ second = self._warm(runtime_adapter="codex", model="gpt-5.6-sol", reasoning_effort="xhigh")
+
+ assert first is not None and second is not None
+ assert second.run_id == first.run_id
+ mock_warm.assert_called_once()
+
def test_does_not_reuse_warm_run_after_environment_access_is_revoked(self):
other_user = User.objects.create_and_join(self.organization, "[email protected]", None)
sandbox_environment = SandboxEnvironment.objects.create(
@@ -397,6 +411,50 @@ class TestCreateTaskWarmReuse(APIBaseTest):
# must be persisted for the warm run to honor the setting.
assert run.state.get("auto_publish") is True
+ def test_reuses_warm_task_with_new_reasoning_effort_and_attachments(self):
+ warm_task, run = self._warm_run(
+ extra_state={
+ "runtime_adapter": "codex",
+ "model": "gpt-5.6-sol",
+ "reasoning_effort": "high",
+ }
+ )
+ run.artifacts = [_artifact_entry("artifact-1")]
+ run.save(update_fields=["artifacts"])
+
+ with patch(f"{FACADE}.signal_task_run_user_message", return_value=True) as mock_signal:
+ dto = self._create(
+ runtime_adapter="codex",
+ model="gpt-5.6-sol",
+ reasoning_effort="xhigh",
+ pending_user_message="inspect the attachment",
+ pending_user_artifact_ids=["artifact-1"],
+ )
+
+ assert str(dto.id) == str(warm_task.id)
+ run.refresh_from_db()
+ assert run.state.get("reasoning_effort") == "xhigh"
+ assert "await_user_message" not in run.state
+ _, kwargs = mock_signal.call_args
+ assert kwargs["artifact_ids"] == ["artifact-1"]
+
+ def test_reuses_warm_task_without_reasoning_effort_and_clears_prewarm_value(self):
+ warm_task, run = self._warm_run(
+ extra_state={
+ "runtime_adapter": "codex",
+ "model": "gpt-5.6-sol",
+ "reasoning_effort": "high",
+ }
+ )
+
+ with patch(f"{FACADE}.signal_task_run_user_message", return_value=True):
+ dto = self._create(runtime_adapter="codex", model="gpt-5.6-sol")
+
+ assert str(dto.id) == str(warm_task.id)
+ run.refresh_from_db()
+ assert "reasoning_effort" not in run.state
+ assert "await_user_message" not in run.state
+
def test_reuses_matching_multi_repository_warm_task(self):
repositories = ["posthog/posthog", "posthog/posthog-js"]
warm_task, run = self._warm_run(repositories=repositories)
@@ -681,6 +739,7 @@ class TestRunTaskWarmActivation(APIBaseTest):
def test_materializes_staged_artifacts_onto_warm_run_before_activation(self):
task, run = self._warm_run()
+ TaskRun.update_state_atomic(run.id, updates={"reasoning_effort": "high"})
staged = _artifact_entry("artifact-1")
get_tasks_cache().set(build_task_staged_artifact_cache_key(str(task.id), "artifact-1"), staged, timeout=60)
@@ -694,6 +753,7 @@ class TestRunTaskWarmActivation(APIBaseTest):
"branch": "main",
"pending_user_message": "do it",
"pending_user_artifact_ids": ["artifact-1"],
+ "reasoning_effort": "xhigh",
},
)
@@ -702,6 +762,7 @@ class TestRunTaskWarmActivation(APIBaseTest):
run.refresh_from_db()
assert [artifact["id"] for artifact in run.artifacts] == ["artifact-1"]
assert "await_user_message" not in run.state
+ assert run.state.get("reasoning_effort") == "xhigh"
_, kwargs = m_signal.call_args
assert kwargs["artifact_ids"] == ["artifact-1"]