Merge 4c6b5b7f1e into da71eaebd2
This commit is contained in:
commit
a4f5b5f7d1
@ -44,10 +44,9 @@ export async function sanitizeSessionMessagesImages(
|
|||||||
const allowNonImageSanitization = sanitizeMode === "full";
|
const allowNonImageSanitization = sanitizeMode === "full";
|
||||||
// We sanitize historical session messages because Anthropic can reject a request
|
// We sanitize historical session messages because Anthropic can reject a request
|
||||||
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
||||||
const sanitizedIds =
|
const sanitizedIds = options?.sanitizeToolCallIds
|
||||||
allowNonImageSanitization && options?.sanitizeToolCallIds
|
? sanitizeToolCallIdsForCloudCodeAssist(messages, options.toolCallIdMode)
|
||||||
? sanitizeToolCallIdsForCloudCodeAssist(messages, options.toolCallIdMode)
|
: messages;
|
||||||
: messages;
|
|
||||||
const out: AgentMessage[] = [];
|
const out: AgentMessage[] = [];
|
||||||
for (const msg of sanitizedIds) {
|
for (const msg of sanitizedIds) {
|
||||||
if (!msg || typeof msg !== "object") {
|
if (!msg || typeof msg !== "object") {
|
||||||
|
|||||||
@ -94,7 +94,7 @@ describe("sanitizeSessionHistory", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not sanitize tool call ids for openai-responses", async () => {
|
it("sanitizes tool call ids for openai-responses", async () => {
|
||||||
vi.mocked(helpers.isGoogleModelApi).mockReturnValue(false);
|
vi.mocked(helpers.isGoogleModelApi).mockReturnValue(false);
|
||||||
|
|
||||||
await sanitizeSessionHistory({
|
await sanitizeSessionHistory({
|
||||||
@ -108,7 +108,7 @@ describe("sanitizeSessionHistory", () => {
|
|||||||
expect(helpers.sanitizeSessionMessagesImages).toHaveBeenCalledWith(
|
expect(helpers.sanitizeSessionMessagesImages).toHaveBeenCalledWith(
|
||||||
mockMessages,
|
mockMessages,
|
||||||
"session:history",
|
"session:history",
|
||||||
expect.objectContaining({ sanitizeMode: "images-only", sanitizeToolCallIds: false }),
|
expect.objectContaining({ sanitizeMode: "images-only", sanitizeToolCallIds: true }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,7 @@ export function resolveTranscriptPolicy(params: {
|
|||||||
|
|
||||||
const needsNonImageSanitize = isGoogle || isAnthropic || isMistral || isOpenRouterGemini;
|
const needsNonImageSanitize = isGoogle || isAnthropic || isMistral || isOpenRouterGemini;
|
||||||
|
|
||||||
const sanitizeToolCallIds = isGoogle || isMistral;
|
const sanitizeToolCallIds = isGoogle || isMistral || isOpenAi;
|
||||||
const toolCallIdMode: ToolCallIdMode | undefined = isMistral
|
const toolCallIdMode: ToolCallIdMode | undefined = isMistral
|
||||||
? "strict9"
|
? "strict9"
|
||||||
: sanitizeToolCallIds
|
: sanitizeToolCallIds
|
||||||
@ -99,7 +99,7 @@ export function resolveTranscriptPolicy(params: {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
sanitizeMode: isOpenAi ? "images-only" : needsNonImageSanitize ? "full" : "images-only",
|
||||||
sanitizeToolCallIds: !isOpenAi && sanitizeToolCallIds,
|
sanitizeToolCallIds,
|
||||||
toolCallIdMode,
|
toolCallIdMode,
|
||||||
repairToolUseResultPairing: !isOpenAi && repairToolUseResultPairing,
|
repairToolUseResultPairing: !isOpenAi && repairToolUseResultPairing,
|
||||||
preserveSignatures: isAntigravityClaudeModel,
|
preserveSignatures: isAntigravityClaudeModel,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user