Skip to content

Commit 6ce71ba

Browse files
Aayush KatariaAayush Kataria
authored andcommitted
Fixing builds
1 parent fb2b030 commit 6ce71ba

7 files changed

Lines changed: 28 additions & 51 deletions

File tree

agent_memory_toolkit/_counters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ def crosses_threshold(old_count: int, new_count: int, n: int) -> bool:
7373
return old_count // n != new_count // n
7474

7575

76-
def _maybe_warn_owner_mismatch(
77-
counter_id: str, existing_owner: Optional[str], observer_owner: Optional[str]
78-
) -> None:
76+
def _maybe_warn_owner_mismatch(counter_id: str, existing_owner: Optional[str], observer_owner: Optional[str]) -> None:
7977
"""One-shot WARN when the previous writer disagrees with the current one.
8078
8179
Operators run with either ``MEMORY_PROCESSOR_OWNER=inprocess`` or

agent_memory_toolkit/aio/cosmos_memory_client.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ async def push_to_cosmos(self, batch_size: int = 25) -> None:
696696
except RuntimeError: # pragma: no cover - no running loop
697697
logger.warning("No running event loop for auto-trigger; skipping")
698698

699-
700699
async def get_memories(
701700
self,
702701
memory_id: Optional[str] = None,
@@ -1272,9 +1271,7 @@ def _get_counter_container(self) -> Any:
12721271
return None
12731272
try:
12741273
db = self._cosmos_client.get_database_client(self._cosmos_database)
1275-
self._counter_container_client = db.get_container_client(
1276-
self._cosmos_counter_container
1277-
)
1274+
self._counter_container_client = db.get_container_client(self._cosmos_counter_container)
12781275
return self._counter_container_client
12791276
except Exception as exc: # pragma: no cover - defensive
12801277
logger.warning(
@@ -1285,9 +1282,7 @@ def _get_counter_container(self) -> Any:
12851282
)
12861283
return None
12871284

1288-
async def _maybe_auto_trigger(
1289-
self, turn_counts: dict[tuple[str, str], int]
1290-
) -> None:
1285+
async def _maybe_auto_trigger(self, turn_counts: dict[tuple[str, str], int]) -> None:
12911286
"""Async mirror of ``CosmosMemoryClient._maybe_auto_trigger``.
12921287
12931288
Scheduled by ``push_to_cosmos`` as a background ``asyncio.Task``
@@ -1329,9 +1324,7 @@ async def _maybe_auto_trigger(
13291324
"Further skips will be logged at DEBUG level."
13301325
)
13311326
else:
1332-
logger.debug(
1333-
"Skipping SDK auto-trigger: MEMORY_PROCESSOR_OWNER=durable"
1334-
)
1327+
logger.debug("Skipping SDK auto-trigger: MEMORY_PROCESSOR_OWNER=durable")
13351328
return
13361329

13371330
n_facts = get_fact_extraction_every_n()
@@ -1471,7 +1464,6 @@ async def _run_auto_trigger_steps(
14711464
f"process_user_summary: {exc!r}",
14721465
)
14731466

1474-
14751467
async def extract_memories(
14761468
self,
14771469
user_id: str,

agent_memory_toolkit/cosmos_memory_client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,7 @@ def _maybe_auto_trigger(self, turn_counts: dict[tuple[str, str], int]) -> None:
653653
"Further skips will be logged at DEBUG level."
654654
)
655655
else:
656-
logger.debug(
657-
"Skipping SDK auto-trigger: MEMORY_PROCESSOR_OWNER=durable"
658-
)
656+
logger.debug("Skipping SDK auto-trigger: MEMORY_PROCESSOR_OWNER=durable")
659657
return
660658
# When unset (None) or PROCESSOR_OWNER_INPROCESS, proceed.
661659

agent_memory_toolkit/pipeline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,7 @@ def deduplicate_facts(
10121012
)
10131013

10141014
source_confidences = [
1015-
c for f in cluster_facts
1016-
if f["id"] in source_ids
1017-
and (c := f.get("confidence")) is not None
1015+
c for f in cluster_facts if f["id"] in source_ids and (c := f.get("confidence")) is not None
10181016
]
10191017
merged_confidence = max(source_confidences) if source_confidences else None
10201018

tests/unit/aio/test_auto_trigger.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ async def fake_upsert(body):
5454
elapsed = loop.time() - t0
5555

5656
# If push had awaited the slow trigger we'd see >= 0.5s here.
57-
assert elapsed < 0.4, (
58-
f"push_to_cosmos awaited trigger inline (elapsed={elapsed:.3f}s)"
59-
)
57+
assert elapsed < 0.4, f"push_to_cosmos awaited trigger inline (elapsed={elapsed:.3f}s)"
6058

6159
# Drain the background task so pytest doesn't warn about a
6260
# destroyed-but-pending task at teardown.

tests/unit/function_app/test_change_feed.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,7 @@ def test_runs_normally_when_owner_durable():
456456
# Counter was written.
457457
assert container._state["thread:u1:t1"]["count"] == 2
458458
# Threshold (2) crossed — orchestrator started.
459-
summary_starts = [
460-
c for c in starter.start_new.await_args_list
461-
if c.args[0] == "ThreadSummaryOrchestrator"
462-
]
459+
summary_starts = [c for c in starter.start_new.await_args_list if c.args[0] == "ThreadSummaryOrchestrator"]
463460
assert len(summary_starts) == 1
464461

465462

@@ -483,8 +480,5 @@ def test_runs_normally_when_owner_unset(monkeypatch):
483480
asyncio.run(process_changefeed_batch(docs, starter, counter_container=container))
484481

485482
assert container._state["thread:u1:t1"]["count"] == 2
486-
summary_starts = [
487-
c for c in starter.start_new.await_args_list
488-
if c.args[0] == "ThreadSummaryOrchestrator"
489-
]
483+
summary_starts = [c for c in starter.start_new.await_args_list if c.args[0] == "ThreadSummaryOrchestrator"]
490484
assert len(summary_starts) == 1

tests/unit/test_pipeline_confidence.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ def test_merge_carries_max_confidence_and_count(self):
208208
]
209209
pipeline._container.query_items.return_value = iter(facts)
210210

211-
with patch.object(
212-
pipeline, "_cluster_by_similarity", return_value=[[0, 1]]
213-
), patch.object(
214-
pipeline,
215-
"_run_prompty",
216-
return_value=(
217-
'{"actions":[{"action":"MERGE","source_ids":["f1","f2"],'
218-
'"merged_text":"User likes coffee in the morning.","salience":0.7}]}'
211+
with (
212+
patch.object(pipeline, "_cluster_by_similarity", return_value=[[0, 1]]),
213+
patch.object(
214+
pipeline,
215+
"_run_prompty",
216+
return_value=(
217+
'{"actions":[{"action":"MERGE","source_ids":["f1","f2"],'
218+
'"merged_text":"User likes coffee in the morning.","salience":0.7}]}'
219+
),
219220
),
220-
), patch.object(
221-
pipeline, "_parse_llm_json", side_effect=lambda s: json.loads(s)
221+
patch.object(pipeline, "_parse_llm_json", side_effect=lambda s: json.loads(s)),
222222
):
223223
pipeline.deduplicate_facts(user_id="u1")
224224

@@ -237,17 +237,16 @@ def test_merge_omits_confidence_when_no_sources_have_it(self):
237237
]
238238
pipeline._container.query_items.return_value = iter(facts)
239239

240-
with patch.object(
241-
pipeline, "_cluster_by_similarity", return_value=[[0, 1]]
242-
), patch.object(
243-
pipeline,
244-
"_run_prompty",
245-
return_value=(
246-
'{"actions":[{"action":"MERGE","source_ids":["f1","f2"],'
247-
'"merged_text":"merged","salience":0.5}]}'
240+
with (
241+
patch.object(pipeline, "_cluster_by_similarity", return_value=[[0, 1]]),
242+
patch.object(
243+
pipeline,
244+
"_run_prompty",
245+
return_value=(
246+
'{"actions":[{"action":"MERGE","source_ids":["f1","f2"],"merged_text":"merged","salience":0.5}]}'
247+
),
248248
),
249-
), patch.object(
250-
pipeline, "_parse_llm_json", side_effect=lambda s: json.loads(s)
249+
patch.object(pipeline, "_parse_llm_json", side_effect=lambda s: json.loads(s)),
251250
):
252251
pipeline.deduplicate_facts(user_id="u1")
253252

0 commit comments

Comments
 (0)