From 52a9e3aaa48fde961c6014d9ddef073840c897cd Mon Sep 17 00:00:00 2001 From: ztimson Date: Thu, 30 Jul 2026 22:12:49 -0400 Subject: [PATCH] Fixed history poisoning on empty tool response --- package.json | 2 +- src/open-ai.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 92894ae..775628c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/open-ai.ts b/src/open-ai.ts index e4195bb..8110196 100644 --- a/src/open-ai.ts +++ b/src/open-ai.ts @@ -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--;