Skip to content

Commit f8dea45

Browse files
authored
Merge pull request #9 from tomolom/fix/redacted-thinking-strip
fix: preserve redacted thinking blocks during reasoning cleanup
2 parents 65da91e + 8317ee8 commit f8dea45

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/plugin/src/hooks/magic-context/strip-content.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,26 @@ describe("strip-content", () => {
193193
});
194194
});
195195
});
196+
197+
describe("#given assistant messages with redacted thinking parts", () => {
198+
describe("#when stripping cleared reasoning", () => {
199+
it("#then preserves redacted thinking blocks unchanged", () => {
200+
const redactedPart = {
201+
type: "redacted_thinking",
202+
data: "opaque-provider-payload",
203+
};
204+
const textPart = { type: "text", text: "visible response" };
205+
const msg = message("m-1", "assistant", [redactedPart, textPart]);
206+
207+
const stripped = stripClearedReasoning([msg]);
208+
209+
expect(stripped).toBe(0);
210+
expect(msg.parts).toHaveLength(2);
211+
expect(msg.parts[0]).toBe(redactedPart);
212+
expect(msg.parts[1]).toBe(textPart);
213+
});
214+
});
215+
});
196216
});
197217

198218
describe("stripInlineThinking", () => {

packages/plugin/src/hooks/magic-context/strip-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function findMaxTag(messageTagNumbers: Map<MessageLike, number>): number {
279279
return max;
280280
}
281281

282-
const CLEARED_REASONING_TYPES = new Set(["thinking", "reasoning", "redacted_thinking"]);
282+
const CLEARED_REASONING_TYPES = new Set(["thinking", "reasoning"]);
283283

284284
export function stripClearedReasoning(messages: MessageLike[]): number {
285285
let stripped = 0;

0 commit comments

Comments
 (0)