mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 01:01:42 +00:00
fix(ai): normalize tool call ids and handoff tests fixes #821
This commit is contained in:
parent
298af5c1c2
commit
2c7c23b865
19 changed files with 570 additions and 1376 deletions
|
|
@ -59,10 +59,10 @@ function resolveThoughtSignature(isSameProviderAndModel: boolean, signature: str
|
|||
}
|
||||
|
||||
/**
|
||||
* Claude models via Google APIs require explicit tool call IDs in function calls/responses.
|
||||
* Models via Google APIs that require explicit tool call IDs in function calls/responses.
|
||||
*/
|
||||
export function requiresToolCallId(modelId: string): boolean {
|
||||
return modelId.startsWith("claude-");
|
||||
return modelId.startsWith("claude-") || modelId.startsWith("gpt-oss-");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +70,12 @@ export function requiresToolCallId(modelId: string): boolean {
|
|||
*/
|
||||
export function convertMessages<T extends GoogleApiType>(model: Model<T>, context: Context): Content[] {
|
||||
const contents: Content[] = [];
|
||||
const transformedMessages = transformMessages(context.messages, model);
|
||||
const normalizeToolCallId = (id: string): string => {
|
||||
if (!requiresToolCallId(model.id)) return id;
|
||||
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
||||
};
|
||||
|
||||
const transformedMessages = transformMessages(context.messages, model, normalizeToolCallId);
|
||||
|
||||
for (const msg of transformedMessages) {
|
||||
if (msg.role === "user") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue