mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-22 07:56:48 +00:00
fix(trace):memory 中文 in trace info is unicode escape sequence. (#3104)
* fix(trace):memory 中文 in trace is unicode * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -338,7 +338,7 @@ class MemoryUpdater:
|
|||||||
reinforcement_detected=reinforcement_detected,
|
reinforcement_detected=reinforcement_detected,
|
||||||
)
|
)
|
||||||
prompt = MEMORY_UPDATE_PROMPT.format(
|
prompt = MEMORY_UPDATE_PROMPT.format(
|
||||||
current_memory=json.dumps(current_memory, indent=2),
|
current_memory=json.dumps(current_memory, indent=2, ensure_ascii=False),
|
||||||
conversation=conversation_text,
|
conversation=conversation_text,
|
||||||
correction_hint=correction_hint,
|
correction_hint=correction_hint,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -78,6 +78,41 @@ def test_apply_updates_skips_existing_duplicate_and_preserves_removals() -> None
|
|||||||
assert all(fact["id"] != "fact_remove" for fact in result["facts"])
|
assert all(fact["id"] != "fact_remove" for fact in result["facts"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_prepare_update_prompt_preserves_non_ascii_memory_text() -> None:
|
||||||
|
updater = MemoryUpdater()
|
||||||
|
current_memory = _make_memory(
|
||||||
|
facts=[
|
||||||
|
{
|
||||||
|
"id": "fact_cn",
|
||||||
|
"content": "Deer-flow是一个非常好的框架。",
|
||||||
|
"category": "context",
|
||||||
|
"confidence": 0.9,
|
||||||
|
"createdAt": "2026-05-20T00:00:00Z",
|
||||||
|
"source": "thread-cn",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch("deerflow.agents.memory.updater.get_memory_config", return_value=_memory_config(enabled=True)),
|
||||||
|
patch("deerflow.agents.memory.updater.get_memory_data", return_value=current_memory),
|
||||||
|
):
|
||||||
|
msg = MagicMock()
|
||||||
|
msg.type = "human"
|
||||||
|
msg.content = "你好"
|
||||||
|
prepared = updater._prepare_update_prompt(
|
||||||
|
[msg],
|
||||||
|
agent_name=None,
|
||||||
|
correction_detected=False,
|
||||||
|
reinforcement_detected=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert prepared is not None
|
||||||
|
_, prompt = prepared
|
||||||
|
assert "Deer-flow是一个非常好的框架。" in prompt
|
||||||
|
assert "\\u" not in prompt
|
||||||
|
|
||||||
|
|
||||||
def test_apply_updates_skips_same_batch_duplicates_and_keeps_source_metadata() -> None:
|
def test_apply_updates_skips_same_batch_duplicates_and_keeps_source_metadata() -> None:
|
||||||
updater = MemoryUpdater()
|
updater = MemoryUpdater()
|
||||||
current_memory = _make_memory()
|
current_memory = _make_memory()
|
||||||
|
|||||||
Reference in New Issue
Block a user