Skip to content

The agent that grows with you

docs(state): note that load_result decodes the parsed row in place

unsupportedpastels21c34f5298d0
diff --git a/hermes_state_terminal.py b/hermes_state_terminal.py
index af444a2c9c8..f9c94764b57 100644
--- a/hermes_state_terminal.py
+++ b/hermes_state_terminal.py
@@ -81,6 +81,8 @@ def load_result(text):
"""Decode a stored result row. Only a row carrying ``encode_result``'s exact envelope is
decoded (to the dict it encoded, key order included); every other row, including all rows
written before it, is returned as stored."""
+ # Decodes in place: safe only because each call parses its own copy. A cache in front of this
+ # must hand out copies, never the decoded dict itself.
result = json.loads(text)
if not isinstance(result, dict) or not isinstance(envelope := result.get(_STORED), dict):
return result