mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-10-19 07:23:51 +00:00
Minify context extras
Serialize protocol and extras context JSON without whitespace to reduce prompt tokens. Cover compact extras rendering in prompt assembly.
This commit is contained in:
parent
eaeec455e2
commit
67b0bc1dea
2 changed files with 2 additions and 1 deletions
2
agent.py
2
agent.py
|
|
@ -613,7 +613,7 @@ class Agent:
|
|||
False,
|
||||
content=self.read_prompt(
|
||||
prompt_file,
|
||||
**{variable_name: dirty_json.stringify(values)},
|
||||
**{variable_name: dirty_json.stringify(values, separators=(",", ":"))},
|
||||
),
|
||||
).output()
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ async def test_prepare_prompt_places_protocol_before_history_and_extras(monkeypa
|
|||
assert isinstance(prompt[3], HumanMessage)
|
||||
assert str(prompt[3].content).startswith("[EXTRAS]")
|
||||
assert "Today." in str(prompt[3].content)
|
||||
assert '{"current_datetime":"Today."' in str(prompt[3].content)
|
||||
|
||||
serialized_history = agent.history.serialize()
|
||||
assert "Project rule." not in serialized_history
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue