Skip to content

Commit 390d4cf

Browse files
fix(server): a failed triage agent prints the prompt to retry with
When the agent `t3 triage` launches exits non-zero, triage only set the exit code. Its prompt and context files were already written, but nothing said where, so the user could not follow the agent's own advice (such as rerunning with `--no-daemon`). Triage now says which agent exited with what code, lists both files, and prints the launch prompt on its own line to start the agent by hand or paste into any coding agent. The file listing is shared with the no-agent fallback. Fixes #28182 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 894eecd commit 390d4cf

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎apps/server/src/cli/triage.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ it.live("a failed agent launch points at the prompt it could not run", () =>
6060
assert.isDefined(promptFilePath);
6161
assert.include(output, promptFilePath);
6262
assert.include(output, buildTriageLaunchPrompt(promptFilePath));
63+
assert.include(output, NodePath.join(NodePath.dirname(promptFilePath), "context.md"));
6364
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NetService.layer, TestConsole.layer))),
6465
);

‎apps/server/src/cli/triage.ts‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ const runInteractiveSession = (input: {
102102
child.once("exit", (code, signal) => resume(Effect.succeed(code ?? (signal === null ? 0 : 1))));
103103
});
104104

105+
const describeTriageFiles = (session: {
106+
readonly promptFilePath: string;
107+
readonly contextFilePath: string;
108+
}) => [
109+
"The triage prompt and machine context were written to:",
110+
` ${session.promptFilePath}`,
111+
` ${session.contextFilePath}`,
112+
];
113+
105114
const agentFlag = Flag.Literals("agent", ["claude", "codex"]).pipe(
106115
Flag.withDescription("Agent CLI to use. Default: ask when both are installed."),
107116
Flag.optional,
@@ -164,16 +173,14 @@ export const triageCommand = Command.make("triage", {
164173
}
165174

166175
// Windows .cmd shims cannot carry multiline argv; the prompt file also serves as the paste fallback.
167-
const { sessionDir, promptFilePath, contextFilePath } = session;
176+
const { sessionDir, promptFilePath } = session;
168177

169178
if (selected === undefined) {
170179
yield* Console.log(
171180
[
172181
"No supported agent CLI (claude, codex) was found on this machine.",
173182
"",
174-
"The triage prompt and machine context were written to:",
175-
` ${promptFilePath}`,
176-
` ${contextFilePath}`,
183+
...describeTriageFiles(session),
177184
"",
178185
"Paste the prompt file into any coding agent to run triage by hand.",
179186
].join("\n"),
@@ -182,14 +189,26 @@ export const triageCommand = Command.make("triage", {
182189
}
183190

184191
const model = Option.getOrUndefined(flags.model);
192+
const launchPrompt = buildTriageLaunchPrompt(promptFilePath);
185193
const spawnSpec = yield* resolveSpawnCommand(selected.command, [
186194
...(model === undefined ? [] : ["--model", model]),
187-
buildTriageLaunchPrompt(promptFilePath),
195+
launchPrompt,
188196
]);
189197
yield* Console.log(`Starting ${selected.label}. It will ask what went wrong.\n`);
190198
const exitCode = yield* runInteractiveSession({ ...spawnSpec, cwd: sessionDir });
191199
if (exitCode !== 0) {
192200
process.exitCode = exitCode;
201+
yield* Console.log(
202+
[
203+
"",
204+
`${selected.label} exited with code ${String(exitCode)}.`,
205+
"",
206+
...describeTriageFiles(session),
207+
"",
208+
`To retry, start \`${selected.command}\` yourself with any flags it suggested, or use any coding agent, and give it this prompt:`,
209+
launchPrompt,
210+
].join("\n"),
211+
);
193212
}
194213
}),
195214
),

0 commit comments

Comments
 (0)