Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
Not sure
Steps to reproduce
- Configure a Codex preCompact hook that stops the turn with an explanatory message.
- Ask an agent to delegate a long Codex task that sends a progress update before it needs compaction.
- Let the delegated task reach compaction and be stopped by the hook.
- Ask the parent agent to read the delegated task result.
Expected behavior
The task result includes the hook stop reason alongside the last assistant message.
Actual behavior
The task is reported as completed with only its last progress message; the parent does not receive the hook stop reason.
Impact
Minor bug or occasional failure. People delegating Codex tasks encounter this whenever a hook stops a completed turn after assistant text has been emitted, leaving the parent unaware of why work stopped.
Version or commit
main at 6dd092315e. The cause is at packages/provider-core/src/server/subagentProjection.ts:256.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
expected 'I am checking the remaining files.' to contain 'preCompact hook (project): Save a curAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/apps/server/src/orchestration-v2/SubagentProjection.test.ts b/apps/server/src/orchestration-v2/SubagentProjection.test.ts
index 2f764233ba..3e53008c1a 100644
--- a/apps/server/src/orchestration-v2/SubagentProjection.test.ts
+++ b/apps/server/src/orchestration-v2/SubagentProjection.test.ts
@@ -1,4 +1,5 @@
import { assert, it } from "@effect/vitest";
+import { expect } from "vite-plus/test";
import {
CommandId,
EnvironmentId,
@@ -403,7 +404,7 @@ it("exposes the provider failure rather than a progress message from the failed
assert.isNull(result.messageId);
});
-it("reports a provider's stop reason for a completed run without an assistant result", () => {
+it("reports a provider's stop reason with and without assistant progress", () => {
const { projection, run } = taskFixture();
const notice = {
id: IdAllocator.derive.runSignalTurnItem({
@@ -425,12 +426,35 @@ it("reports a provider's stop reason for a completed run without an assistant re
updatedAt: childCreatedAt,
type: "system_notice",
level: "warning",
- message: "sessionStart hook (user): Plugin guard blocked this session.",
+ message: "preCompact hook (project): Save a current task checkpoint before compaction.",
} satisfies OrchestrationV2TurnItem;
assert.equal(
subagentResultForRun({ ...projection, turnItems: [notice] }, run).text,
`Child task completed without an assistant result.\n\n${notice.message}`,
);
+ const progress = makeSubagentConversationArtifacts({
+ messageId: MessageId.make("before-hook-stop"),
+ turnItemId: TurnItemId.make("before-hook-stop"),
+ threadId: parentThreadId,
+ rootNodeId: NodeId.make("root"),
+ providerThreadId: null,
+ providerTurnId: null,
+ nativeItemRef: null,
+ role: "assistant",
+ text: "I am checking the remaining files.",
+ ordinal: 1,
+ now: childCreatedAt,
+ });
+ const result = subagentResultForRun(
+ {
+ ...projection,
+ messages: [{ ...progress.message, runId: run.id }],
+ turnItems: [{ ...progress.turnItem, runId: run.id }, notice],
+ },
+ run,
+ );
+ expect(result.text).toContain(progress.message.text);
+ expect(result.text).toContain(notice.message);
});
it("keeps the final report of a run that failed after its turn ended", () => {cd apps/server && pnpm exec vp test run src/orchestration-v2/SubagentProjection.test.ts -t 'reports a provider'Workaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity