Skip to content

Commit 1d935cc

Browse files
committed
fix(agents): suppress mid-turn continuation prompts
1 parent 5a6cedc commit 1d935cc

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Docs: https://docs.openclaw.ai
5050

5151
### Fixes
5252

53+
- Agents/Pi: suppress persistence for synthetic mid-turn overflow continuation prompts, so transcript-retry recovery does not write the "continue from transcript" prompt as a new user turn. Thanks @vincentkoc.
5354
- Exec approvals: detect `env -S` split-string command-carrier risks when `-S`/`-s` is combined with other env short options, so approval explanations do not miss split payloads hidden behind `env -iS...`. Thanks @vincentkoc.
5455
- Voice Call: mark realtime calls completed when the realtime provider closes normally, so Twilio/OpenAI/Google realtime stop events do not leave active call records behind. Thanks @vincentkoc.
5556
- Exec approvals: treat POSIX `exec` as a command carrier for inline eval, shell-wrapper, and eval/source detection, so approval explanations and command-risk checks do not miss payloads hidden behind `exec`. Thanks @vincentkoc.

src/agents/pi-embedded-runner/run.overflow-compaction.loop.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ describe("overflow compaction in run loop", () => {
359359
2,
360360
expect.objectContaining({
361361
prompt: expect.stringContaining("Continue from the current transcript"),
362+
suppressNextUserMessagePersistence: true,
362363
}),
363364
);
364365
expect(mockedRunEmbeddedAttempt).not.toHaveBeenNthCalledWith(
@@ -433,6 +434,7 @@ describe("overflow compaction in run loop", () => {
433434
2,
434435
expect.objectContaining({
435436
prompt: expect.stringContaining("Continue from the current transcript"),
437+
suppressNextUserMessagePersistence: true,
436438
}),
437439
);
438440
expect(mockedRunEmbeddedAttempt).not.toHaveBeenNthCalledWith(

src/agents/pi-embedded-runner/run.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,10 @@ export async function runEmbeddedPiAgent(
817817
}
818818
params.onUserMessagePersisted?.(message);
819819
};
820+
const continueFromCurrentTranscript = () => {
821+
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
822+
suppressNextUserMessagePersistence = true;
823+
};
820824
const maybeEscalateRateLimitProfileFallback = (params: {
821825
failoverProvider: string;
822826
failoverModel: string;
@@ -1327,7 +1331,7 @@ export async function runEmbeddedPiAgent(
13271331
(retryingFromTranscript ? "retrying from current transcript" : "retrying prompt"),
13281332
);
13291333
if (retryingFromTranscript) {
1330-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
1334+
continueFromCurrentTranscript();
13311335
}
13321336
continue;
13331337
}
@@ -1512,7 +1516,7 @@ export async function runEmbeddedPiAgent(
15121516
`context overflow persisted after in-attempt compaction (attempt ${overflowCompactionAttempts}/${MAX_OVERFLOW_COMPACTION_ATTEMPTS}); retrying prompt without additional compaction for ${provider}/${modelId}`,
15131517
);
15141518
if (preflightRecovery?.source === "mid-turn") {
1515-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
1519+
continueFromCurrentTranscript();
15161520
}
15171521
continue;
15181522
}
@@ -1645,7 +1649,7 @@ export async function runEmbeddedPiAgent(
16451649
autoCompactionCount += 1;
16461650
log.info(`auto-compaction succeeded for ${provider}/${modelId}; retrying prompt`);
16471651
if (preflightRecovery?.source === "mid-turn") {
1648-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
1652+
continueFromCurrentTranscript();
16491653
} else if (
16501654
params.currentMessageId !== undefined &&
16511655
params.currentMessageId === lastPersistedCurrentMessageId
@@ -1696,7 +1700,7 @@ export async function runEmbeddedPiAgent(
16961700
`[context-overflow-recovery] Truncated ${truncResult.truncatedCount} tool result(s); retrying prompt`,
16971701
);
16981702
if (preflightRecovery?.source === "mid-turn") {
1699-
nextAttemptPromptOverride = MID_TURN_PRECHECK_CONTINUATION_PROMPT;
1703+
continueFromCurrentTranscript();
17001704
}
17011705
continue;
17021706
}

0 commit comments

Comments
 (0)