Agent Zero AI framework

Minify context extras

Serialize protocol and extras context JSON without whitespace to reduce prompt tokens. Cover compact extras rendering in prompt assembly.

linkliti committed Aug 24, 2026 at 20:39 UTC 67b0bc1deabaddccf4248e894980bf8da6da4ec1
2 files changed +2 -1
agent.py
+1 -1
@@ -613,7 +613,7 @@ class Agent:
613 False,
614 content=self.read_prompt(
615 prompt_file,
616 - **{variable_name: dirty_json.stringify(values)},
616 + **{variable_name: dirty_json.stringify(values, separators=(",", ":"))},
617 ),
618 ).output()
619
tests/test_prompt_protocol.py
+1
@@ -62,6 +62,7 @@ async def test_prepare_prompt_places_protocol_before_history_and_extras(monkeypa
62 assert isinstance(prompt[3], HumanMessage)
63 assert str(prompt[3].content).startswith("[EXTRAS]")
64 assert "Today." in str(prompt[3].content)
65 + assert '{"current_datetime":"Today."' in str(prompt[3].content)
66
67 serialized_history = agent.history.serialize()
68 assert "Project rule." not in serialized_history