fix(coding-agent): serialize split-turn compaction summaries
Some checks are pending
CI / build-check-test (push) Waiting to run

closes #5536
This commit is contained in:
Vegard Stikbakke 2026-07-01 15:37:00 +02:00
parent e2ccdc8509
commit f58c115626
4 changed files with 31 additions and 22 deletions

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed harness split-turn compaction to serialize summary requests so single-concurrency providers are not asked to run overlapping generations ([#5536](https://github.com/earendil-works/pi/issues/5536)).
## [0.80.3] - 2026-06-30
### Added

View file

@ -653,9 +653,9 @@ export async function compact(
let summary: string;
if (isSplitTurn && turnPrefixMessages.length > 0) {
const [historyResult, turnPrefixResult] = await Promise.all([
const historyResult =
messagesToSummarize.length > 0
? generateSummary(
? await generateSummary(
messagesToSummarize,
models,
model,
@ -665,10 +665,16 @@ export async function compact(
previousSummary,
thinkingLevel,
)
: Promise.resolve(ok<string, CompactionError>("No prior history.")),
generateTurnPrefixSummary(turnPrefixMessages, models, model, settings.reserveTokens, signal, thinkingLevel),
]);
: ok<string, CompactionError>("No prior history.");
if (!historyResult.ok) return err(historyResult.error);
const turnPrefixResult = await generateTurnPrefixSummary(
turnPrefixMessages,
models,
model,
settings.reserveTokens,
signal,
thinkingLevel,
);
if (!turnPrefixResult.ok) return err(turnPrefixResult.error);
summary = `${historyResult.value}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult.value}`;
} else {

View file

@ -9,6 +9,7 @@
### Fixed
- Fixed split-turn compaction to serialize summary requests so single-concurrency local providers do not fail with 429 errors ([#5536](https://github.com/earendil-works/pi/issues/5536)).
- Fixed custom session entries appended during assistant streaming to render before the live assistant message, matching persisted session order.
- Fixed oversized bash tool timeouts to fail with a clear validation error instead of being clamped to an immediate timeout ([#6181](https://github.com/earendil-works/pi/issues/6181)).

View file

@ -778,14 +778,13 @@ export async function compact(
settings,
} = preparation;
// Generate summaries (can be parallel if both needed) and merge into one
// Generate summaries and merge into one
let summary: string;
if (isSplitTurn && turnPrefixMessages.length > 0) {
// Generate both summaries in parallel
const [historyResult, turnPrefixResult] = await Promise.all([
const historyResult =
messagesToSummarize.length > 0
? generateSummary(
? await generateSummary(
messagesToSummarize,
model,
settings.reserveTokens,
@ -798,19 +797,18 @@ export async function compact(
streamFn,
env,
)
: Promise.resolve("No prior history."),
generateTurnPrefixSummary(
turnPrefixMessages,
model,
settings.reserveTokens,
apiKey,
headers,
env,
signal,
thinkingLevel,
streamFn,
),
]);
: "No prior history.";
const turnPrefixResult = await generateTurnPrefixSummary(
turnPrefixMessages,
model,
settings.reserveTokens,
apiKey,
headers,
env,
signal,
thinkingLevel,
streamFn,
);
// Merge into single summary
summary = `${historyResult}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult}`;
} else {