fix(openai): add multilingual gpt ack prompts

This commit is contained in:
Peter Steinberger
2026-04-05 12:57:19 +01:00
parent 76da484bed
commit 2635e07bf0
2 changed files with 37 additions and 1 deletions

View File

@@ -109,6 +109,16 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
expect(isLikelyExecutionAckPrompt("Can you do it?")).toBe(false);
});
it("detects short execution approvals across requested locales", () => {
expect(isLikelyExecutionAckPrompt("نفذها")).toBe(true);
expect(isLikelyExecutionAckPrompt("mach es")).toBe(true);
expect(isLikelyExecutionAckPrompt("進めて")).toBe(true);
expect(isLikelyExecutionAckPrompt("fais-le")).toBe(true);
expect(isLikelyExecutionAckPrompt("adelante")).toBe(true);
expect(isLikelyExecutionAckPrompt("vai em frente")).toBe(true);
expect(isLikelyExecutionAckPrompt("진행해")).toBe(true);
});
it("adds an ack-turn fast-path instruction for GPT action turns", () => {
const instruction = resolveAckExecutionFastPathInstruction({
provider: "openai",

View File

@@ -49,6 +49,31 @@ const ACK_EXECUTION_NORMALIZED_SET = new Set([
"make it so",
"yes do it",
"yep do it",
"تمام",
"حسنا",
"حسنًا",
"امض قدما",
"نفذها",
"mach es",
"leg los",
"los geht s",
"weiter",
"やって",
"進めて",
"そのまま進めて",
"allez y",
"vas y",
"fais le",
"continue",
"hazlo",
"adelante",
"sigue",
"faz isso",
"vai em frente",
"pode fazer",
"해줘",
"진행해",
"계속해",
]);
export const PLANNING_ONLY_RETRY_INSTRUCTION =
@@ -113,9 +138,10 @@ function shouldApplyPlanningOnlyRetryGuard(params: {
function normalizeAckPrompt(text: string): string {
return text
.normalize("NFKC")
.trim()
.toLowerCase()
.replace(/[`"'.,!?]+/g, " ")
.replace(/[\p{P}\p{S}]+/gu, " ")
.replace(/\s+/g, " ")
.trim();
}