mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-02 02:11:20 +00:00
process() wrapped both the memory enrichment and the agent streaming loop in a single try/except whose fallback re-invoked self.agent.process(). The fallback was meant to keep the agent running when memory enrichment failed, but because the agent's own iteration lived inside the same try, an agent error raised mid-stream, after chunks had already been yielded to the caller, re-ran the entire agent from scratch: the caller received a second full response concatenated onto the partial one, plus a duplicate billable LLM call. Scope the guard to the memory-enrichment/injection/storage block only, and run the agent iteration exactly once after it. Enrichment failures are logged and absorbed as before; agent errors now propagate to the caller instead of triggering a duplicate run. Regression tests stream from a fake inner agent that dies mid-stream: each chunk is delivered exactly once, the agent's run counter stays at 1, and the error propagates (both tests fail against the previous implementation with run_count == 2). A third test pins the intended behaviour that enrichment failures still let the agent run once. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_empty_profile.py | ||
| test_single_agent_run.py | ||