@@ -21,10 +21,17 @@ def _make_retrieval_response() -> Dict[str, Any]:
2121 "query" : "refund policy" ,
2222 "router_used" : "discovery+agent" ,
2323 "answer_text" : "Annual plans may be refunded within 30 days of purchase." ,
24+ "evidence_text" : "Rendered retrieval evidence" ,
25+ "stop_reason" : "answer_done" ,
26+ "failure_reason" : "insufficient evidence" ,
2427 "referenced_chunks" : [
2528 {
2629 "chunk_id" : "chunk_001" ,
2730 "document_id" : "doc_123" ,
31+ "chunk_type" : "text" ,
32+ "section_path" : "Policies / Billing / Refunds" ,
33+ "file_path" : None ,
34+ "job_id" : "job_123" ,
2835 "asset_url" : "https://example.com/assets/chunk_001" ,
2936 }
3037 ],
@@ -44,11 +51,13 @@ def _make_retrieval_response() -> Dict[str, Any]:
4451
4552
4653def _make_legacy_retrieval_response () -> Dict [str , Any ]:
47- """Legacy-mode response without agentic fields (backward compatibility) ."""
54+ """Legacy-mode response with server-default agentic fields."""
4855 return {
4956 "namespace" : "support-center" ,
5057 "query" : "refund policy" ,
5158 "router_used" : "discovery+legacy" ,
59+ "answer_text" : None ,
60+ "referenced_chunks" : [],
5261 "results" : [
5362 {
5463 "chunk_type" : "text" ,
@@ -126,7 +135,12 @@ def test_query_sends_request_and_returns_results(self, sync_client: Any) -> None
126135 "Annual plans may be refunded within 30 days of purchase."
127136 )
128137 assert len (response .referenced_chunks ) == 1
129- assert response .referenced_chunks [0 ]["chunk_id" ] == "chunk_001"
138+ assert response .evidence_text == "Rendered retrieval evidence"
139+ assert response .stop_reason == "answer_done"
140+ assert response .failure_reason == "insufficient evidence"
141+ assert response .referenced_chunks [0 ].chunk_id == "chunk_001"
142+ assert response .referenced_chunks [0 ].chunk_type == "text"
143+ assert response .referenced_chunks [0 ].file_path is None
130144 assert not hasattr (response .results [0 ], "citation" )
131145 assert not hasattr (response .results [0 ], "chunk_id" )
132146 assert not hasattr (response .results [0 ], "section_id" )
@@ -188,8 +202,8 @@ def test_use_agentic_omitted_when_none(self, sync_client: Any) -> None:
188202
189203 @respx .mock
190204 def test_agentic_response_fields (self , sync_client : Any ) -> None :
191- """Agentic response exposes answer_text and referenced_chunks ."""
192- route = respx .post (RETRIEVAL_QUERY_URL ).mock (
205+ """Agentic response exposes answer, evidence, and typed references ."""
206+ respx .post (RETRIEVAL_QUERY_URL ).mock (
193207 return_value = httpx .Response (200 , json = _make_retrieval_response ())
194208 )
195209
@@ -202,15 +216,23 @@ def test_agentic_response_fields(self, sync_client: Any) -> None:
202216 "Annual plans may be refunded within 30 days of purchase."
203217 )
204218 assert len (response .referenced_chunks ) == 1
205- assert response .referenced_chunks [0 ]["chunk_id" ] == "chunk_001"
206- assert response .referenced_chunks [0 ]["asset_url" ] == (
219+ assert response .referenced_chunks [0 ].chunk_id == "chunk_001"
220+ assert response .referenced_chunks [0 ].document_id == "doc_123"
221+ assert response .referenced_chunks [0 ].chunk_type == "text"
222+ assert response .referenced_chunks [0 ].section_path == "Policies / Billing / Refunds"
223+ assert response .referenced_chunks [0 ].file_path is None
224+ assert response .referenced_chunks [0 ].job_id == "job_123"
225+ assert response .referenced_chunks [0 ].asset_url == (
207226 "https://example.com/assets/chunk_001"
208227 )
228+ assert response .evidence_text == "Rendered retrieval evidence"
229+ assert response .stop_reason == "answer_done"
230+ assert response .failure_reason == "insufficient evidence"
209231
210232 @respx .mock
211233 def test_legacy_response_without_agentic_fields (self , sync_client : Any ) -> None :
212- """Legacy-mode response (no agentic fields) parses without error ."""
213- route = respx .post (RETRIEVAL_QUERY_URL ).mock (
234+ """Legacy-mode response defaults agentic fields to null and empty references ."""
235+ respx .post (RETRIEVAL_QUERY_URL ).mock (
214236 return_value = httpx .Response (
215237 200 , json = _make_legacy_retrieval_response ()
216238 )
0 commit comments