Skip to content

Commit 6ca8307

Browse files
mjnoviceclaude
andcommitted
feat: add per-field search weights to MemoryConfig
Add field_weights dict to MemoryConfig so users can control which input fields are used for memory search and their relative importance (0.0-1.0). When field_weights is specified, only listed fields are included in the search request, matching the backend behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 44fd7e2 commit 6ca8307

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/uipath_langchain/agent/react/memory_node.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ async def memory_recall_node(state: AgentGraphState) -> dict[str, Any]:
4343
if not input_arguments:
4444
return {}
4545

46-
fields = _build_search_fields(input_arguments)
46+
fields = _build_search_fields(
47+
input_arguments, field_weights=memory_config.field_weights or None
48+
)
4749
if not fields:
4850
return {}
4951

@@ -106,6 +108,9 @@ def _build_search_fields(
106108
for name, value in input_arguments.items():
107109
if value is None or name.startswith("uipath__"):
108110
continue
111+
# When field_weights is specified, only include fields with configured weights
112+
if field_weights and name not in field_weights:
113+
continue
109114
settings = FieldSettings()
110115
if field_weights and name in field_weights:
111116
settings = FieldSettings(weight=field_weights[name])

src/uipath_langchain/agent/react/types.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class MemoryConfig(BaseModel):
7373
)
7474
result_count: int = Field(default=5, ge=1, le=10)
7575
threshold: float = Field(default=0.0, ge=0.0, le=1.0)
76+
field_weights: dict[str, float] = Field(
77+
default_factory=dict,
78+
description=(
79+
"Per-field search weights. Keys are input field names, values are "
80+
"weights between 0.0 and 1.0. Only fields listed here are used for "
81+
"memory search. If empty, all input fields are used with default weight."
82+
),
83+
)
7684

7785

7886
class AgentGraphConfig(BaseModel):

0 commit comments

Comments
 (0)