Skip to content

Commit a14283c

Browse files
t3dotggclaude
andcommitted
fix: council review of prompt suggestions
Read the Labs flag live (Codex per sample, Claude per query), skip delegated threads per turn with one isDelegatedAppThread predicate (treating MCP's null delegatedFrom as unset), gate the client on the setting instead of a capability, route Tab through the typing guard, and share dismissals across composers per environment and run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 38c68bf commit a14283c

15 files changed

Lines changed: 313 additions & 126 deletions

File tree

‎apps/server/src/environment/ServerEnvironment.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ export const make = Effect.gen(function* () {
254254
threadProjectFromScratch: true,
255255
threadTitleRegeneration: true,
256256
commandOutputStreaming: true,
257-
promptSuggestions: true,
258257
threadVisitedTracking: true,
259258
threadPullRequests: true,
260259
threadPullRequestWatch: true,

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 88 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,7 +3134,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
31343134
providerSessionId: ProviderSessionId.make("provider-session-claude-wake"),
31353135
modelSelection: CLAUDE_TEST_MODEL_SELECTION,
31363136
runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
3137-
promptSuggestions: options?.promptSuggestions === true,
3137+
promptSuggestions: Effect.succeed(options?.promptSuggestions === true),
31383138
});
31393139
const providerThread = yield* runtime.ensureThread({
31403140
threadId,
@@ -6804,53 +6804,94 @@ describe("ClaudeAdapterV2 background wake turns", () => {
68046804
),
68056805
);
68066806

6807-
it.effect("offers the prompt suggestion Claude sends after a completed turn", () =>
6808-
Effect.gen(function* () {
6809-
const harness = yield* makeWakeHarnessWithOptions({ promptSuggestions: true });
6810-
const input = makeClaudeTestTurnInput({
6811-
threadId: harness.threadId,
6812-
providerThread: harness.providerThread,
6813-
now: yield* DateTime.now,
6814-
attemptId: RunAttemptId.make("attempt-prompt-suggestion"),
6815-
text: "Add a subtract function.",
6816-
attachments: [],
6817-
});
6818-
yield* harness.runtime.startTurn(input);
6819-
yield* Queue.offer(
6820-
harness.sdkMessages,
6821-
makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000690", result: "Done." }),
6822-
);
6823-
yield* Queue.take(harness.terminalReceipts);
6824-
yield* Queue.offer(
6825-
harness.sdkMessages,
6826-
claudeSdkFrame({
6827-
type: "prompt_suggestion",
6828-
suggestion: " add tests for subtract\n",
6829-
uuid: "00000000-0000-4000-8000-000000000691",
6830-
session_id: WAKE_NATIVE_SESSION,
6831-
}),
6832-
);
6833-
yield* harness.until(() =>
6834-
harness.events.some((event) => event.type === "prompt_suggestion.updated"),
6835-
);
6836-
assert.equal(harness.getOpenedOptions()?.promptSuggestions, true);
6837-
assert.deepEqual(
6838-
harness.events.filter((event) => event.type === "prompt_suggestion.updated"),
6839-
[
6840-
{
6841-
type: "prompt_suggestion.updated",
6842-
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6843-
threadId: harness.threadId,
6844-
runId: input.runId,
6845-
text: "add tests for subtract",
6846-
},
6847-
],
6848-
);
6849-
}).pipe(
6850-
Effect.provide(
6851-
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
6807+
it.effect.each(["root", "mcp", "subagent", "remote"] as const)(
6808+
"asks Claude for suggestions only on threads a person drives (%s)",
6809+
(lineage) =>
6810+
Effect.gen(function* () {
6811+
const harness = yield* makeWakeHarnessWithOptions({ promptSuggestions: true });
6812+
const base = makeClaudeTestTurnInput({
6813+
threadId: harness.threadId,
6814+
providerThread: harness.providerThread,
6815+
now: yield* DateTime.now,
6816+
attemptId: RunAttemptId.make("attempt-prompt-suggestion"),
6817+
text: "Add a subtract function.",
6818+
attachments: [],
6819+
});
6820+
const parentThreadId = ThreadId.make("thread-claude-suggestion-parent");
6821+
// MCP-launched root threads carry `delegatedFrom: null` at runtime.
6822+
const offered = lineage === "root" || lineage === "mcp";
6823+
const input =
6824+
lineage === "root"
6825+
? base
6826+
: lineage === "mcp"
6827+
? {
6828+
...base,
6829+
appThread: {
6830+
...base.appThread,
6831+
delegatedFrom: null as unknown as undefined,
6832+
},
6833+
}
6834+
: lineage === "subagent"
6835+
? {
6836+
...base,
6837+
appThread: {
6838+
...base.appThread,
6839+
lineage: {
6840+
parentThreadId,
6841+
relationshipToParent: "subagent" as const,
6842+
rootThreadId: parentThreadId,
6843+
},
6844+
},
6845+
}
6846+
: {
6847+
...base,
6848+
appThread: {
6849+
...base.appThread,
6850+
delegatedFrom: {
6851+
environmentId: EnvironmentId.make("environment-claude-suggestion-parent"),
6852+
threadId: parentThreadId,
6853+
title: "Parent",
6854+
},
6855+
},
6856+
};
6857+
yield* harness.runtime.startTurn(input);
6858+
yield* Queue.offer(
6859+
harness.sdkMessages,
6860+
makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000690", result: "Done." }),
6861+
);
6862+
yield* Queue.take(harness.terminalReceipts);
6863+
// Delegated threads have no one typing, so the SDK is never asked for suggestions.
6864+
assert.equal(harness.getOpenedOptions()?.promptSuggestions, offered);
6865+
if (!offered) return;
6866+
yield* Queue.offer(
6867+
harness.sdkMessages,
6868+
claudeSdkFrame({
6869+
type: "prompt_suggestion",
6870+
suggestion: " add tests for subtract\n",
6871+
uuid: "00000000-0000-4000-8000-000000000691",
6872+
session_id: WAKE_NATIVE_SESSION,
6873+
}),
6874+
);
6875+
yield* harness.until(() =>
6876+
harness.events.some((event) => event.type === "prompt_suggestion.updated"),
6877+
);
6878+
assert.deepEqual(
6879+
harness.events.filter((event) => event.type === "prompt_suggestion.updated"),
6880+
[
6881+
{
6882+
type: "prompt_suggestion.updated",
6883+
driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6884+
threadId: harness.threadId,
6885+
runId: input.runId,
6886+
text: "add tests for subtract",
6887+
},
6888+
],
6889+
);
6890+
}).pipe(
6891+
Effect.provide(
6892+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
6893+
),
68526894
),
6853-
),
68546895
);
68556896

68566897
it.effect("merges cumulative stream usage into the message_start counts", () =>

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ import {
107107
type RunId,
108108
type ThreadId,
109109
resolveIdleCompaction,
110+
isDelegatedAppThread,
110111
} from "@t3tools/contracts";
111112

112113
import { FILE_HEADERS_ONLY, formatPatch, structuredPatch } from "diff";
@@ -4720,7 +4721,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
47204721
}),
47214722
openSession: Effect.fn("ClaudeAdapterV2.openSession")(
47224723
function* (input: ProviderAdapter.ProviderAdapterV2OpenSessionInput) {
4723-
const promptSuggestionsEnabled = input.promptSuggestions === true;
4724+
const promptSuggestionsEnabled = input.promptSuggestions ?? Effect.succeed(false);
47244725
const sessionScope = yield* Effect.scope;
47254726
const now = yield* DateTime.now;
47264727
const session = providerSession({
@@ -10339,7 +10340,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1033910340
cwd: turnInput.runtimePolicy.cwd,
1034010341
attachmentsDir,
1034110342
settings: adapterOptions.settings,
10342-
promptSuggestions: promptSuggestionsEnabled,
10343+
// Delegated threads have no one typing, so they never ask for suggestions.
10344+
promptSuggestions:
10345+
!isDelegatedAppThread(turnInput.appThread) && (yield* promptSuggestionsEnabled),
1034310346
...(launchArgSettings === undefined
1034410347
? {}
1034510348
: { sdkSettings: claudeSdkLaunchArgSettings(launchArgSettings) }),

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
11471147
onRequest: (method: string, params: unknown) => Effect.Effect<void> = () => Effect.void,
11481148
readChildMetadata?: Parameters<typeof withCodexReplayChildMetadata>[2],
11491149
beforeEmitInbound?: CodexReplay.CodexAppServerReplayDriver["beforeEmitInbound"],
1150-
promptSuggestions = false,
1150+
promptSuggestions: Effect.Effect<boolean> = Effect.succeed(false),
11511151
) =>
11521152
Effect.gen(function* () {
11531153
const fileSystem = yield* FileSystem.FileSystem;
@@ -1710,6 +1710,109 @@ describe("CodexAdapterV2 post-settle continuation", () => {
17101710
),
17111711
);
17121712

1713+
it.effect.each(["subagent", "remote", "toggled-off"] as const)(
1714+
"never samples a suggestion for a %s thread",
1715+
(delegation) =>
1716+
Effect.gen(function* () {
1717+
const nativeThreadId = `suggest-${delegation}-thread`;
1718+
const prompt = "Continue the task.";
1719+
const first = codexReplayPreamble({
1720+
nativeThreadId,
1721+
nativeTurnId: `${delegation}-turn-1`,
1722+
prompt,
1723+
});
1724+
const second = codexReplayPreamble({
1725+
nativeThreadId,
1726+
nativeTurnId: `${delegation}-turn-2`,
1727+
prompt,
1728+
});
1729+
const completed = (nativeTurnId: string): CodexReplay.CodexAppServerReplayEntry => ({
1730+
type: "emit_inbound",
1731+
label: `${nativeTurnId} completed`,
1732+
frame: {
1733+
method: "turn/completed",
1734+
params: {
1735+
threadId: nativeThreadId,
1736+
turn: makeCodexReplayTurn({ id: nativeTurnId, status: "completed" }),
1737+
},
1738+
},
1739+
});
1740+
// The second turn is a barrier: a stray sample from the first turn is sent before it ends.
1741+
const requests: Array<string> = [];
1742+
const enabled = yield* Ref.make(true);
1743+
const harness = yield* makeCodexReplayHarness(
1744+
makeCodexReplayTranscript({
1745+
scenario: `prompt-suggestion-${delegation}`,
1746+
entries: [
1747+
...first,
1748+
completed(`${delegation}-turn-1`),
1749+
...second.slice(5, 7).map((entry) => withReplayRequestId(entry, 4)),
1750+
completed(`${delegation}-turn-2`),
1751+
],
1752+
}),
1753+
undefined,
1754+
(method) => Effect.sync(() => requests.push(method)),
1755+
undefined,
1756+
undefined,
1757+
Ref.get(enabled),
1758+
);
1759+
// The flag is read per turn: turning it off after the session opened stops sampling.
1760+
if (delegation === "toggled-off") yield* Ref.set(enabled, false);
1761+
const base = makeCodexTestTurnInput({
1762+
threadId: harness.threadId,
1763+
providerThread: harness.providerThread,
1764+
now: yield* DateTime.now,
1765+
attemptId: RunAttemptId.make(`${delegation}-attempt-1`),
1766+
text: prompt,
1767+
});
1768+
const parentThreadId = ThreadId.make("thread-codex-suggestion-parent");
1769+
const turn = {
1770+
...base,
1771+
appThread:
1772+
delegation === "toggled-off"
1773+
? base.appThread
1774+
: delegation === "subagent"
1775+
? {
1776+
...base.appThread,
1777+
lineage: {
1778+
parentThreadId,
1779+
relationshipToParent: "subagent" as const,
1780+
rootThreadId: parentThreadId,
1781+
},
1782+
}
1783+
: {
1784+
...base.appThread,
1785+
delegatedFrom: {
1786+
environmentId: EnvironmentId.make("environment-codex-suggestion-parent"),
1787+
threadId: parentThreadId,
1788+
title: "Parent",
1789+
},
1790+
},
1791+
};
1792+
yield* harness.runtime.startTurn(turn);
1793+
yield* harness.awaitTerminal(1);
1794+
yield* harness.runtime.startTurn({
1795+
...turn,
1796+
runId: RunId.make(`${delegation}-run-2`),
1797+
attemptId: RunAttemptId.make(`${delegation}-attempt-2`),
1798+
rootNodeId: NodeId.make(`${delegation}-root-2`),
1799+
runOrdinal: 2,
1800+
providerTurnOrdinal: 2,
1801+
});
1802+
yield* harness.awaitTerminal(2);
1803+
assert.deepEqual(
1804+
harness.terminalEvents().map((event) => event.status),
1805+
["completed", "completed"],
1806+
);
1807+
assert.notInclude(requests, "thread/sample");
1808+
}).pipe(
1809+
Effect.scoped,
1810+
Effect.provide(
1811+
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
1812+
),
1813+
),
1814+
);
1815+
17131816
it.effect("samples a next-prompt suggestion after a completed root turn", () =>
17141817
Effect.gen(function* () {
17151818
const nativeThreadId = "suggest-thread";
@@ -1767,7 +1870,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
17671870
undefined,
17681871
undefined,
17691872
undefined,
1770-
true,
1873+
Effect.succeed(true),
17711874
);
17721875
const turnInput = makeCodexTestTurnInput({
17731876
threadId: harness.threadId,

0 commit comments

Comments
 (0)