Skip to content

Commit 3023742

Browse files
committed
fix: filter non-string handoff image_urls entries
1 parent 8c02f85 commit 3023742

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

astrbot/core/astr_agent_tool_exec.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,25 @@ async def _collect_handoff_image_urls(
7373
run_context: ContextWrapper[AstrAgentContext],
7474
image_urls_raw: T.Any,
7575
) -> list[str]:
76-
candidates: list[T.Any] = []
76+
candidates: list[str] = []
7777
if image_urls_raw is None:
7878
pass
7979
elif isinstance(image_urls_raw, str):
8080
candidates.append(image_urls_raw)
8181
elif isinstance(image_urls_raw, (Sequence, AbstractSet)) and not isinstance(
8282
image_urls_raw, (str, bytes, bytearray)
8383
):
84-
candidates.extend(image_urls_raw)
84+
non_string_count = 0
85+
for item in image_urls_raw:
86+
if isinstance(item, str):
87+
candidates.append(item)
88+
else:
89+
non_string_count += 1
90+
if non_string_count > 0:
91+
logger.warning(
92+
"Dropped %d non-string image_urls entries in handoff tool args.",
93+
non_string_count,
94+
)
8595
else:
8696
logger.warning(
8797
"Unsupported image_urls type in handoff tool args: %s",

0 commit comments

Comments
 (0)