Repository navigation
fix(memory): keep embedding bytes out of recall results - #7308
Conversation
Asking about a memory that isn't there could end the turn with only "TypeError: Object of type bytes is not JSON serializable": a recall that returned many rows handed the model each row's stored embedding, and shrinking that large result to fit the context crashed. Recall now returns text only, and a tool result that still carries a value JSON can't hold fails with the tool's name and the field's path instead of a bare TypeError. The hybrid search drops each vector hit's embedding BLOB before it becomes a result, and condense_result checks the whole result before measuring it. Closes #ISSUE
|
Verdict: Request changes The memory fix itself is right and complete: recall no longer returns each row's raw embedding bytes, so a big "what do you remember" answer won't crash the turn. The new safety check that comes with it is the problem. It only runs on results big enough to be shrunk, and it is stricter than the converter the agent already uses on every other result. So a tool that returns a date, a file path or a numpy number now works while its answer is small and ends the turn once the answer gets big. That is the same kind of size-dependent crash this PR fixes.
Real-world evidenceN/A: no evidence bundle was produced for this run. This verdict rests on reading the code alone. I couldn't run the new tests here because the runner has no Python environment with 🔍 Technical details🟡
Now
Two consistent options:
Checked and fine
Strengths
|
The JSON check added with the recall fix ran only on results big enough to condense, and was stricter than the encoder every other result goes through. A tool returning a date, a path or a numpy number worked while its answer was small and ended the turn once it grew. The check is gone; the condenser now measures a result with the same encoder the agent uses at every size, which is what the original crash needed.
|
A large tool result is now handled by the same rule as a small one, so a date, a path or a numpy number in a big answer no longer ends the turn.
Still owed from the test plan: the run on a rebuilt app with 300+ memories that asks for everything it remembers. |
Every unit test indexes three files and stores five memories, and rc18 fell over at 300 of each: a folder index reloaded the embedder once per file, so 300 small files took 15 minutes, and a memory search over a few hundred rows ended the turn on a JSON error. This adds a scale run that does both at a real user's size on every release tag, with no model: the installer journeys' fake model server answers, and the test asserts counts of what GAIA asked it for. What it asserts: | At scale | Assertion | Today | |---|---|---| | large folder index | every file indexed, exactly one library row each | ✅ | | large folder index | the embedder is loaded at most twice, within a time budget | ✅ (fixed by amd#7310 while this was in review; it caught amd#7288, a reload per file, before that) | | search over 500 memories | the result can be sent as JSON | ✅ (fixed by amd#7308 while this was in review; the test caught it before that) | | 500 memories | the memory API reaches every one, page by page | ✅ | **Size:** 300 files, the size rc18 failed at. With amd#7310 in, they index in about 25 s against the fake server, well inside the 240 s budget; before it, 300 ran past 45 minutes on a hosted runner (that slowness was the bug). **Not built here, and why:** the 60-turn chat with the context meter compared to what the model is sent (F59) needs a real flagship turn loop behind the relay, and the memory page showing only 200 of 500 (F63) and duplicate rows from a re-add during indexing (F65) are a frontend bug and a race. Each has its own focused test in its fix PR (amd#7309, amd#7312, amd#7311); a scale version belongs with the Electron journey proposed in amd#7343. Stacked on amd#7331 (it uses that PR's `tests/fixtures/fake_lemonade.py`); the commits before "test: run GAIA at a real user's size ..." are that PR. ## Test plan - [ ] The new **Scale Run** workflow on this PR passes (4 passed) - [ ] Locally: `GAIA_SCALE_FILES=8 python -m pytest tests/integration/test_scale_run.py -q` passes - [ ] Runs on every `v*` tag (each RC and final) and on PRs that touch the test, its fixture or the workflow <details> <summary>🔍 Technical details</summary> - The folder is indexed once per run through `POST /api/documents/index-folder` with the real RAG code; the embedder's load and unload requests are read from the fake server's log. - The time budget (240 s) sits in the same expected-failure test as the load count, since the reloads are what make it slow. </details> --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
Asking about a memory that isn't there could end the turn with only
"TypeError: Object of type bytes is not JSON serializable": a recall that
returned many rows handed the model each row's stored embedding, and
shrinking that large result to fit the context crashed. Recall now returns
text only, and a large tool result is measured with the same encoder as a
small one, so a date, path, numpy number or bytes value in a big answer no
longer ends the turn.
The hybrid search drops each vector hit's embedding BLOB before it becomes
a result, and the condenser measures a result with the agent's own encoder
instead of a bare JSON encode.
Closes #7283
Test plan
python -m pytest tests/unit/test_recall_result_is_json.py tests/unit/agents/test_chunk_index.py tests/unit/agents/test_large_tool_result_truncation.py(185 pass; the new cases fail on main)