fix(artifacts): guard malformed tool_calls entries in collectSessionArtifacts (#3329)

Codex regression-gate finding: the OpenAI tool_calls loop dereferenced
tc.function with no null/type guard, so a persisted message.tool_calls
array containing a null or non-object entry would throw and abort artifact
collection. Mirror the existing tool_use-block guard. Adds a node-driven
regression test.

Co-authored-by: mysoul12138 <mysoul12138@users.noreply.github.com>
This commit is contained in:
nesquena-hermesandmysoul12138 committed 2026-06-01 17:27:02 +00:00
1 parent 89a72c2e3b
commit 1c4365ce2a
2 files changed
+103 -1

No files matched your search

+2 -1
View File
@@ -285,7 +285,8 @@ function collectSessionArtifacts(){
// Structured tool_calls array (OpenAI format: {function:{name,arguments}}).
if(Array.isArray(msg.tool_calls)){
for(const tc of msg.tool_calls){
const fn = tc.function || tc;
if(!tc || typeof tc !== 'object') continue;
const fn = (tc.function && typeof tc.function === 'object') ? tc.function : tc;
const name = fn.name || tc.name || '';
let args = fn.arguments || tc.arguments || tc.args || tc.input || {};
if(typeof args === 'string'){ try{ args = JSON.parse(args); }catch(_){} }