Skip to content

Commit b07e44e

Browse files
mjnoviceclaude
andcommitted
fix: prefix key_path with field type in memory search fields
The LLMOps memory search API requires key_path to be prefixed with the field type: ["agent-input", "fieldName"] for episodic memory, ["escalation-input", "fieldName"] for escalation memory. This matches the Temporal backend's FieldBuilder (FieldBuilder.cs:15): keyPath = [fieldType.StringValue(), fieldName] Without this prefix, the API returns 400 Bad Request. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3d8e4ef commit b07e44e

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

src/uipath_langchain/agent/react/memory_node.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,15 @@ def _extract_user_inputs(state: Any) -> dict[str, Any]:
149149
def _build_search_fields(
150150
input_arguments: dict[str, Any],
151151
field_weights: dict[str, float] | None = None,
152+
field_type: str = "agent-input",
152153
) -> list[SearchField]:
153-
"""Convert agent input arguments to SearchField objects."""
154+
"""Convert agent input arguments to SearchField objects.
155+
156+
The key_path must be prefixed with the field type, matching the
157+
Temporal backend's FieldBuilder (FieldBuilder.cs:15):
158+
keyPath = [fieldType.StringValue(), fieldName]
159+
e.g. ["agent-input", "a"] for episodic memory.
160+
"""
154161
fields: list[SearchField] = []
155162
for name, value in input_arguments.items():
156163
if value is None or name.startswith("uipath__"):
@@ -161,5 +168,9 @@ def _build_search_fields(
161168
settings = FieldSettings()
162169
if field_weights and name in field_weights:
163170
settings = FieldSettings(weight=field_weights[name])
164-
fields.append(SearchField(key_path=[name], value=str(value), settings=settings))
171+
fields.append(
172+
SearchField(
173+
key_path=[field_type, name], value=str(value), settings=settings
174+
)
175+
)
165176
return fields

src/uipath_langchain/agent/tools/escalation_tool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,14 @@ async def _check_escalation_memory_cache(
467467
if k in field_settings_lookup:
468468
fs = field_settings_lookup[k]
469469
settings = FieldSettings(weight=fs.get("weight", 1.0))
470-
fields.append(SearchField(key_path=[k], value=str(v), settings=settings))
470+
# key_path must be prefixed with field type (FieldBuilder.cs:15)
471+
fields.append(
472+
SearchField(
473+
key_path=["escalation-input", k],
474+
value=str(v),
475+
settings=settings,
476+
)
477+
)
471478
if not fields:
472479
return None
473480

tests/agent/react/test_memory_node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def test_basic_fields(self) -> None:
3838
fields = _build_search_fields({"topic": "python", "level": "advanced"})
3939
assert len(fields) == 2
4040
key_paths = [f.key_path for f in fields]
41-
assert ["topic"] in key_paths
42-
assert ["level"] in key_paths
41+
assert ["agent-input", "topic"] in key_paths
42+
assert ["agent-input", "level"] in key_paths
4343

4444
def test_filters_none_and_uipath_prefix(self) -> None:
4545
fields = _build_search_fields(
4646
{"topic": "py", "uipath__settings": {}, "empty": None}
4747
)
4848
assert len(fields) == 1
49-
assert fields[0].key_path == ["topic"]
49+
assert fields[0].key_path == ["agent-input", "topic"]
5050

5151
def test_empty_input(self) -> None:
5252
assert _build_search_fields({}) == []

0 commit comments

Comments
 (0)