Compare commits

...

1 Commits

Author SHA1 Message Date
52a9e3aaa4 Fixed history poisoning on empty tool response
All checks were successful
Publish Library / Build NPM Project (push) Successful in 51s
Publish Library / Tag Version (push) Successful in 13s
2026-07-30 22:12:49 -04:00
2 changed files with 4 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/ai-utils",
"version": "1.2.10",
"version": "1.2.11",
"description": "AI Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -29,11 +29,11 @@ export class OpenAi extends LLMProvider {
}));
history.splice(i, 1, ...tools);
i += tools.length - 1;
} else if(h.role === 'tool' && h.content) {
} else if(h.role === 'tool') {
const record = history.find(h2 => h.tool_call_id == h2.id);
if(record) {
if(h.content.includes('"error":')) record.error = h.content;
else record.content = h.content;
if(h.content?.includes('"error":')) record.error = h.content;
else record.content = h.content || '';
}
history.splice(i, 1);
i--;