Skip to content

Commit 793b39c

Browse files
committed
Add null guard
1 parent f684ff0 commit 793b39c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/agents.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,15 @@ function extractTextFromValue(value: unknown, depth: number, filterByType: boole
286286
const isRecognizedTextType = typeValue ? TEXTUAL_CONTENT_TYPES.has(typeValue) : false;
287287

288288
if (typeof record.text === 'string') {
289-
if (!filterByType || isRecognizedTextType) {
289+
if (!filterByType || isRecognizedTextType || typeValue === null) {
290290
return record.text.trim();
291291
}
292292
}
293293

294-
if (record.content !== undefined) {
295-
const nested = extractTextFromValue(record.content, depth + 1, filterByType);
294+
const contentValue = record.content;
295+
// If a direct text field was skipped due to type filtering, fall back to nested content.
296+
if (contentValue != null) {
297+
const nested = extractTextFromValue(contentValue, depth + 1, filterByType);
296298
if (nested) {
297299
return nested;
298300
}

0 commit comments

Comments
 (0)