Commit 2ae3acf
fix: encode bytes in SessionAgent/Session.to_dict() for JSON serialization
SessionAgent.to_dict() and Session.to_dict() call asdict() directly
without encoding bytes values, while SessionMessage.to_dict() correctly
uses encode_bytes_values(). This inconsistency causes S3SessionManager
and FileSessionManager to crash with:
TypeError: Object of type bytes is not JSON serializable
when agent state contains binary content (e.g., inline PDF bytes from
multimodal prompts passed through LiteLLM proxy).
Fix: Apply encode_bytes_values() in SessionAgent.to_dict() and
Session.to_dict() (matching SessionMessage.to_dict()), and add
decode_bytes_values() in SessionAgent.from_dict() for round-trip
correctness.
Added regression tests for bytes serialization in SessionAgent.
Fixes #1864
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent fca208b commit 2ae3acf
File tree
2 files changed
+43
-3
lines changed- src/strands/types
- tests/strands/types
2 files changed
+43
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
0 commit comments