Record created threads and subagent progress
- Add parent-thread records for spawned child threads - Persist Claude subagent progress as reasoning items - Tighten projection verification around readable thread projections
This commit is contained in:
1 parent
82ffe9862c
commit
efdf72ec8c
26 files changed
+1081
-266
No files matched your search
@@ -65,7 +65,12 @@ describe("V2 client presentation", () => {
|
||||
expect(thread.runtime?.status).toBe("running");
|
||||
expect(thread.runs).toHaveLength(1);
|
||||
expect(thread.availableActions.canInterrupt).toBe(true);
|
||||
expect(thread.messages[0]).toMatchObject({ text: "Hello", runId });
|
||||
expect(thread.messages[0]).toMatchObject({
|
||||
text: "Hello",
|
||||
runId,
|
||||
createdBy: "user",
|
||||
creationSource: "web",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the complete payload for generic V2 work-item rendering", () => {
|
||||
|
||||
@@ -7,6 +7,8 @@ import type {
|
||||
MessageId,
|
||||
OrchestrationProjectShell,
|
||||
OrchestrationV2PlanArtifact,
|
||||
OrchestrationV2Actor,
|
||||
OrchestrationV2CreationSource,
|
||||
OrchestrationV2ProviderCapabilities,
|
||||
OrchestrationV2RunStatus,
|
||||
OrchestrationV2ShellSnapshot,
|
||||
@@ -83,6 +85,8 @@ export interface ThreadConversationMessage {
|
||||
readonly attachments?: ReadonlyArray<ChatAttachment>;
|
||||
readonly runId: RunId | null;
|
||||
readonly streaming: boolean;
|
||||
readonly createdBy?: OrchestrationV2Actor;
|
||||
readonly creationSource?: OrchestrationV2CreationSource;
|
||||
readonly createdAt: string;
|
||||
readonly updatedAt: string;
|
||||
}
|
||||
@@ -371,10 +375,16 @@ function summarizeWorkItem(item: OrchestrationV2TurnItem): {
|
||||
};
|
||||
case "fork":
|
||||
return { label: title ?? "Thread forked", detail: item.targetThreadId, toolData: item };
|
||||
case "thread_created":
|
||||
return {
|
||||
label: title ?? "Thread created",
|
||||
detail: `${item.targetProviderInstanceId} · ${item.targetModel}`,
|
||||
toolData: item,
|
||||
};
|
||||
case "subagent":
|
||||
return {
|
||||
label: title ?? "Subagent",
|
||||
detail: item.result ?? item.prompt,
|
||||
detail: item.result ?? item.progress ?? item.prompt,
|
||||
toolTitle: title ?? "Subagent",
|
||||
toolData: item,
|
||||
};
|
||||
@@ -535,6 +545,8 @@ function presentMessages(
|
||||
attachments: message.attachments,
|
||||
runId: message.runId,
|
||||
streaming: message.streaming,
|
||||
createdBy: message.createdBy,
|
||||
creationSource: message.creationSource,
|
||||
createdAt: iso(message.createdAt),
|
||||
updatedAt: iso(message.updatedAt),
|
||||
}));
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
|
||||
const now = DateTime.makeUnsafe("2026-04-20T00:00:00.000Z");
|
||||
const decodeOrchestrationV2Command = Schema.decodeUnknownSync(OrchestrationV2Command);
|
||||
const decodeOrchestrationV2TurnItem = Schema.decodeUnknownSync(OrchestrationV2TurnItem);
|
||||
|
||||
describe("orchestration V2 contracts", () => {
|
||||
it("decodes nested checkpoint scopes without making child scopes advance app run count", () => {
|
||||
@@ -162,6 +163,50 @@ describe("orchestration V2 contracts", () => {
|
||||
expect(command.parentNodeId).toBe(NodeId.make("node-parent-1"));
|
||||
});
|
||||
|
||||
it("decodes durable created-thread timeline records", () => {
|
||||
const command = decodeOrchestrationV2Command({
|
||||
type: "thread.created.record",
|
||||
commandId: "command-thread-record-1",
|
||||
parentThreadId: "thread-parent-1",
|
||||
parentRunId: "run-parent-1",
|
||||
parentNodeId: "node-parent-1",
|
||||
targetThreadId: "thread-child-1",
|
||||
targetRunId: "run-child-1",
|
||||
});
|
||||
const item = decodeOrchestrationV2TurnItem({
|
||||
id: "turn-item-thread-created-1",
|
||||
type: "thread_created",
|
||||
threadId: "thread-parent-1",
|
||||
runId: "run-parent-1",
|
||||
nodeId: "node-parent-1",
|
||||
providerThreadId: "provider-thread-parent-1",
|
||||
providerTurnId: null,
|
||||
nativeItemRef: null,
|
||||
parentItemId: null,
|
||||
ordinal: 4,
|
||||
status: "completed",
|
||||
title: "Child thread",
|
||||
targetThreadId: "thread-child-1",
|
||||
targetRunId: "run-child-1",
|
||||
targetProviderInstanceId: "claude-default",
|
||||
targetModel: "claude-sonnet-4-6",
|
||||
startedAt: now,
|
||||
completedAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
|
||||
expect(command.type).toBe("thread.created.record");
|
||||
if (command.type !== "thread.created.record") {
|
||||
throw new Error("expected thread.created.record");
|
||||
}
|
||||
expect(command.targetThreadId).toBe(ThreadId.make("thread-child-1"));
|
||||
expect(item.type).toBe("thread_created");
|
||||
if (item.type !== "thread_created") {
|
||||
throw new Error("expected thread_created");
|
||||
}
|
||||
expect(item.targetRunId).toBe(RunId.make("run-child-1"));
|
||||
});
|
||||
|
||||
it("decodes provider-neutral replay transcripts", () => {
|
||||
const transcript = Schema.decodeUnknownSync(ProviderReplayTranscript)({
|
||||
provider: "codex",
|
||||
@@ -302,6 +347,7 @@ describe("orchestration V2 contracts", () => {
|
||||
title: "Package audit",
|
||||
model: "gpt-5.4",
|
||||
status: "completed",
|
||||
progress: "Inspecting package metadata",
|
||||
result: "Package is private.",
|
||||
startedAt: now,
|
||||
completedAt: now,
|
||||
@@ -326,6 +372,7 @@ describe("orchestration V2 contracts", () => {
|
||||
providerInstanceId: subagent.providerInstanceId,
|
||||
childThreadId: subagent.childThreadId,
|
||||
prompt: subagent.prompt,
|
||||
progress: subagent.progress,
|
||||
result: subagent.result,
|
||||
startedAt: now,
|
||||
completedAt: now,
|
||||
@@ -333,8 +380,11 @@ describe("orchestration V2 contracts", () => {
|
||||
});
|
||||
|
||||
expect(subagent.origin).toBe("provider_native");
|
||||
expect(subagent.progress).toBe("Inspecting package metadata");
|
||||
expect(subagent.childThreadId).toBeNull();
|
||||
expect(turnItem.type).toBe("subagent");
|
||||
if (turnItem.type !== "subagent") throw new Error("expected subagent item");
|
||||
expect(turnItem.progress).toBe("Inspecting package metadata");
|
||||
});
|
||||
|
||||
it("decodes thread projections with an ordered turn item rendering stream", () => {
|
||||
|
||||
@@ -442,6 +442,7 @@ export const OrchestrationV2Subagent = Schema.Struct({
|
||||
"cancelled",
|
||||
"interrupted",
|
||||
]),
|
||||
progress: Schema.optional(Schema.String),
|
||||
result: Schema.NullOr(Schema.String),
|
||||
startedAt: Schema.NullOr(Schema.DateTimeUtc),
|
||||
completedAt: Schema.NullOr(Schema.DateTimeUtc),
|
||||
@@ -903,6 +904,14 @@ export const OrchestrationV2TurnItem = Schema.Union([
|
||||
targetThreadId: ThreadId,
|
||||
providerThreadId: Schema.optional(ProviderThreadId),
|
||||
}),
|
||||
Schema.Struct({
|
||||
...OrchestrationV2TurnItemBaseFields,
|
||||
type: Schema.Literal("thread_created"),
|
||||
targetThreadId: ThreadId,
|
||||
targetRunId: Schema.NullOr(RunId),
|
||||
targetProviderInstanceId: ProviderInstanceId,
|
||||
targetModel: TrimmedNonEmptyString,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...OrchestrationV2TurnItemBaseFields,
|
||||
type: Schema.Literal("subagent"),
|
||||
@@ -912,6 +921,7 @@ export const OrchestrationV2TurnItem = Schema.Union([
|
||||
providerInstanceId: ProviderInstanceId,
|
||||
childThreadId: Schema.NullOr(ThreadId),
|
||||
prompt: Schema.String,
|
||||
progress: Schema.optional(Schema.String),
|
||||
result: Schema.NullOr(Schema.String),
|
||||
}),
|
||||
Schema.Struct({
|
||||
@@ -1488,6 +1498,14 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
|
||||
targetThreadId: ThreadId,
|
||||
providerThreadId: Schema.optional(ProviderThreadId),
|
||||
}),
|
||||
Schema.Struct({
|
||||
...OrchestrationV2TurnItemJsonBaseFields,
|
||||
type: Schema.Literal("thread_created"),
|
||||
targetThreadId: ThreadId,
|
||||
targetRunId: Schema.NullOr(RunId),
|
||||
targetProviderInstanceId: ProviderInstanceId,
|
||||
targetModel: TrimmedNonEmptyString,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...OrchestrationV2TurnItemJsonBaseFields,
|
||||
type: Schema.Literal("subagent"),
|
||||
@@ -1497,6 +1515,7 @@ export const OrchestrationV2TurnItemJson = Schema.Union([
|
||||
providerInstanceId: ProviderInstanceId,
|
||||
childThreadId: Schema.NullOr(ThreadId),
|
||||
prompt: Schema.String,
|
||||
progress: Schema.optional(Schema.String),
|
||||
result: Schema.NullOr(Schema.String),
|
||||
}),
|
||||
Schema.Struct({
|
||||
@@ -1821,6 +1840,15 @@ export const OrchestrationV2Command = Schema.Union([
|
||||
interactionMode: ProviderInteractionMode,
|
||||
createdAt: Schema.optional(Schema.DateTimeUtc),
|
||||
}),
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("thread.created.record"),
|
||||
commandId: CommandId,
|
||||
parentThreadId: ThreadId,
|
||||
parentRunId: RunId,
|
||||
parentNodeId: NodeId,
|
||||
targetThreadId: ThreadId,
|
||||
targetRunId: Schema.NullOr(RunId),
|
||||
}),
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("provider.switch"),
|
||||
commandId: CommandId,
|
||||
|
||||
Reference in new issue
Block a user