The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 12:00 UTC
fix(codex): preserve partial answer messages and thread histories (#23388)
Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Alex Southwell committed
Oct 30, 2026 at 20:45 UTC
87b36c77fb5cdb26911d2419f62a23dbab6becc5
5 files changed
+219
-24
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+34
-1
@@ -3201,7 +3201,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
3201
answers: ReadonlyArray<{
3202
readonly id: string;
3203
readonly text: string;
3204
- readonly phase?: "commentary" | "final_answer" | null;
3204
+ readonly phase?: "commentary" | "partial_answer" | "final_answer" | null;
3205
readonly omitPhase?: boolean;
3206
readonly streamed?: boolean;
3207
readonly completionDelayMs?: number;
@@ -3296,6 +3296,39 @@ describe("CodexAdapterV2 post-settle continuation", () => {
3296
});
3297
};
3298
3299
+ it.effect.each([false, true])(
3300
+ "preserves a final answer that repeats a preceding partial answer (streamed: %s)",
3301
+ (streamed) =>
3302
+ Effect.scoped(
3303
+ Effect.gen(function* () {
3304
+ const transcript = finalAnswerTranscript("codex-partial-then-final", [
3305
+ { id: "partial", text: "CODEX_RECOVERY_OK", phase: "partial_answer", streamed },
3306
+ { id: "final", text: "CODEX_RECOVERY_OK", phase: "final_answer", streamed },
3307
+ ]);
3308
+ const harness = yield* makeCodexReplayHarness(transcript);
3309
+ const now = yield* DateTime.now;
3310
+ yield* harness.runtime.startTurn(
3311
+ makeCodexTestTurnInput({
3312
+ threadId: harness.threadId,
3313
+ providerThread: harness.providerThread,
3314
+ now,
3315
+ attemptId: RunAttemptId.make("attempt-codex-partial-then-final"),
3316
+ text: "Reply with the requested recovery marker.",
3317
+ }),
3318
+ );
3319
+ yield* harness.awaitTerminal(1);
3320
+ assert.deepEqual(
3321
+ assistantMessages(harness.events).map((event) => event.message.text),
3322
+ ["CODEX_RECOVERY_OK", "CODEX_RECOVERY_OK"],
3323
+ );
3324
+ }).pipe(
3325
+ Effect.provide(
3326
+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
3327
+ ),
3328
+ ),
3329
+ ),
3330
+ );
3331
+
3332
it.effect.each([
3333
{
3334
name: "a text reply gains each saved image once",
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+2
-2
@@ -4769,7 +4769,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
4769
}
4770
4771
if (payload.item.type === "agentMessage") {
4772
- if (payload.item.phase !== "commentary") {
4772
+ if (payload.item.phase == null || payload.item.phase === "final_answer") {
4773
yield* Ref.update(finalAnswerItemIdsByTurn, (current) => {
4774
const updated = new Map(current);
4775
const itemIds = new Set(updated.get(payload.turnId) ?? []);
@@ -5132,7 +5132,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
5132
return;
5133
}
5134
5135
- const finalAnswer = payload.item.phase !== "commentary";
5135
+ const finalAnswer = payload.item.phase == null || payload.item.phase === "final_answer";
5136
if (finalAnswer) {
5137
yield* Ref.update(finalAnswerItemIdsByTurn, (current) => {
5138
const updated = new Map(current);
packages/effect-codex-app-server/scripts/generate.ts
+23
@@ -145,6 +145,29 @@ const ManualSchemas: Record<string, Schema.Json> = {
145
// `account/read` decode and take the provider down with it.
146
const DefinitionOverrides: Record<string, Schema.Json> = {
147
PlanType: { type: "string" },
148
+ // Newer custom Codex binaries emit partial answers before additional tools or text.
149
+ MessagePhase: {
150
+ description:
151
+ 'Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as "phase unknown" and keep compatibility behavior for legacy models.',
152
+ oneOf: [
153
+ {
154
+ type: "string",
155
+ enum: ["commentary"],
156
+ description:
157
+ "Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
158
+ },
159
+ {
160
+ type: "string",
161
+ enum: ["partial_answer"],
162
+ description: "Stable answer text that may be followed by more assistant output or tools.",
163
+ },
164
+ {
165
+ type: "string",
166
+ enum: ["final_answer"],
167
+ description: "The assistant's terminal answer text for the current turn.",
168
+ },
169
+ ],
170
+ },
171
};
172
173
const getGeneratedPaths = Effect.fn("getGeneratedPaths")(function* () {
packages/effect-codex-app-server/src/_generated/schema.gen.ts
+114
-21
@@ -1532,13 +1532,16 @@ export const ClientRequest__InternalChatMessageMetadataPassthrough = Schema.Stru
1532
identifier: "ClientRequest__InternalChatMessageMetadataPassthrough",
1533
});
1534
1535
-export type ClientRequest__MessagePhase = "commentary" | "final_answer";
1535
+export type ClientRequest__MessagePhase = "commentary" | "partial_answer" | "final_answer";
1536
export const ClientRequest__MessagePhase = Schema.Union(
1537
[
1538
Schema.Literal("commentary").annotate({
1539
description:
1540
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
1541
}),
1542
+ Schema.Literal("partial_answer").annotate({
1543
+ description: "Stable answer text that may be followed by more assistant output or tools.",
1544
+ }),
1545
Schema.Literal("final_answer").annotate({
1546
description: "The assistant's terminal answer text for the current turn.",
1547
}),
@@ -2219,13 +2222,16 @@ export const ServerNotification__MemoryCitationEntry = Schema.Struct({
2222
path: Schema.String,
2223
}).annotate({ identifier: "ServerNotification__MemoryCitationEntry" });
2224
2222
-export type ServerNotification__MessagePhase = "commentary" | "final_answer";
2225
+export type ServerNotification__MessagePhase = "commentary" | "partial_answer" | "final_answer";
2226
export const ServerNotification__MessagePhase = Schema.Union(
2227
[
2228
Schema.Literal("commentary").annotate({
2229
description:
2230
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
2231
}),
2232
+ Schema.Literal("partial_answer").annotate({
2233
+ description: "Stable answer text that may be followed by more assistant output or tools.",
2234
+ }),
2235
Schema.Literal("final_answer").annotate({
2236
description: "The assistant's terminal answer text for the current turn.",
2237
}),
@@ -5991,13 +5997,19 @@ export const V2ItemCompletedNotification__MemoryCitationEntry = Schema.Struct({
5997
path: Schema.String,
5998
}).annotate({ identifier: "V2ItemCompletedNotification__MemoryCitationEntry" });
5999
5994
-export type V2ItemCompletedNotification__MessagePhase = "commentary" | "final_answer";
6000
+export type V2ItemCompletedNotification__MessagePhase =
6001
+ | "commentary"
6002
+ | "partial_answer"
6003
+ | "final_answer";
6004
export const V2ItemCompletedNotification__MessagePhase = Schema.Union(
6005
[
6006
Schema.Literal("commentary").annotate({
6007
description:
6008
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
6009
}),
6010
+ Schema.Literal("partial_answer").annotate({
6011
+ description: "Stable answer text that may be followed by more assistant output or tools.",
6012
+ }),
6013
Schema.Literal("final_answer").annotate({
6014
description: "The assistant's terminal answer text for the current turn.",
6015
}),
@@ -6538,13 +6550,19 @@ export const V2ItemStartedNotification__MemoryCitationEntry = Schema.Struct({
6550
path: Schema.String,
6551
}).annotate({ identifier: "V2ItemStartedNotification__MemoryCitationEntry" });
6552
6541
-export type V2ItemStartedNotification__MessagePhase = "commentary" | "final_answer";
6553
+export type V2ItemStartedNotification__MessagePhase =
6554
+ | "commentary"
6555
+ | "partial_answer"
6556
+ | "final_answer";
6557
export const V2ItemStartedNotification__MessagePhase = Schema.Union(
6558
[
6559
Schema.Literal("commentary").annotate({
6560
description:
6561
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
6562
}),
6563
+ Schema.Literal("partial_answer").annotate({
6564
+ description: "Stable answer text that may be followed by more assistant output or tools.",
6565
+ }),
6566
Schema.Literal("final_answer").annotate({
6567
description: "The assistant's terminal answer text for the current turn.",
6568
}),
@@ -7915,13 +7933,19 @@ export const V2RawResponseItemCompletedNotification__InternalChatMessageMetadata
7933
identifier: "V2RawResponseItemCompletedNotification__InternalChatMessageMetadataPassthrough",
7934
});
7935
7918
-export type V2RawResponseItemCompletedNotification__MessagePhase = "commentary" | "final_answer";
7936
+export type V2RawResponseItemCompletedNotification__MessagePhase =
7937
+ | "commentary"
7938
+ | "partial_answer"
7939
+ | "final_answer";
7940
export const V2RawResponseItemCompletedNotification__MessagePhase = Schema.Union(
7941
[
7942
Schema.Literal("commentary").annotate({
7943
description:
7944
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
7945
}),
7946
+ Schema.Literal("partial_answer").annotate({
7947
+ description: "Stable answer text that may be followed by more assistant output or tools.",
7948
+ }),
7949
Schema.Literal("final_answer").annotate({
7950
description: "The assistant's terminal answer text for the current turn.",
7951
}),
@@ -8215,13 +8239,16 @@ export const V2ReviewStartResponse__MemoryCitationEntry = Schema.Struct({
8239
path: Schema.String,
8240
}).annotate({ identifier: "V2ReviewStartResponse__MemoryCitationEntry" });
8241
8218
-export type V2ReviewStartResponse__MessagePhase = "commentary" | "final_answer";
8242
+export type V2ReviewStartResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
8243
export const V2ReviewStartResponse__MessagePhase = Schema.Union(
8244
[
8245
Schema.Literal("commentary").annotate({
8246
description:
8247
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
8248
}),
8249
+ Schema.Literal("partial_answer").annotate({
8250
+ description: "Stable answer text that may be followed by more assistant output or tools.",
8251
+ }),
8252
Schema.Literal("final_answer").annotate({
8253
description: "The assistant's terminal answer text for the current turn.",
8254
}),
@@ -8927,13 +8954,16 @@ export const V2ThreadForkResponse__MemoryCitationEntry = Schema.Struct({
8954
path: Schema.String,
8955
}).annotate({ identifier: "V2ThreadForkResponse__MemoryCitationEntry" });
8956
8930
-export type V2ThreadForkResponse__MessagePhase = "commentary" | "final_answer";
8957
+export type V2ThreadForkResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
8958
export const V2ThreadForkResponse__MessagePhase = Schema.Union(
8959
[
8960
Schema.Literal("commentary").annotate({
8961
description:
8962
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
8963
}),
8964
+ Schema.Literal("partial_answer").annotate({
8965
+ description: "Stable answer text that may be followed by more assistant output or tools.",
8966
+ }),
8967
Schema.Literal("final_answer").annotate({
8968
description: "The assistant's terminal answer text for the current turn.",
8969
}),
@@ -9382,13 +9412,19 @@ export const V2ThreadItemsListResponse__MemoryCitationEntry = Schema.Struct({
9412
path: Schema.String,
9413
}).annotate({ identifier: "V2ThreadItemsListResponse__MemoryCitationEntry" });
9414
9385
-export type V2ThreadItemsListResponse__MessagePhase = "commentary" | "final_answer";
9415
+export type V2ThreadItemsListResponse__MessagePhase =
9416
+ | "commentary"
9417
+ | "partial_answer"
9418
+ | "final_answer";
9419
export const V2ThreadItemsListResponse__MessagePhase = Schema.Union(
9420
[
9421
Schema.Literal("commentary").annotate({
9422
description:
9423
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
9424
}),
9425
+ Schema.Literal("partial_answer").annotate({
9426
+ description: "Stable answer text that may be followed by more assistant output or tools.",
9427
+ }),
9428
Schema.Literal("final_answer").annotate({
9429
description: "The assistant's terminal answer text for the current turn.",
9430
}),
@@ -9872,13 +9908,16 @@ export const V2ThreadListResponse__MemoryCitationEntry = Schema.Struct({
9908
path: Schema.String,
9909
}).annotate({ identifier: "V2ThreadListResponse__MemoryCitationEntry" });
9910
9875
-export type V2ThreadListResponse__MessagePhase = "commentary" | "final_answer";
9911
+export type V2ThreadListResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
9912
export const V2ThreadListResponse__MessagePhase = Schema.Union(
9913
[
9914
Schema.Literal("commentary").annotate({
9915
description:
9916
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
9917
}),
9918
+ Schema.Literal("partial_answer").annotate({
9919
+ description: "Stable answer text that may be followed by more assistant output or tools.",
9920
+ }),
9921
Schema.Literal("final_answer").annotate({
9922
description: "The assistant's terminal answer text for the current turn.",
9923
}),
@@ -10364,13 +10403,19 @@ export const V2ThreadMetadataUpdateResponse__MemoryCitationEntry = Schema.Struct
10403
path: Schema.String,
10404
}).annotate({ identifier: "V2ThreadMetadataUpdateResponse__MemoryCitationEntry" });
10405
10367
-export type V2ThreadMetadataUpdateResponse__MessagePhase = "commentary" | "final_answer";
10406
+export type V2ThreadMetadataUpdateResponse__MessagePhase =
10407
+ | "commentary"
10408
+ | "partial_answer"
10409
+ | "final_answer";
10410
export const V2ThreadMetadataUpdateResponse__MessagePhase = Schema.Union(
10411
[
10412
Schema.Literal("commentary").annotate({
10413
description:
10414
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
10415
}),
10416
+ Schema.Literal("partial_answer").annotate({
10417
+ description: "Stable answer text that may be followed by more assistant output or tools.",
10418
+ }),
10419
Schema.Literal("final_answer").annotate({
10420
description: "The assistant's terminal answer text for the current turn.",
10421
}),
@@ -10822,13 +10867,16 @@ export const V2ThreadReadResponse__MemoryCitationEntry = Schema.Struct({
10867
path: Schema.String,
10868
}).annotate({ identifier: "V2ThreadReadResponse__MemoryCitationEntry" });
10869
10825
-export type V2ThreadReadResponse__MessagePhase = "commentary" | "final_answer";
10870
+export type V2ThreadReadResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
10871
export const V2ThreadReadResponse__MessagePhase = Schema.Union(
10872
[
10873
Schema.Literal("commentary").annotate({
10874
description:
10875
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
10876
}),
10877
+ Schema.Literal("partial_answer").annotate({
10878
+ description: "Stable answer text that may be followed by more assistant output or tools.",
10879
+ }),
10880
Schema.Literal("final_answer").annotate({
10881
description: "The assistant's terminal answer text for the current turn.",
10882
}),
@@ -11382,13 +11430,16 @@ export const V2ThreadResumeParams__InternalChatMessageMetadataPassthrough = Sche
11430
identifier: "V2ThreadResumeParams__InternalChatMessageMetadataPassthrough",
11431
});
11432
11385
-export type V2ThreadResumeParams__MessagePhase = "commentary" | "final_answer";
11433
+export type V2ThreadResumeParams__MessagePhase = "commentary" | "partial_answer" | "final_answer";
11434
export const V2ThreadResumeParams__MessagePhase = Schema.Union(
11435
[
11436
Schema.Literal("commentary").annotate({
11437
description:
11438
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
11439
}),
11440
+ Schema.Literal("partial_answer").annotate({
11441
+ description: "Stable answer text that may be followed by more assistant output or tools.",
11442
+ }),
11443
Schema.Literal("final_answer").annotate({
11444
description: "The assistant's terminal answer text for the current turn.",
11445
}),
@@ -11755,13 +11806,16 @@ export const V2ThreadResumeResponse__MemoryCitationEntry = Schema.Struct({
11806
path: Schema.String,
11807
}).annotate({ identifier: "V2ThreadResumeResponse__MemoryCitationEntry" });
11808
11758
-export type V2ThreadResumeResponse__MessagePhase = "commentary" | "final_answer";
11809
+export type V2ThreadResumeResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
11810
export const V2ThreadResumeResponse__MessagePhase = Schema.Union(
11811
[
11812
Schema.Literal("commentary").annotate({
11813
description:
11814
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
11815
}),
11816
+ Schema.Literal("partial_answer").annotate({
11817
+ description: "Stable answer text that may be followed by more assistant output or tools.",
11818
+ }),
11819
Schema.Literal("final_answer").annotate({
11820
description: "The assistant's terminal answer text for the current turn.",
11821
}),
@@ -12202,13 +12256,16 @@ export const V2ThreadRevertResponse__MemoryCitationEntry = Schema.Struct({
12256
path: Schema.String,
12257
}).annotate({ identifier: "V2ThreadRevertResponse__MemoryCitationEntry" });
12258
12205
-export type V2ThreadRevertResponse__MessagePhase = "commentary" | "final_answer";
12259
+export type V2ThreadRevertResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
12260
export const V2ThreadRevertResponse__MessagePhase = Schema.Union(
12261
[
12262
Schema.Literal("commentary").annotate({
12263
description:
12264
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
12265
}),
12266
+ Schema.Literal("partial_answer").annotate({
12267
+ description: "Stable answer text that may be followed by more assistant output or tools.",
12268
+ }),
12269
Schema.Literal("final_answer").annotate({
12270
description: "The assistant's terminal answer text for the current turn.",
12271
}),
@@ -12841,13 +12898,19 @@ export const V2ThreadStartedNotification__MemoryCitationEntry = Schema.Struct({
12898
path: Schema.String,
12899
}).annotate({ identifier: "V2ThreadStartedNotification__MemoryCitationEntry" });
12900
12844
-export type V2ThreadStartedNotification__MessagePhase = "commentary" | "final_answer";
12901
+export type V2ThreadStartedNotification__MessagePhase =
12902
+ | "commentary"
12903
+ | "partial_answer"
12904
+ | "final_answer";
12905
export const V2ThreadStartedNotification__MessagePhase = Schema.Union(
12906
[
12907
Schema.Literal("commentary").annotate({
12908
description:
12909
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
12910
}),
12911
+ Schema.Literal("partial_answer").annotate({
12912
+ description: "Stable answer text that may be followed by more assistant output or tools.",
12913
+ }),
12914
Schema.Literal("final_answer").annotate({
12915
description: "The assistant's terminal answer text for the current turn.",
12916
}),
@@ -13469,13 +13532,16 @@ export const V2ThreadStartResponse__MemoryCitationEntry = Schema.Struct({
13532
path: Schema.String,
13533
}).annotate({ identifier: "V2ThreadStartResponse__MemoryCitationEntry" });
13534
13472
-export type V2ThreadStartResponse__MessagePhase = "commentary" | "final_answer";
13535
+export type V2ThreadStartResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
13536
export const V2ThreadStartResponse__MessagePhase = Schema.Union(
13537
[
13538
Schema.Literal("commentary").annotate({
13539
description:
13540
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
13541
}),
13542
+ Schema.Literal("partial_answer").annotate({
13543
+ description: "Stable answer text that may be followed by more assistant output or tools.",
13544
+ }),
13545
Schema.Literal("final_answer").annotate({
13546
description: "The assistant's terminal answer text for the current turn.",
13547
}),
@@ -13910,13 +13976,19 @@ export const V2ThreadTurnsListResponse__MemoryCitationEntry = Schema.Struct({
13976
path: Schema.String,
13977
}).annotate({ identifier: "V2ThreadTurnsListResponse__MemoryCitationEntry" });
13978
13913
-export type V2ThreadTurnsListResponse__MessagePhase = "commentary" | "final_answer";
13979
+export type V2ThreadTurnsListResponse__MessagePhase =
13980
+ | "commentary"
13981
+ | "partial_answer"
13982
+ | "final_answer";
13983
export const V2ThreadTurnsListResponse__MessagePhase = Schema.Union(
13984
[
13985
Schema.Literal("commentary").annotate({
13986
description:
13987
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
13988
}),
13989
+ Schema.Literal("partial_answer").annotate({
13990
+ description: "Stable answer text that may be followed by more assistant output or tools.",
13991
+ }),
13992
Schema.Literal("final_answer").annotate({
13993
description: "The assistant's terminal answer text for the current turn.",
13994
}),
@@ -14384,13 +14456,19 @@ export const V2ThreadUnarchiveResponse__MemoryCitationEntry = Schema.Struct({
14456
path: Schema.String,
14457
}).annotate({ identifier: "V2ThreadUnarchiveResponse__MemoryCitationEntry" });
14458
14387
-export type V2ThreadUnarchiveResponse__MessagePhase = "commentary" | "final_answer";
14459
+export type V2ThreadUnarchiveResponse__MessagePhase =
14460
+ | "commentary"
14461
+ | "partial_answer"
14462
+ | "final_answer";
14463
export const V2ThreadUnarchiveResponse__MessagePhase = Schema.Union(
14464
[
14465
Schema.Literal("commentary").annotate({
14466
description:
14467
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
14468
}),
14469
+ Schema.Literal("partial_answer").annotate({
14470
+ description: "Stable answer text that may be followed by more assistant output or tools.",
14471
+ }),
14472
Schema.Literal("final_answer").annotate({
14473
description: "The assistant's terminal answer text for the current turn.",
14474
}),
@@ -14785,13 +14863,19 @@ export const V2TurnCompletedNotification__MemoryCitationEntry = Schema.Struct({
14863
path: Schema.String,
14864
}).annotate({ identifier: "V2TurnCompletedNotification__MemoryCitationEntry" });
14865
14788
-export type V2TurnCompletedNotification__MessagePhase = "commentary" | "final_answer";
14866
+export type V2TurnCompletedNotification__MessagePhase =
14867
+ | "commentary"
14868
+ | "partial_answer"
14869
+ | "final_answer";
14870
export const V2TurnCompletedNotification__MessagePhase = Schema.Union(
14871
[
14872
Schema.Literal("commentary").annotate({
14873
description:
14874
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
14875
}),
14876
+ Schema.Literal("partial_answer").annotate({
14877
+ description: "Stable answer text that may be followed by more assistant output or tools.",
14878
+ }),
14879
Schema.Literal("final_answer").annotate({
14880
description: "The assistant's terminal answer text for the current turn.",
14881
}),
@@ -15200,13 +15284,19 @@ export const V2TurnStartedNotification__MemoryCitationEntry = Schema.Struct({
15284
path: Schema.String,
15285
}).annotate({ identifier: "V2TurnStartedNotification__MemoryCitationEntry" });
15286
15203
-export type V2TurnStartedNotification__MessagePhase = "commentary" | "final_answer";
15287
+export type V2TurnStartedNotification__MessagePhase =
15288
+ | "commentary"
15289
+ | "partial_answer"
15290
+ | "final_answer";
15291
export const V2TurnStartedNotification__MessagePhase = Schema.Union(
15292
[
15293
Schema.Literal("commentary").annotate({
15294
description:
15295
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
15296
}),
15297
+ Schema.Literal("partial_answer").annotate({
15298
+ description: "Stable answer text that may be followed by more assistant output or tools.",
15299
+ }),
15300
Schema.Literal("final_answer").annotate({
15301
description: "The assistant's terminal answer text for the current turn.",
15302
}),
@@ -15729,13 +15819,16 @@ export const V2TurnStartResponse__MemoryCitationEntry = Schema.Struct({
15819
path: Schema.String,
15820
}).annotate({ identifier: "V2TurnStartResponse__MemoryCitationEntry" });
15821
15732
-export type V2TurnStartResponse__MessagePhase = "commentary" | "final_answer";
15822
+export type V2TurnStartResponse__MessagePhase = "commentary" | "partial_answer" | "final_answer";
15823
export const V2TurnStartResponse__MessagePhase = Schema.Union(
15824
[
15825
Schema.Literal("commentary").annotate({
15826
description:
15827
"Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
15828
}),
15829
+ Schema.Literal("partial_answer").annotate({
15830
+ description: "Stable answer text that may be followed by more assistant output or tools.",
15831
+ }),
15832
Schema.Literal("final_answer").annotate({
15833
description: "The assistant's terminal answer text for the current turn.",
15834
}),
packages/effect-codex-app-server/src/schema.test.ts
+46
@@ -33,6 +33,52 @@ it("keeps async questions in live notifications and thread history", () => {
33
}
34
});
35
36
+it("keeps partial answers in notifications and persisted thread histories", () => {
37
+ const item = {
38
+ type: "agentMessage",
39
+ id: "partial-1",
40
+ text: "A stable answer before more tool work.",
41
+ phase: "partial_answer",
42
+ } as const;
43
+ for (const schema of [
44
+ CodexSchema.ServerNotification__ThreadItem,
45
+ CodexSchema.V2ItemStartedNotification__ThreadItem,
46
+ CodexSchema.V2ItemCompletedNotification__ThreadItem,
47
+ CodexSchema.V2ThreadReadResponse__ThreadItem,
48
+ CodexSchema.V2ThreadResumeResponse__ThreadItem,
49
+ CodexSchema.V2ThreadForkResponse__ThreadItem,
50
+ CodexSchema.V2TurnCompletedNotification__ThreadItem,
51
+ ]) {
52
+ assert.deepEqual(Schema.decodeSync(schema)(item), item);
53
+ }
54
+ const response = {
55
+ approvalPolicy: "never",
56
+ approvalsReviewer: "user",
57
+ cwd: "/tmp/project",
58
+ model: "gpt-5.6-sol",
59
+ modelProvider: "openai",
60
+ sandbox: { type: "dangerFullAccess" },
61
+ thread: {
62
+ cliVersion: "0.162.0",
63
+ createdAt: 0,
64
+ updatedAt: 0,
65
+ cwd: "/tmp/project",
66
+ ephemeral: false,
67
+ id: "thread-1",
68
+ modelProvider: "openai",
69
+ preview: "",
70
+ projectId: null,
71
+ sessionId: "session-1",
72
+ source: "cli",
73
+ status: { type: "idle" },
74
+ turns: [{ id: "turn-1", status: "completed", items: [item] }],
75
+ },
76
+ };
77
+ assert.equal(isThreadForkResponse(response), true);
78
+ assert.equal(isThreadResumeResponse(response), true);
79
+ assert.equal(isThreadReadResponse({ thread: response.thread }), true);
80
+});
81
+
82
it("accepts Codex 0.150 multi-agent values", () => {
83
const schemas = [
84
CodexSchema.ServerNotification__SubAgentActivityKind,