Skip to content

Commit 7c6eb65

Browse files
committed
fix(api): shim terminal joins the transcript; sessions tolerate delta-less results
The prompt-shim terminal returned without pushing its final assistant text onto the conversation array, so shim-path transcript deltas ended on a tool result. Sessions now fall back to the minimal user/assistant pair when a result carries no transcriptDelta, keeping the pre-0.10 history shape for legacy generateText wrappers and test doubles.
1 parent 6de2642 commit 7c6eb65

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/api/agent.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,15 @@ export function agent(opts: AgentOptions): Agent {
10011001
}
10021002
}
10031003

1004-
if (historyBuffer && result.transcriptDelta) {
1004+
if (historyBuffer) {
1005+
// Lossless delta when the call carried one; minimal user/assistant
1006+
// pair otherwise (legacy generateText wrappers and test doubles
1007+
// predating transcriptDelta keep the pre-0.10 history shape).
10051008
historyBuffer.appendSendDelta(
1006-
result.transcriptDelta,
1009+
result.transcriptDelta ?? [
1010+
userMessage as unknown as SessionTranscriptMessage,
1011+
{ role: 'assistant', content: result.text },
1012+
],
10071013
sendOpts?.blockLabel,
10081014
epochAtStart,
10091015
);

src/api/generateText.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,9 @@ export async function generateText(opts: GenerateTextOptions): Promise<GenerateT
17001700
surface: 'generateText',
17011701
durationMs: Date.now() - rootStartedAt,
17021702
});
1703+
// The shim's final assistant text lives in loopResult, never on the
1704+
// messages array — push it so the transcript delta ends on the reply.
1705+
messages.push({ role: 'assistant', content: loopResult.text });
17031706
return {
17041707
transcriptDelta: messages.slice(transcriptDeltaStart) as unknown as SessionTranscriptMessage[],
17051708
provider: resolved.providerId,

0 commit comments

Comments
 (0)