Skip to content

Commit 0f315c3

Browse files
committed
chore(agent-context): drop the dead single_agent memory-file prefix
1 parent e5a86e5 commit 0f315c3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

sources/utils/agent_context.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import json
1010
from pathlib import Path
1111

12-
_AGENT_FILE_PREFIXES = ("task_", "single_agent")
12+
# Both factories save agent memory as ``task_{agent_name}.json``; the
13+
# single-agent run saves itself as ``task_single_agent.json``.
14+
_AGENT_FILE_PREFIX = "task_"
1315

1416

1517
def _final_input_tokens(steps: list) -> int:
@@ -54,7 +56,7 @@ def read_agent_context_lengths(memory_dir: str, workflow_uuid: str) -> list[int]
5456

5557
lengths = []
5658
for path in sorted(run_memory.glob("*.json")):
57-
if not path.name.startswith(_AGENT_FILE_PREFIXES):
59+
if not path.name.startswith(_AGENT_FILE_PREFIX):
5860
continue
5961
try:
6062
steps = json.loads(path.read_text())

tests/context_dispersity_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ def test_reader_skips_unreadable_and_untokened_agents():
203203
assert read_agent_context_lengths(root, "uuid-1") == [10]
204204

205205

206+
def test_reader_includes_the_single_agent_memory_file():
207+
"""A single-agent run saves its memory as task_single_agent.json."""
208+
with tempfile.TemporaryDirectory() as root:
209+
uuid = "single_agent_20260101_abc123"
210+
run = Path(root) / uuid
211+
run.mkdir()
212+
_write_agent(run, "task_single_agent.json", [{"token_usage": {"input_tokens": 77}}])
213+
214+
assert read_agent_context_lengths(root, uuid) == [77]
215+
216+
206217
def test_reader_returns_empty_for_missing_run():
207218
with tempfile.TemporaryDirectory() as root:
208219
assert read_agent_context_lengths(root, "absent") == []

0 commit comments

Comments
 (0)