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

This commit is contained in:
2026-07-30 22:12:49 -04:00
parent a7aec4ee29
commit 52a9e3aaa4
2 changed files with 4 additions and 4 deletions

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--;