mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-21 15:36:48 +00:00
* feat(memory): add structured reflection and correction detection * fix(memory): align sourceError schema and prompt guidance --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -72,6 +72,56 @@ def test_import_memory_route_returns_imported_memory() -> None:
|
||||
assert response.json()["facts"] == imported_memory["facts"]
|
||||
|
||||
|
||||
def test_export_memory_route_preserves_source_error() -> None:
|
||||
app = FastAPI()
|
||||
app.include_router(memory.router)
|
||||
exported_memory = _sample_memory(
|
||||
facts=[
|
||||
{
|
||||
"id": "fact_correction",
|
||||
"content": "Use make dev for local development.",
|
||||
"category": "correction",
|
||||
"confidence": 0.95,
|
||||
"createdAt": "2026-03-20T00:00:00Z",
|
||||
"source": "thread-1",
|
||||
"sourceError": "The agent previously suggested npm start.",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with patch("app.gateway.routers.memory.get_memory_data", return_value=exported_memory):
|
||||
with TestClient(app) as client:
|
||||
response = client.get("/api/memory/export")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["facts"][0]["sourceError"] == "The agent previously suggested npm start."
|
||||
|
||||
|
||||
def test_import_memory_route_preserves_source_error() -> None:
|
||||
app = FastAPI()
|
||||
app.include_router(memory.router)
|
||||
imported_memory = _sample_memory(
|
||||
facts=[
|
||||
{
|
||||
"id": "fact_correction",
|
||||
"content": "Use make dev for local development.",
|
||||
"category": "correction",
|
||||
"confidence": 0.95,
|
||||
"createdAt": "2026-03-20T00:00:00Z",
|
||||
"source": "thread-1",
|
||||
"sourceError": "The agent previously suggested npm start.",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with patch("app.gateway.routers.memory.import_memory_data", return_value=imported_memory):
|
||||
with TestClient(app) as client:
|
||||
response = client.post("/api/memory/import", json=imported_memory)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["facts"][0]["sourceError"] == "The agent previously suggested npm start."
|
||||
|
||||
|
||||
def test_clear_memory_route_returns_cleared_memory() -> None:
|
||||
app = FastAPI()
|
||||
app.include_router(memory.router)
|
||||
|
||||
Reference in New Issue
Block a user