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(desktop): carry the pinned reasoning effort into codex turns (#88893)

Alex Lebedev083b2f1e6d77
diff --git a/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.test.ts b/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.test.ts
index bd511ec53600..c9b51dba34df 100644
--- a/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.test.ts
+++ b/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.test.ts
@@ -126,6 +126,53 @@ describe("resolveCodexMode", () => {
});
describe("SessionConfigState", () => {
+ it("carries the pinned reasoning effort in the per-turn collaboration mode", () => {
+ const pinned = new SessionConfigState("gpt-5.6-sol", "xhigh");
+ expect(pinned.collaborationModeForTurn()).toEqual({
+ mode: "default",
+ settings: { model: "gpt-5.6-sol", reasoning_effort: "xhigh" },
+ });
+
+ pinned.setOption("effort", "max");
+ expect(pinned.collaborationModeForTurn()).toEqual({
+ mode: "default",
+ settings: { model: "gpt-5.6-sol", reasoning_effort: "max" },
+ });
+
+ // No pin: leave the effort to codex's model default rather than sending null.
+ expect(
+ new SessionConfigState("gpt-5.5").collaborationModeForTurn(),
+ ).toEqual({
+ mode: "default",
+ settings: { model: "gpt-5.5" },
+ });
+ });
+
+ it("drops a pinned effort the newly selected model does not support", () => {
+ const config = new SessionConfigState("gpt-5.6-sol", "max");
+
+ // gpt-5.5 supports xhigh but not max, so the stale max pin must not ride the turn.
+ config.setOption("model", "gpt-5.5");
+ expect(config.collaborationModeForTurn()).toEqual({
+ mode: "default",
+ settings: { model: "gpt-5.5" },
+ });
+ const efforts = config.options.find((o) => o.category === "thought_level");
+ expect(
+ efforts?.type === "select"
+ ? efforts.options.map((o) => (o as { value: string }).value)
+ : [],
+ ).not.toContain("max");
+
+ // A pin the new model still supports survives the switch.
+ config.setOption("effort", "xhigh");
+ config.setOption("model", "gpt-5.6-sol");
+ expect(config.collaborationModeForTurn()).toEqual({
+ mode: "default",
+ settings: { model: "gpt-5.6-sol", reasoning_effort: "xhigh" },
+ });
+ });
+
it("canonicalizes bypassPermissions during a live mode update", () => {
const config = new SessionConfigState("gpt-5.5");
diff --git a/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.ts b/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.ts
index af3b6bdeb39f..1d901de567d8 100644
--- a/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.ts
+++ b/products/desktop/packages/agent/src/adapters/codex-app-server/session-config.ts
@@ -232,6 +232,15 @@ export interface RawModel {
supportedReasoningEfforts?: Array<{ reasoningEffort?: string } | string>;
}
+/** The per-turn `collaborationMode` payload sent on `turn/start`. */
+export interface CodexTurnCollaborationMode {
+ mode: "plan" | "default";
+ settings: {
+ model: string;
+ reasoning_effort?: string;
+ };
+}
+
/**
* Stateful holder for a codex session's model / effort / mode selectors and the
* ACP `configOptions` derived from them — synthesizing the Claude-style picker
@@ -300,6 +309,7 @@ export class SessionConfigState {
(!this.gatewayModels || this.allowedModelIds?.has(value))
) {
this._model = value;
+ this.reconcileEffortForModel();
} else if (configId === "effort") this._effort = value;
else if (configId === "mode") {
this._mode = resolveCodexMode(value);
@@ -310,6 +320,20 @@ export class SessionConfigState {
return { modeChanged };
}
+ /**
+ * Re-derive the effort selectors for the current model after a model switch.
+ * Effort tiers differ by family (`max` is gpt-5.6 only, `xhigh` is
+ * gpt-5.5/5.6), so a pin that the new model does not support is dropped —
+ * codex then reasons at the model default instead of receiving an unsupported
+ * effort on every turn.
+ */
+ private reconcileEffortForModel(): void {
+ this.efforts = getReasoningEffortOptions(this._model).map((o) => o.value);
+ if (this._effort && !this.efforts.includes(this._effort)) {
+ this._effort = undefined;
+ }
+ }
+
/**
* Populate the model + effort selectors from a `model/list` `data` array. The
* gateway also serves Claude models, so drop non-OpenAI ones; it doesn't
@@ -362,13 +386,19 @@ export class SessionConfigState {
}
/**
- * codex's per-turn `collaborationMode`: `{ mode, settings: { model } }`. The
- * model must be a string (not the null in collaborationMode/list output).
+ * codex's per-turn `collaborationMode`: `{ mode, settings: { model, reasoning_effort } }`.
+ * The model must be a string (not the null in collaborationMode/list output). As of codex
+ * 0.144 (codex-rs/core/src/codex_thread.rs), codex applies a provided collaboration mode as
+ * is and reads the turn's `effort` param only when no collaboration mode is sent, so the
+ * pinned effort has to ride along here or every turn runs at the model's default effort.
*/
- collaborationModeForTurn(): unknown {
+ collaborationModeForTurn(): CodexTurnCollaborationMode {
return {
mode: collaborationModeFor(this._mode),
- settings: { model: this._model },
+ settings: {
+ model: this._model,
+ ...(this._effort ? { reasoning_effort: this._effort } : {}),
+ },
};
}