chore: format and sync protocol outputs
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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.");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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 [];
|
||||
|
||||
Reference in New Issue
Block a user