Skip to content

Commit 6ea8038

Browse files
committed
fix: validate json.loads result is a list before assigning to pending_thinking_blocks
1 parent 4e46151 commit 6ea8038

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/agents/models/chatcmpl_converter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,11 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
786786
# "\n"-joined signatures format so existing in-flight sessions
787787
# with the old encoding are not broken.
788788
try:
789-
pending_thinking_blocks = json.loads(encrypted_content)
790-
except (json.JSONDecodeError, TypeError):
789+
decoded = json.loads(encrypted_content)
790+
if not isinstance(decoded, list):
791+
raise ValueError("expected a list of block dicts")
792+
pending_thinking_blocks = decoded
793+
except (json.JSONDecodeError, TypeError, ValueError):
791794
signatures = encrypted_content.split("\n")
792795

793796
reconstructed_thinking_blocks = []

0 commit comments

Comments
 (0)