wenjin272 opened a new pull request, #1123:
URL: https://github.com/apache/flink-agents/pull/1123

   Linked issue: N/A (hotfix)
   
   ### Purpose of change
   
   Prevent the Mem0 cross-language E2E agent from mutating the Event payload 
received by an Action. The previous in-place writes changed Event.hashCode 
while the corresponding ActionTask was being used as a HashMap key, causing 
context cleanup to fail with No contexts to remove for action task.
   
   #### Runtime flow
   
   Mem0LongTermMemoryAgent.retrieveItems converts the value payload into a 
detached Map, adds the second-action timestamp and retrieved items to that 
copy, and emits the copy as the OutputEvent. The triggering Event remains 
unchanged.
   
   #### Key decisions
   
   The change is scoped to the Mem0 test agent. It uses a deep conversion 
rather than a shallow Map copy so nested maps and lists are detached as well. 
Runtime ActionTask identity semantics are intentionally unchanged.
   
   ### Behavioral Semantics
   
   Interaction decisions: not applicable; this test fixture has one 
JSON-compatible record path.
   
   Behavioral contracts:
   
   - Enriching the Mem0 output record does not mutate the triggering Event 
payload or change its hash code.
   - The emitted record retains the same fields and values as before, plus the 
existing enrichment fields.
   
   Failure behavior: payload conversion errors propagate and fail the test job, 
consistent with the fixture existing type and shape assumptions.
   
   ### Tests
   
   | Contract | Test |
   | --- | --- |
   | Top-level enrichment does not mutate the Event payload or hash code | 
Mem0LongTermMemoryAgentTest.deepCopyRecordDoesNotMutateEventPayload |
   | Nested maps and lists are detached | 
Mem0LongTermMemoryAgentTest.deepCopyRecordDoesNotMutateEventPayload |
   
   Verified with Java 11:
   
   mvn --batch-mode --no-transfer-progress -pl 
e2e-test/flink-agents-end-to-end-tests-resource-cross-language -am 
-Dtest=Mem0LongTermMemoryAgentTest -Dsurefire.failIfNoSpecifiedTests=false test
   
   Apache RAT license checks also pass.
   
   Not verified locally: the full Mem0 Elasticsearch and Milvus E2E paths 
require Ollama, ACTION_API_KEY, and external vector stores; the cross-language 
CI job exercises those paths.
   
   <details>
   <summary>Implementation invariants and evidence</summary>
   
   The copy is materialized through Jackson with a Map String Object 
TypeReference. The focused test mutates both the copied top-level map and a 
nested list, then verifies the source payload and original Event hash code are 
unchanged.
   
   </details>
   
   ### API
   
   No public API changes. This only changes a Java E2E test fixture.
   
   ### Documentation
   
   - [x] doc-not-needed
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Codex (GPT-5)


-- 
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]

Reply via email to