Skip to content

Commit 4e45096

Browse files
author
islam666
committed
fix(research): expose resolved model in API and logs (#4567)
1 parent d88c8cb commit 4e45096

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

routes/research/research_routes.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ def _resolve_research_endpoint(sess, owner: Optional[str] = None) -> tuple:
147147
fallback_headers=sess.headers,
148148
owner=owner,
149149
)
150+
sess_model = getattr(sess, "model", None) or ""
151+
if model and sess_model and model != sess_model:
152+
logger.info(
153+
"Research using configured model '%s' (session model was '%s')",
154+
model,
155+
sess_model,
156+
)
157+
elif model:
158+
logger.info("Research using model '%s'", model)
150159
return url, model, headers
151160

152161

@@ -574,7 +583,7 @@ async def research_start(body: ResearchStartRequest, request: Request):
574583
extraction_concurrency=body.extraction_concurrency,
575584
owner=user,
576585
)
577-
return {"session_id": session_id, "status": "running", "query": body.query}
586+
return {"session_id": session_id, "status": "running", "query": body.query, "model": ep_model}
578587

579588
@router.get("/api/research/stream/{session_id}")
580589
async def research_stream(session_id: str, request: Request):

src/research_handler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def start_research(
302302
"result": None,
303303
"started_at": time.time(),
304304
"category": category,
305+
"llm_model": llm_model,
305306
# SECURITY: track ownership so all reads / saves can filter by user.
306307
"owner": owner or "",
307308
}
@@ -413,6 +414,7 @@ def get_status(self, session_id: str) -> Optional[dict]:
413414
"progress": entry["progress"],
414415
"query": entry["query"],
415416
"started_at": entry["started_at"],
417+
"model": entry.get("llm_model"),
416418
}
417419
# avg_duration is a historical figure over completed reports on
418420
# disk; get_avg_duration() globs and JSON-parses the whole research

0 commit comments

Comments
 (0)