fix: bound code queue cli noise
This commit is contained in:
+94
-41
@@ -5,22 +5,27 @@ import { coreInternalFetch } from "./microservices";
|
||||
import { previewJson } from "./preview";
|
||||
import { codeAgentPortForModel, codeModelPorts as sharedCodeModelPorts, defaultCodeModels as sharedDefaultCodeModels, opencodeModels as sharedOpencodeModels } from "../../src/components/microservices/code-queue/src/code-agent/common";
|
||||
|
||||
const defaultToolLimit = 8;
|
||||
const defaultToolLimit = 3;
|
||||
const defaultTraceLimit = 80;
|
||||
const maxTraceLimit = 500;
|
||||
const defaultOutputLimit = 20;
|
||||
const defaultTextPreviewChars = 12_000;
|
||||
const defaultOutputPreviewChars = 500;
|
||||
const maxOutputPreviewChars = 1200;
|
||||
const defaultTasksLimit = 20;
|
||||
const defaultQueuesLimit = 8;
|
||||
const maxTasksLimit = 100;
|
||||
const supervisorSectionReturnedLimit = 5;
|
||||
const supervisorRecentCompletedLimit = 5;
|
||||
const supervisorPromptPreviewChars = 90;
|
||||
const supervisorBodyPreviewChars = 90;
|
||||
const supervisorRecentBodyPreviewChars = 60;
|
||||
const supervisorSectionReturnedLimit = 3;
|
||||
const supervisorRecentCompletedLimit = 3;
|
||||
const supervisorPromptPreviewChars = 70;
|
||||
const supervisorBodyPreviewChars = 70;
|
||||
const supervisorRecentBodyPreviewChars = 50;
|
||||
const diagnosticsIdPreviewLimit = 3;
|
||||
const diagnosticsReasonPreviewLimit = 2;
|
||||
const steerPromptPreviewChars = 320;
|
||||
const detailAttemptReturnedLimit = 3;
|
||||
const detailInitialPromptPreviewChars = 1200;
|
||||
const detailBasePromptPreviewChars = 800;
|
||||
const detailLastAssistantPreviewChars = 1200;
|
||||
const minimaxSubmitModel = "minimax-m2.7";
|
||||
const deepseekSubmitModel = "deepseek-chat";
|
||||
const gptSubmitModel = "gpt-5.5";
|
||||
@@ -42,6 +47,7 @@ interface CodexTaskOptions {
|
||||
}
|
||||
|
||||
interface CodexOutputOptions {
|
||||
requestedLimit: number;
|
||||
limit: number;
|
||||
mode: "tail" | "after" | "before";
|
||||
afterSeq: number;
|
||||
@@ -654,13 +660,13 @@ function compactText(text: unknown, full: boolean, maxChars: number): Record<str
|
||||
return textView(asString(text), full, maxChars);
|
||||
}
|
||||
|
||||
function compactLastAssistant(value: unknown, full: boolean): Record<string, unknown> {
|
||||
function compactLastAssistant(value: unknown, full: boolean, maxChars = 4000): Record<string, unknown> {
|
||||
const record = asRecord(value) ?? {};
|
||||
return {
|
||||
at: record.at ?? null,
|
||||
seq: record.seq ?? null,
|
||||
source: record.source ?? "none",
|
||||
...textView(asString(record.text), full, 4000),
|
||||
...textView(asString(record.text), full, maxChars),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1255,9 +1261,11 @@ function supervisorExecutionDiagnostics(value: unknown): Record<string, unknown>
|
||||
};
|
||||
}
|
||||
|
||||
function compactToolSummary(value: unknown, full: boolean): Record<string, unknown> {
|
||||
function compactToolSummary(value: unknown, full: boolean, limit = defaultToolLimit): Record<string, unknown> {
|
||||
const record = asRecord(value) ?? {};
|
||||
const items = asArray(record.items).map((item) => {
|
||||
const allItems = asArray(record.items);
|
||||
const sourceItems = full ? allItems : allItems.slice(0, limit);
|
||||
const items = sourceItems.map((item) => {
|
||||
const line = asRecord(item) ?? {};
|
||||
return {
|
||||
seq: line.seq ?? null,
|
||||
@@ -1265,18 +1273,18 @@ function compactToolSummary(value: unknown, full: boolean): Record<string, unkno
|
||||
kind: line.kind ?? null,
|
||||
title: line.title ?? "",
|
||||
status: line.status ?? null,
|
||||
commandPreview: compactText(line.commandPreview, full, 1200),
|
||||
commandPreview: compactText(line.commandPreview, full, 360),
|
||||
commandOmittedLines: line.commandOmittedLines ?? 0,
|
||||
outputPreview: compactText(line.outputPreview, full, 800),
|
||||
outputPreview: compactText(line.outputPreview, full, 360),
|
||||
outputOmittedLines: line.outputOmittedLines ?? 0,
|
||||
rawSeqs: line.rawSeqs ?? [],
|
||||
};
|
||||
});
|
||||
return {
|
||||
count: record.count ?? 0,
|
||||
returned: record.returned ?? items.length,
|
||||
limit: record.limit ?? items.length,
|
||||
truncated: record.truncated ?? false,
|
||||
count: record.count ?? allItems.length,
|
||||
returned: items.length,
|
||||
limit,
|
||||
truncated: record.truncated === true || (!full && allItems.length > items.length),
|
||||
items,
|
||||
};
|
||||
}
|
||||
@@ -1286,8 +1294,11 @@ function compactSummary(summary: unknown, options: CodexTaskOptions, taskId: str
|
||||
const transcriptCount = asNumber(record.transcriptCount, 0);
|
||||
const transcriptMaxSeq = transcriptCount > 0 ? record.transcriptMaxSeq ?? null : null;
|
||||
const initialPrompt = asString(record.initialPrompt ?? record.prompt);
|
||||
const initialPromptView = textView(initialPrompt, options.full, 3000);
|
||||
const basePromptView = textView(asString(record.basePrompt), options.full, 2000);
|
||||
const initialPromptView = textView(initialPrompt, options.full, detailInitialPromptPreviewChars);
|
||||
const basePromptView = textView(asString(record.basePrompt), options.full, detailBasePromptPreviewChars);
|
||||
const attemptRecordsSource = asArray(record.attempts);
|
||||
const attemptRecords = (options.full ? attemptRecordsSource : attemptRecordsSource.slice(0, detailAttemptReturnedLimit))
|
||||
.map((attempt) => compactAttemptCycle(attempt, options.full));
|
||||
return {
|
||||
id: record.id ?? taskId,
|
||||
queueId: record.queueId ?? null,
|
||||
@@ -1304,7 +1315,10 @@ function compactSummary(summary: unknown, options: CodexTaskOptions, taskId: str
|
||||
currentMode: record.currentMode ?? null,
|
||||
judgeFailCount: record.judgeFailCount ?? null,
|
||||
judgeFailRetryLimit: record.judgeFailRetryLimit ?? null,
|
||||
attemptRecords: asArray(record.attempts).map((attempt) => compactAttemptCycle(attempt, options.full)),
|
||||
attemptRecordCount: attemptRecordsSource.length,
|
||||
attemptRecordsReturned: attemptRecords.length,
|
||||
attemptRecordsTruncated: !options.full && attemptRecordsSource.length > attemptRecords.length,
|
||||
attemptRecords,
|
||||
},
|
||||
thread: {
|
||||
codexThreadId: record.codexThreadId ?? null,
|
||||
@@ -1322,10 +1336,10 @@ function compactSummary(summary: unknown, options: CodexTaskOptions, taskId: str
|
||||
: { initialPromptPreview: initialPromptView, basePromptPreview: basePromptView }),
|
||||
referenceTaskIds: record.referenceTaskIds ?? [],
|
||||
referenceInjection: record.referenceInjection ?? null,
|
||||
lastAssistantMessage: compactLastAssistant(record.lastAssistantMessage, options.full),
|
||||
lastAssistantMessage: compactLastAssistant(record.lastAssistantMessage, options.full, detailLastAssistantPreviewChars),
|
||||
lastJudge: record.lastJudge ?? null,
|
||||
lastError: record.lastError ?? null,
|
||||
toolSummary: compactToolSummary(record.toolSummary, options.full),
|
||||
toolSummary: compactToolSummary(record.toolSummary, options.full, options.toolLimit),
|
||||
counts: {
|
||||
transcript: record.transcriptCount ?? null,
|
||||
output: record.outputCount ?? null,
|
||||
@@ -1336,6 +1350,7 @@ function compactSummary(summary: unknown, options: CodexTaskOptions, taskId: str
|
||||
renderer: "shared trace-summary/trace-steps progressive abstraction; CLI and WebUI diverge only at final rendering",
|
||||
total: record.transcriptCount ?? null,
|
||||
maxSeq: transcriptMaxSeq,
|
||||
detailOutputPolicy: "bounded detail by default; use --full, --trace, --tool-limit, or codex output for progressive disclosure",
|
||||
defaultPage: `bun scripts/cli.ts codex task ${taskId} --trace --limit ${defaultTraceLimit}`,
|
||||
firstPage: `bun scripts/cli.ts codex task ${taskId} --trace --from-start --limit ${defaultTraceLimit}`,
|
||||
nextPageTemplate: `bun scripts/cli.ts codex task ${taskId} --trace --after-seq <nextAfterSeq> --limit ${defaultTraceLimit}`,
|
||||
@@ -1449,16 +1464,16 @@ function compactAttemptCycle(value: unknown, full: boolean): Record<string, unkn
|
||||
appServerExitCode: record.appServerExitCode ?? null,
|
||||
appServerSignal: record.appServerSignal ?? null,
|
||||
error: record.error ?? null,
|
||||
stderrTail: textView(asString(record.stderrTail), full, 1200),
|
||||
stderrTail: textView(asString(record.stderrTail), full, 600),
|
||||
startedAt: record.startedAt ?? null,
|
||||
finishedAt: record.finishedAt ?? null,
|
||||
startSeq: record.startSeq ?? null,
|
||||
endSeq: record.endSeq ?? null,
|
||||
execution: record.execution ?? null,
|
||||
finalResponse: textView(asString(record.finalResponsePreview ?? record.finalResponse), full, 3000),
|
||||
finalResponse: textView(asString(record.finalResponsePreview ?? record.finalResponse), full, 1200),
|
||||
judge: record.judge ?? null,
|
||||
runnerErrorClassification: record.runnerErrorClassification ?? null,
|
||||
feedbackPrompt: textView(asString(record.feedbackPromptPreview), full, 1800),
|
||||
feedbackPrompt: textView(asString(record.feedbackPromptPreview), full, 800),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1588,13 +1603,16 @@ function parseOutputOptions(args: string[]): CodexOutputOptions {
|
||||
const afterSeq = nonNegativeNumberOption(args, ["--after-seq", "--afterSeq"], 0);
|
||||
const fromStart = hasFlag(args, "--from-start") || hasFlag(args, "--first");
|
||||
const mode = beforeSeq !== null ? "before" : fromStart || args.some((arg) => arg === "--after-seq" || arg === "--afterSeq") ? "after" : "tail";
|
||||
const fullText = hasFlag(args, "--full-text") || hasFlag(args, "--raw");
|
||||
const requestedLimit = positiveIntegerOption(args, ["--limit"], defaultOutputLimit, maxTraceLimit);
|
||||
return {
|
||||
limit: positiveIntegerOption(args, ["--limit"], defaultOutputLimit, maxTraceLimit),
|
||||
requestedLimit,
|
||||
limit: fullText ? requestedLimit : Math.min(requestedLimit, defaultOutputLimit),
|
||||
mode,
|
||||
afterSeq,
|
||||
beforeSeq,
|
||||
fullText: hasFlag(args, "--full-text") || hasFlag(args, "--raw"),
|
||||
maxTextChars: positiveIntegerOption(args, ["--max-text-chars"], defaultTextPreviewChars, 500_000),
|
||||
fullText,
|
||||
maxTextChars: positiveIntegerOption(args, ["--max-text-chars"], defaultOutputPreviewChars, fullText ? 500_000 : maxOutputPreviewChars),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1706,8 +1724,23 @@ function codexTaskSummary(taskId: string, options: CodexTaskOptions, fetcher: Co
|
||||
return result;
|
||||
}
|
||||
|
||||
function compactOutputPage(body: Record<string, unknown>, taskId: string, limit: number): Record<string, unknown> {
|
||||
const output = asArray(body.output);
|
||||
function compactOutputRecord(item: unknown, options: CodexOutputOptions): Record<string, unknown> {
|
||||
const record = asRecord(item) ?? {};
|
||||
const text = textView(asString(record.text), options.fullText, options.maxTextChars);
|
||||
return {
|
||||
seq: record.seq ?? null,
|
||||
at: record.at ?? null,
|
||||
channel: record.channel ?? null,
|
||||
method: record.method ?? null,
|
||||
itemId: record.itemId ?? null,
|
||||
text: text.text,
|
||||
textChars: text.chars,
|
||||
...(text.truncated ? { textTruncated: true, textOmittedChars: text.omittedChars } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function compactOutputPage(body: Record<string, unknown>, taskId: string, options: CodexOutputOptions): Record<string, unknown> {
|
||||
const output = asArray(body.output).map((item) => compactOutputRecord(item, options));
|
||||
const nextAfterSeq = body.nextAfterSeq ?? null;
|
||||
const previousBeforeSeq = body.previousBeforeSeq ?? null;
|
||||
return {
|
||||
@@ -1716,7 +1749,8 @@ function compactOutputPage(body: Record<string, unknown>, taskId: string, limit:
|
||||
status: body.status ?? null,
|
||||
updatedAt: body.updatedAt ?? null,
|
||||
mode: body.mode ?? null,
|
||||
limit,
|
||||
requestedLimit: options.requestedLimit,
|
||||
limit: options.limit,
|
||||
returned: output.length,
|
||||
total: body.total ?? null,
|
||||
maxSeq: body.maxSeq ?? null,
|
||||
@@ -1726,13 +1760,21 @@ function compactOutputPage(body: Record<string, unknown>, taskId: string, limit:
|
||||
previousBeforeSeq,
|
||||
hasMore: body.hasMore ?? false,
|
||||
hasBefore: body.hasBefore ?? false,
|
||||
disclosure: {
|
||||
defaultPolicy: "bounded output rows and bounded text previews; use --full-text with an explicit seq window only when raw text is required",
|
||||
limitCapped: !options.fullText && options.limit < options.requestedLimit,
|
||||
fullText: options.fullText,
|
||||
textPreviewChars: options.maxTextChars,
|
||||
requestedLimit: options.requestedLimit,
|
||||
effectiveLimit: options.limit,
|
||||
},
|
||||
output,
|
||||
commands: {
|
||||
next: body.hasMore === true && nextAfterSeq !== null ? `bun scripts/cli.ts codex output ${taskId} --after-seq ${nextAfterSeq} --limit ${limit}` : null,
|
||||
previous: body.hasBefore === true && previousBeforeSeq !== null ? `bun scripts/cli.ts codex output ${taskId} --before-seq ${previousBeforeSeq} --limit ${limit}` : null,
|
||||
tail: `bun scripts/cli.ts codex output ${taskId} --tail --limit ${limit}`,
|
||||
first: `bun scripts/cli.ts codex output ${taskId} --from-start --limit ${limit}`,
|
||||
fullText: `bun scripts/cli.ts codex output ${taskId} --after-seq <rawSeqBefore> --limit ${limit} --full-text`,
|
||||
next: body.hasMore === true && nextAfterSeq !== null ? `bun scripts/cli.ts codex output ${taskId} --after-seq ${nextAfterSeq} --limit ${options.limit}` : null,
|
||||
previous: body.hasBefore === true && previousBeforeSeq !== null ? `bun scripts/cli.ts codex output ${taskId} --before-seq ${previousBeforeSeq} --limit ${options.limit}` : null,
|
||||
tail: `bun scripts/cli.ts codex output ${taskId} --tail --limit ${options.limit}`,
|
||||
first: `bun scripts/cli.ts codex output ${taskId} --from-start --limit ${options.limit}`,
|
||||
fullText: `bun scripts/cli.ts codex output ${taskId} --after-seq <rawSeqBefore> --limit ${Math.min(options.requestedLimit, defaultOutputLimit)} --full-text`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1747,7 +1789,7 @@ function codexTaskOutput(taskId: string, options: CodexOutputOptions, fetcher: C
|
||||
if (options.mode === "after") params.afterSeq = options.afterSeq;
|
||||
if (options.mode === "before") params.beforeSeq = options.beforeSeq;
|
||||
const response = unwrapCodexResponse(fetcher(codeQueueProxyPath(`/api/tasks/${encodeURIComponent(taskId)}/output${queryString(params)}`)));
|
||||
return { upstream: response.upstream, outputPage: compactOutputPage(response.body, taskId, options.limit) };
|
||||
return { upstream: response.upstream, outputPage: compactOutputPage(response.body, taskId, options) };
|
||||
}
|
||||
|
||||
function codexTaskJudge(taskId: string, options: CodexJudgeOptions, fetcher: CodexResponseFetcher): unknown {
|
||||
@@ -2389,7 +2431,7 @@ async function codexTaskOutputAsync(taskId: string, options: CodexOutputOptions,
|
||||
if (options.mode === "after") params.afterSeq = options.afterSeq;
|
||||
if (options.mode === "before") params.beforeSeq = options.beforeSeq;
|
||||
const response = unwrapCodexResponse(await fetcher(codeQueueProxyPath(`/api/tasks/${encodeURIComponent(taskId)}/output${queryString(params)}`)));
|
||||
return { upstream: response.upstream, outputPage: compactOutputPage(response.body, taskId, options.limit) };
|
||||
return { upstream: response.upstream, outputPage: compactOutputPage(response.body, taskId, options) };
|
||||
}
|
||||
|
||||
async function codexTaskJudgeAsync(taskId: string, options: CodexJudgeOptions, fetcher: AsyncCodexResponseFetcher): Promise<unknown> {
|
||||
@@ -3882,17 +3924,28 @@ function codexSteerTask(taskId: string, args: string[], fetcher: CodexResponseFe
|
||||
};
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
upstream: response.upstream,
|
||||
steer: {
|
||||
accepted: true,
|
||||
prompt,
|
||||
taskId,
|
||||
promptChars: options.prompt.length,
|
||||
promptOmitted: true,
|
||||
outputPolicy: {
|
||||
default: "write-confirmation",
|
||||
promptEchoed: false,
|
||||
taskDetailEchoed: false,
|
||||
reason: "codex steer is a write operation; default output confirms delivery and provides drill-down commands without echoing prompt text or full task state.",
|
||||
},
|
||||
},
|
||||
task: compactTaskMutationResponse(response.body.task),
|
||||
queue: compactQueueMutationSummary(response.body.queue),
|
||||
task: compactSubmitTaskConfirmation(response.body.task),
|
||||
queue: compactSubmitQueueConfirmation(response.body.queue),
|
||||
commands: {
|
||||
show: `bun scripts/cli.ts codex task ${taskId}`,
|
||||
detail: `bun scripts/cli.ts codex task ${taskId} --detail`,
|
||||
trace: `bun scripts/cli.ts codex task ${taskId} --trace --tail --limit ${defaultTraceLimit}`,
|
||||
output: `bun scripts/cli.ts codex output ${taskId} --tail --limit ${defaultOutputLimit}`,
|
||||
supervisor: `bun scripts/cli.ts codex tasks --view supervisor --limit ${defaultTasksLimit}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user