diff --git a/apps/api/app/api/v1/routes/retrieval.py b/apps/api/app/api/v1/routes/retrieval.py index 5db937130..700049fed 100644 --- a/apps/api/app/api/v1/routes/retrieval.py +++ b/apps/api/app/api/v1/routes/retrieval.py @@ -83,6 +83,9 @@ class RetrievalQueryResponse(BaseModel): answer_text: str | None = None referenced_chunks: list[dict] = Field(default_factory=list) results: list[dict] = Field(default_factory=list) + evidence_text: str | None = None + stop_reason: str | None = None + failure_reason: str | None = None @router.post("/query", response_model=RetrievalQueryResponse) diff --git a/docs/assets/benchmark-performance.png b/docs/assets/benchmark-performance.png deleted file mode 100644 index 2a1e48fe5..000000000 Binary files a/docs/assets/benchmark-performance.png and /dev/null differ diff --git a/packages/shared-python/shared/services/retrieval/execution/response_projection.py b/packages/shared-python/shared/services/retrieval/execution/response_projection.py index 14e84bf4b..90e811972 100644 --- a/packages/shared-python/shared/services/retrieval/execution/response_projection.py +++ b/packages/shared-python/shared/services/retrieval/execution/response_projection.py @@ -42,6 +42,12 @@ async def project_public_retrieval_response(response: dict[str, Any]) -> dict[st public_response['answer_text'] = response['answer_text'] if response.get('referenced_chunks') is not None: public_response['referenced_chunks'] = response['referenced_chunks'] + if response.get('evidence_text') is not None: + public_response['evidence_text'] = response['evidence_text'] + if response.get('stop_reason') is not None: + public_response['stop_reason'] = response['stop_reason'] + if response.get('failure_reason') is not None: + public_response['failure_reason'] = response['failure_reason'] projected_rows = await enrich_rows_with_retrieval_asset_urls( response.get('results', []), diff --git a/packages/shared-python/shared/services/retrieval/execution/routes.py b/packages/shared-python/shared/services/retrieval/execution/routes.py index b47c7351b..efb24f240 100644 --- a/packages/shared-python/shared/services/retrieval/execution/routes.py +++ b/packages/shared-python/shared/services/retrieval/execution/routes.py @@ -129,6 +129,24 @@ async def _run_agentic_route( response["referenced_chunks"] = resolved_references.refs response["results"] = [attach_citation(row) for row in assembled_workflow_rows] + evidence_parts = [ + step.evidence_text + for step in workflow_result.steps + if step.evidence_text + ] + if evidence_parts: + response["evidence_text"] = "\n\n".join(evidence_parts) + + last_retrieve = next( + (s for s in reversed(workflow_result.steps) if s.step_kind == "retrieve"), + None, + ) + if last_retrieve: + if last_retrieve.stop_reason: + response["stop_reason"] = last_retrieve.stop_reason + if last_retrieve.failure_reason: + response["failure_reason"] = last_retrieve.failure_reason + completion_detail = ( f"chunks | answer={len(workflow_result.answer_text)} chars | " f"router={workflow_result.router_used}"