chore: format and sync protocol outputs

This commit is contained in:
Peter Steinberger
2026-01-16 03:30:56 +00:00
parent a5d8f89b53
commit abcca86e4e
18 changed files with 117 additions and 95 deletions

View File

@@ -126,15 +126,7 @@ describe("cleanupSuspendedCliProcesses", () => {
await cleanupSuspendedCliProcesses(
{
command: "codex",
resumeArgs: [
"exec",
"resume",
"{sessionId}",
"--color",
"never",
"--sandbox",
"read-only",
],
resumeArgs: ["exec", "resume", "{sessionId}", "--color", "never", "--sandbox", "read-only"],
} as CliBackendConfig,
1,
);

View File

@@ -25,8 +25,6 @@ describe("sanitizeUserFacingText", () => {
it("sanitizes raw API error payloads", () => {
const raw = '{"type":"error","error":{"message":"Something exploded","type":"server_error"}}';
expect(sanitizeUserFacingText(raw)).toBe(
"The AI service returned an error. Please try again.",
);
expect(sanitizeUserFacingText(raw)).toBe("The AI service returned an error. Please try again.");
});
});

View File

@@ -230,7 +230,11 @@ export function formatAssistantErrorText(
}
// Catch role ordering errors - including JSON-wrapped and "400" prefix variants
if (/incorrect role information|roles must alternate|400.*role|"message".*role.*information/i.test(raw)) {
if (
/incorrect role information|roles must alternate|400.*role|"message".*role.*information/i.test(
raw,
)
) {
return (
"Message ordering conflict - please try again. " +
"If this persists, use /new to start a fresh session."

View File

@@ -422,7 +422,8 @@ export async function runEmbeddedAttempt(
// Check if last message is a user message to prevent consecutive user turns
const lastMsg = activeSession.messages[activeSession.messages.length - 1];
const lastMsgRole = lastMsg && typeof lastMsg === "object" ? (lastMsg as { role?: unknown }).role : undefined;
const lastMsgRole =
lastMsg && typeof lastMsg === "object" ? (lastMsg as { role?: unknown }).role : undefined;
if (lastMsgRole === "user") {
// Last message was a user message. Adding another user message would create
@@ -433,9 +434,11 @@ export async function runEmbeddedAttempt(
// Skip this prompt to prevent "400 Incorrect role information" error.
log.warn(
`Skipping prompt because last message is a user message (would create consecutive user turns). ` +
`runId=${params.runId} sessionId=${params.sessionId}`
`runId=${params.runId} sessionId=${params.sessionId}`,
);
promptError = new Error(
"Incorrect role information: consecutive user messages would violate role ordering",
);
promptError = new Error("Incorrect role information: consecutive user messages would violate role ordering");
} else {
try {
await activeSession.prompt(params.prompt, { images: params.images });

View File

@@ -27,10 +27,7 @@ function buildSkillsSection(params: {
];
}
function buildMemorySection(params: {
isMinimal: boolean;
availableTools: Set<string>;
}) {
function buildMemorySection(params: { isMinimal: boolean; availableTools: Set<string> }) {
if (params.isMinimal) return [];
if (!params.availableTools.has("memory_search") && !params.availableTools.has("memory_get")) {
return [];