wenjin272 opened a new pull request, #1314: URL: https://github.com/apache/flink-agents/pull/1314
Linked issue: #1313 ### Purpose of change #### Outcome and intent Reading a missing long-term-memory ID now returns no item; deleting one reports Mem0's not-found error instead of an internal `AttributeError`. Explicit IDs continue to address records directly in the backing collection. The documentation makes callers responsible for using IDs from the intended MemorySet. #### Runtime flow and key decisions The Flink-to-Mem0 vector-store adapter returns `None` for an absent record. Mem0 then returns `None` from `get` or raises its existing `ValueError` from `delete`. The LTM reader skips missing results before item conversion and observation recording. Java delegates to this Python implementation. Mem0 1.0.11's native Chroma `get` indexes an empty result and raises `IndexError`. The reverse Mem0VectorStore adapter uses the same Chroma query and payload parser but checks for an empty result first. Other providers retain their existing path; storage errors are not caught. No scope-validation reads or batch preflight are added to deletion. Both API references and the memory guide distinguish context-scoped operations from explicit-ID operations. ### Behavioral Semantics #### Interaction decisions and contracts | Input | Read | Delete | | --- | --- | --- | | Existing explicit ID, including another job/key/set in the same collection | Return the record | Delete the record | | Missing explicit ID | Skip it; return an empty list when none exist | Raise Mem0's not-found error | | Mixed existing/missing IDs | Return existing records in request order | Process sequentially; stop at the first error without rolling back prior deletions | | No IDs supplied | Existing scoped listing | Existing scoped whole-set deletion | Missing reads produce no GET observation. Existing action-context validation remains in effect even for explicit IDs. #### Failure behavior Missing-ID deletion raises `ValueError` in Python and propagates through the Java bridge. Storage failures propagate; there are no retries or new fallback results. Failed deletes do not become successful operations, and batch deletion is not atomic. Configuration handling is unchanged. ### Tests | Contract | Coverage | | --- | --- | | Missing and deleted IDs are omitted from reads, including mixed and empty ID lists | `test_get_skips_missing_ids` on native Chroma and Mem0-wrapped Chroma | | Missing/repeated deletes report not-found | `test_delete_missing_id_raises_not_found` on both paths | | A failing batch retains earlier deletions and leaves later IDs untouched | `test_delete_batch_stops_at_missing_id_without_rollback` on both paths | | Explicit IDs retain direct addressing across job, key and set boundaries | `test_explicit_ids_address_records_outside_memory_set`, each dimension on both paths | | Missing reads do not emit GET observations | `test_missing_ids_do_not_produce_get_observations` | | Reverse Chroma adapter skips absent IDs and propagates storage errors | Vector-store `test_get_skips_missing_ids`, `test_get_propagates_chroma_read_errors` | | Existing scoped operations remain supported | Existing LTM add/list/search/delete-all tests | 100 Python tests passed against source with real local Chroma storage and mock models; 17 existing Java adapter tests passed on JDK 11 after rebuilding dependency modules. Ruff, Spotless, `git diff --check`, and Hugo 0.110.0 build passed; rendered scope links and behavior text were checked. Not verified: a real Java/Pemja-to-Mem0 execution, a deployed Flink job, other Mem0 storage providers, or the full repository test suite. <details> <summary>Commands and regression evidence</summary> Python dependencies: mem0ai 1.0.11, chromadb 1.0.21. The active Python environment's purelib and this worktree's Python sources were included in PYTHONPATH; no installed Flink Agents wheel was used. ```text python -m pytest python/flink_agents/runtime/memory python/flink_agents/api/tests/test_memory_event.py python/flink_agents/integrations/vector_stores/mem0/tests -q mvn -B --no-transfer-progress -pl runtime -am -Dtest=Mem0LongTermMemoryTest -Dsurefire.failIfNoSpecifiedTests=false test ``` Before the fix, the new missing-ID/observation regressions failed while all six direct-addressing cases passed. The reverse Chroma regressions also exposed the provider's empty-result indexing error. The final selected Python suite passed all 100 tests. </details> ### API No signatures change. Missing-ID reads now omit absent records instead of failing; missing-ID deletes expose the backend not-found error. Existing valid-ID and cross-context ID behavior remains unchanged. Python and Java API documentation describe the same contract. ### Documentation - [ ] `doc-needed` - [ ] `doc-not-needed` - [x] `doc-included` ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes - [ ] No Generated-by: Codex CLI 0.153.4 (GPT-6) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
