GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): a cancelled delegated task no longer shows its child's question by flamboh · Pull Request #18459 · pingdotgg/t3code

fix(server): a cancelled delegated task no longer shows its child's question #18459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
maria-rcks merged 8 commits into pingdotgg:main from flamboh:t3/clear-cancelled-agent-questions
Oct 15, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(server): a cancelled delegated task no longer shows its child's question #18459

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
8 commits
Select commit Hold shift + click to select a range
7c90f70
fix(server): a finished delegated task no longer shows its child's qu…
flamboh Oct 12, 2026
503b8f1
fix(server): a declined restart continuation still closes its task's …
flamboh Oct 12, 2026
3b9b63b
fix(server): question dismissal holds the parent lock so a follow-up …
flamboh Oct 12, 2026
60527b5
fix(server): a finished delegated task keeps its child's question
flamboh Oct 14, 2026
67b3a96
refactor(server): simplify cancelled task question cleanup
maria-rcks Oct 14, 2026
22daad8
fix(server): finish cancelled task question cleanup after dismiss fai…
maria-rcks Oct 14, 2026
d505308
fix(server): scope cancelled task questions to their run
maria-rcks Oct 14, 2026
5dcca64
fix(server): defer cancelled task question cleanup reads
maria-rcks Oct 14, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

58 changes: 58 additions & 0 deletions 58 apps/server/src/orchestration-v2/Orchestrator.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10470,6 +10470,64 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
...(progress.resultRun === undefined ? {} : { resultRun: progress.resultRun }),
});
}

const { resultRun } = progress;
if (progress.state !== "result_available" || resultRun === undefined) return;
const status = delegatedTaskTerminalStatus(runOutcome(resultRun));
if (status !== "cancelled" && status !== "interrupted") return;
if (
yield* childAwaitsRestartContinuation(
childControls.runs,
resultRun,
options?.settledContinuationOf,
)
)
return;
// Cancelled or interrupted tasks must not leave async questions that resume the child.
// Callers hold the parent lock; dismiss takes the child lock, as follow-up intake does.
const { runtimeRequests } = yield* projectionStore.getThreadRecords(childThreadId, [
"runtimeRequests",
]);
const pendingQuestions = runtimeRequests.filter(
(request) =>
request.status === "pending" &&
request.kind === "user_input" &&
request.responseCapability.type === "message",
);
if (pendingQuestions.length === 0) return;
const { nodes } = yield* projectionStore.getThreadRecords(childThreadId, ["nodes"]);
const resultRunIds = new Set<RunId>();
let run: OrchestrationV2Run | undefined = resultRun;
while (run !== undefined && !resultRunIds.has(run.id)) {
resultRunIds.add(run.id);
const previousRunId: RunId | undefined = run.restartContinuationOfRunId;
run =
previousRunId === undefined
? undefined
: childControls.runs.find((candidate) => candidate.id === previousRunId);
}
for (const request of pendingQuestions) {
if (
nodes.some(
(node) =>
node.id === request.nodeId && node.runId !== null && resultRunIds.has(node.runId),
)
) {
yield* dispatchWithReceipt({
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

type: "thread.user-input.dismiss",
commandId: CommandId.make(`command:system:delegated-task-question:${request.id}`),
threadId: childThreadId,
requestId: request.id,
}).pipe(
Effect.catchCause((cause) =>
Effect.logWarning("Failed to dismiss task question", {
requestId: request.id,
cause,
}),
),
);
}
}
});

const finalizeDelegatedCompletionDelivery = (threadId: ThreadId, runId: RunId) =>
Expand Down
73 changes: 73 additions & 0 deletions 73 apps/server/src/orchestration-v2/ThreadStop.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ProviderInstanceId,
ProviderSessionId,
ProviderTurnId,
RuntimeRequestId,
ThreadId,
TurnItemId,
} from "@t3tools/contracts";
Expand Down Expand Up @@ -539,6 +540,78 @@ it.effect.each(["thread.stop", "run.interrupt"] as const)(
}).pipe(Effect.provide(layerTest.pipe(Layer.provideMerge(TestClock.layer())))),
);

it.effect.each([
{ ending: "cancelled", question: "resolved" },
{ ending: "interrupted", question: "resolved" },
{ ending: "completed", question: "pending" },
{ ending: "failed", question: "pending" },
] as const)(
"a $ending delegated task leaves its async question $question",
({ ending, question }) =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
const projections = yield* ProjectionStore.ProjectionStoreV2;
const parentThreadId = ThreadId.make(`thread:stop-question-parent:${ending}`);
yield* createWatchingThread(parentThreadId, 20);
yield* send(parentThreadId, "first", "start_immediately");
const childThreadId = yield* delegate(parentThreadId, `question task ${ending}`);
const childRun = (yield* orchestrator.getThreadProjection(childThreadId)).runs[0]!;
assert.equal(
(yield* orchestrator.getThreadProjection(childThreadId)).nodes.find(
(node) => node.id === childRun.rootNodeId,
)?.runId,
childRun.id,
);
const now = yield* DateTime.now;
yield* projections.apply({
id: EventId.make("event:stop-question:request"),
type: "runtime-request.updated",
threadId: childThreadId,
runId: childRun.id,
occurredAt: now,
payload: {
id: RuntimeRequestId.make("request:stop-question"),
nodeId: childRun.rootNodeId!,
providerTurnId: null,
nativeRequestRef: null,
kind: "user_input",
status: "pending",
responseCapability: { type: "message" },
createdAt: now,
resolvedAt: null,
},
});
const request = Effect.map(
orchestrator.getThreadProjection(childThreadId),
(projection) => projection.runtimeRequests[0],
);

// While the task runs, its question stays open.
yield* orchestrator.recoverDelegatedTask(childThreadId, childRun.id);
assert.equal((yield* request)?.status, "pending");
if (ending === "interrupted") {
// What task_cancel dispatches.
yield* orchestrator.dispatch({
type: "thread.stop",
commandId: CommandId.make("stop-question-child"),
threadId: childThreadId,
});
} else {
yield* projections.apply({
id: EventId.make(`event:stop-question:${ending}`),
type: "run.updated",
threadId: childThreadId,
runId: childRun.id,
occurredAt: now,
payload: { ...childRun, status: ending, startedAt: now, completedAt: now },
});
}
yield* orchestrator.recoverDelegatedTask(childThreadId, childRun.id);
assert.equal((yield* request)?.status, question);
assert.equal((yield* request)?.decision, question === "resolved" ? "cancel" : undefined);
}).pipe(Effect.provide(layerTest)),
);

it.effect("a delegated task that cannot be stopped fails the walk after its siblings stop", () =>
Effect.gen(function* () {
const orchestrator = yield* Orchestrator.OrchestratorV2;
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.