Commit 27c47f1
authored
fix(agent): Agent.load() raised for every agent on a read-only property (kyegomez#2014)
SafeStateManager.load_state assigns every safe-typed key from the state
file back onto the object:
for key, value in state_dict.items():
if not key.startswith("_") and key not in preserved
and SafeLoaderUtils.is_safe_type(value):
setattr(obj, key, value)
for key, value in preserved.items():
setattr(obj, key, value)
create_state_dict reads instance state, which includes class-level
read-only properties, so the file carries keys that cannot be written
back. Agent has two — `workspace` and `mcp_enabled` — and the first one
reached ends the load:
AttributeError: property 'workspace' of 'Agent' object has no setter
That is not an edge case. Every Agent has both properties, so
Agent.load() could not complete for any agent, from either loop.
is_settable() skips a key whose class attribute is a property with no
setter. Both loops consult it. These are derived values — `workspace`
and `mcp_enabled` are computed from state that *is* restorable — so
skipping them loses nothing, and the test asserts they still hold their
computed value after a load rather than being blanked.
Why this went unnoticed: the repo's only save/load round-trip test,
TestBasicAgent::test_save_and_load, has errored at setup since
2025-10-21 on a fixture deleted out from under it (kyegomez#2010). It looked
like coverage for ten months.
tests/structs/test_safe_loading.py is a new file — nothing under tests/
owned safe_loading.py. Six tests: the crash itself, a real scalar round
trip (max_loops 9 -> 3, agent_name restored), read-only properties
surviving, the premise that Agent still has such properties at all, and
FileNotFoundError still propagating. Against unfixed source: 5 failed,
1 passed. Here: 6 passed.
tests/structs/test_agent.py failure set is unchanged from master (27=27).1 parent bcda9a4 commit 27c47f1
2 files changed
Lines changed: 127 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
42 | 67 | | |
43 | 68 | | |
44 | 69 | | |
| |||
220 | 245 | | |
221 | 246 | | |
222 | 247 | | |
| 248 | + | |
223 | 249 | | |
224 | 250 | | |
225 | 251 | | |
226 | 252 | | |
227 | 253 | | |
228 | | - | |
| 254 | + | |
| 255 | + | |
229 | 256 | | |
230 | 257 | | |
231 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
0 commit comments