fix the unit test error after merging #3651

This commit is contained in:
Willem Jiang 2026-06-21 21:43:43 +08:00
parent 9c62420d67
commit 0d732b65dd
2 changed files with 10 additions and 1 deletions

View file

@ -646,6 +646,10 @@ async def list_thread_messages(
event_store = get_run_event_store(request)
messages = await event_store.list_messages(thread_id, limit=limit, before_seq=before_seq, after_seq=after_seq)
# Resolve the caller once; it is needed both to scope the feedback query
# below and to list the thread's runs for turn-duration injection.
user_id = await get_current_user(request)
# Find the last AI message per run_id. AI messages are persisted by
# RunJournal with event_type "llm.ai.response" (see runtime/journal.py);
# the event store returns that value verbatim, so match on it here.
@ -660,7 +664,6 @@ async def list_thread_messages(
feedback_map: dict[str, dict] = {}
if last_ai_per_run:
feedback_repo = get_feedback_repo(request)
user_id = await get_current_user(request)
feedback_map = await feedback_repo.list_by_thread_grouped(thread_id, user_id=user_id)
last_ai_indices = set(last_ai_per_run.values())

View file

@ -29,6 +29,12 @@ def _make_app(messages, feedback_grouped):
feedback_repo.list_by_thread_grouped = AsyncMock(return_value=feedback_grouped)
app.state.feedback_repo = feedback_repo
# list_thread_messages also calls run_manager.list_by_thread to inject
# turn durations; stub it to return no runs so that path stays inert.
run_manager = MagicMock()
run_manager.list_by_thread = AsyncMock(return_value=[])
app.state.run_manager = run_manager
return app, feedback_repo