fix(orchestrator): harden Grok v2 lifecycle (#3578)
Integrate the current Grok settlement, monitor/subagent lifecycle, interrupt containment, steer visibility, and image support stack into the orchestration-v2 branch. Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
0282ab8608
commit
e16d4e514b
53 files changed
+15859
-985
No files matched your search
@@ -56,4 +56,20 @@ describe("projectThreadAwarenessV2", () => {
|
||||
}),
|
||||
).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
|
||||
});
|
||||
|
||||
it("does not present authentication refreshes as user approvals", () => {
|
||||
expect(
|
||||
projectThreadAwarenessV2({
|
||||
environmentId: "env-1" as EnvironmentId,
|
||||
project,
|
||||
thread: v2Thread({
|
||||
pendingRuntimeRequest: {
|
||||
id: RuntimeRequestId.make("request-auth-refresh"),
|
||||
kind: "auth_refresh",
|
||||
createdAt: updatedAt,
|
||||
},
|
||||
}),
|
||||
}),
|
||||
).toMatchObject({ phase: "running", headline: "Agent is working" });
|
||||
});
|
||||
});
|
||||
@@ -87,7 +87,10 @@ function resolveThreadAwarenessPhaseV2(
|
||||
if (thread.pendingRuntimeRequest?.kind === "user_input") {
|
||||
return "waiting_for_input";
|
||||
}
|
||||
if (thread.pendingRuntimeRequest !== null) {
|
||||
if (
|
||||
thread.pendingRuntimeRequest !== null &&
|
||||
thread.pendingRuntimeRequest.kind !== "auth_refresh"
|
||||
) {
|
||||
return "waiting_for_approval";
|
||||
}
|
||||
switch (thread.status) {
|
||||
|
||||
@@ -7,22 +7,52 @@ const runId = RunId.make("run:timeline-visibility");
|
||||
const nodeId = NodeId.make("node:timeline-visibility");
|
||||
|
||||
describe("isOrchestrationV2TurnItemVisible", () => {
|
||||
it("hides interruption results from superseded attempts", () => {
|
||||
it("hides unpaired interruption results from superseded attempts", () => {
|
||||
expect(
|
||||
isOrchestrationV2TurnItemVisible({
|
||||
item: { type: "run_interrupt_result", runId, nodeId },
|
||||
runs: [{ id: runId, status: "running" }],
|
||||
attempts: [{ runId, rootNodeId: nodeId, status: "superseded" }],
|
||||
items: [{ type: "run_interrupt_result", runId, nodeId }],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps interruption results from terminal attempts", () => {
|
||||
it("keeps paired interruption results from superseded attempts", () => {
|
||||
expect(
|
||||
isOrchestrationV2TurnItemVisible({
|
||||
item: { type: "run_interrupt_result", runId, nodeId },
|
||||
runs: [{ id: runId, status: "running" }],
|
||||
attempts: [{ runId, rootNodeId: nodeId, status: "superseded" }],
|
||||
items: [
|
||||
{ type: "run_interrupt_request", runId, nodeId },
|
||||
{ type: "run_interrupt_result", runId, nodeId },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps interruption results from terminal attempts without a request", () => {
|
||||
expect(
|
||||
isOrchestrationV2TurnItemVisible({
|
||||
item: { type: "run_interrupt_result", runId, nodeId },
|
||||
runs: [{ id: runId, status: "interrupted" }],
|
||||
attempts: [{ runId, rootNodeId: nodeId, status: "interrupted" }],
|
||||
items: [{ type: "run_interrupt_result", runId, nodeId }],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps interruption results from terminal attempts with a request", () => {
|
||||
expect(
|
||||
isOrchestrationV2TurnItemVisible({
|
||||
item: { type: "run_interrupt_result", runId, nodeId },
|
||||
runs: [{ id: runId, status: "interrupted" }],
|
||||
attempts: [{ runId, rootNodeId: nodeId, status: "interrupted" }],
|
||||
items: [
|
||||
{ type: "run_interrupt_request", runId, nodeId },
|
||||
{ type: "run_interrupt_result", runId, nodeId },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
@@ -40,6 +70,7 @@ describe("isOrchestrationV2TurnItemVisible", () => {
|
||||
},
|
||||
{ runId, rootNodeId: nodeId, status: "interrupted" },
|
||||
],
|
||||
items: [{ type: "run_interrupt_result", runId, nodeId }],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
@@ -11,24 +11,36 @@ type TimelineTurnItem = Pick<OrchestrationV2TurnItem, "type" | "runId" | "nodeId
|
||||
export function isOrchestrationV2SupersededInterrupt(input: {
|
||||
readonly item: TimelineTurnItem;
|
||||
readonly attempts: ReadonlyArray<TimelineRunAttempt>;
|
||||
readonly items: ReadonlyArray<TimelineTurnItem>;
|
||||
}): boolean {
|
||||
const { item } = input;
|
||||
if (item.type !== "run_interrupt_result" || item.runId === null || item.nodeId === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return input.attempts.some(
|
||||
const isSuperseded = input.attempts.some(
|
||||
(attempt) =>
|
||||
attempt.runId === item.runId &&
|
||||
attempt.rootNodeId === item.nodeId &&
|
||||
attempt.status === "superseded",
|
||||
);
|
||||
if (!isSuperseded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Paired stop-then-steer results have a matching request on the same run and
|
||||
// must stay visible. Legacy plain-steer results have no request and stay hidden.
|
||||
const hasMatchingRequest = input.items.some(
|
||||
(candidate) => candidate.type === "run_interrupt_request" && candidate.runId === item.runId,
|
||||
);
|
||||
return !hasMatchingRequest;
|
||||
}
|
||||
|
||||
export function isOrchestrationV2TurnItemVisible(input: {
|
||||
readonly item: TimelineTurnItem;
|
||||
readonly runs: ReadonlyArray<TimelineRun>;
|
||||
readonly attempts: ReadonlyArray<TimelineRunAttempt>;
|
||||
readonly items: ReadonlyArray<TimelineTurnItem>;
|
||||
}): boolean {
|
||||
const { item } = input;
|
||||
if (
|
||||
@@ -38,5 +50,9 @@ export function isOrchestrationV2TurnItemVisible(input: {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isOrchestrationV2SupersededInterrupt({ item, attempts: input.attempts });
|
||||
return !isOrchestrationV2SupersededInterrupt({
|
||||
item,
|
||||
attempts: input.attempts,
|
||||
items: input.items,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user