diff --git a/apps/memos-local-plugin/adapters/hermes/memos_provider/__init__.py b/apps/memos-local-plugin/adapters/hermes/memos_provider/__init__.py index 25546dfff..7228c4aa2 100644 --- a/apps/memos-local-plugin/adapters/hermes/memos_provider/__init__.py +++ b/apps/memos-local-plugin/adapters/hermes/memos_provider/__init__.py @@ -2111,11 +2111,15 @@ def _turn_end( if agent_thinking: payload["agentThinking"] = agent_thinking result = self._bridge.request("turn.end", payload, timeout=_LONG_RPC_TIMEOUT) - # Capture the trace ID for feedback submission + # Capture the trace ID for feedback submission. The core contract + # (memory-core.ts onTurnEnd) returns a singular `traceId`; accept + # the plural form too for forward compatibility. if result and isinstance(result, dict): - trace_ids = result.get("traceIds", []) - if trace_ids and len(trace_ids) > 0: - trace_id = trace_ids[-1] # Last trace is the current turn + trace_id = result.get("traceId") or "" + if not trace_id: + trace_ids = result.get("traceIds") or [] + trace_id = trace_ids[-1] if trace_ids else "" + if trace_id: self._last_trace_id = trace_id return trace_id return "" diff --git a/apps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py b/apps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py index 1c8cb6a6c..4992fe6a7 100644 --- a/apps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py +++ b/apps/memos-local-plugin/tests/python/test_hermes_provider_pipeline.py @@ -114,6 +114,9 @@ def test_lifecycle_persists_turn_and_closes_real_episode(self) -> None: turn_end = next(params for method, params in bridge.calls if method == "turn.end") self.assertEqual(turn_end["agent"], "hermes") + # The core returns a singular `traceId` (memory-core.ts onTurnEnd); + # it must be captured for verifier-feedback trace binding. + self.assertEqual(provider._last_trace_id, "trace-1") self.assertEqual(turn_end["sessionId"], "host-session") self.assertEqual(turn_end["episodeId"], "episode-from-turn-start") self.assertIn("HERMES_MEMOS_E2E_0428", turn_end["userText"])