File tree Expand file tree Collapse file tree
testcases/company-research-agent/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import json
22import logging
3- import sys
4- from pathlib import Path
53from typing import Any
64
75from langchain .agents import create_agent
1412
1513logger = logging .getLogger (__name__ )
1614
17- # Monkey-patch to dump raw response to file on failure
15+ # Monkey-patch to surface raw response on failure
1816_original_postprocess = _NormalizedChat ._postprocess_response
19- _debug_file = Path (__file__ ).resolve ().parent .parent / "debug_response.json"
2017
2118def _debug_postprocess (self : Any , response : dict [str , Any ]) -> Any :
2219 if "choices" not in response :
2320 dump = json .dumps (response , indent = 2 , default = str )
24- _debug_file .write_text (dump )
25- sys .stderr .write (f"\n \n ===== DEBUG RAW RESPONSE (no 'choices' key) =====\n { dump } \n =====\n \n " )
26- sys .stderr .flush ()
21+ raise ValueError (
22+ f"LLM response missing 'choices' key. "
23+ f"Got keys: { list (response .keys ())} . "
24+ f"Full response: { dump } "
25+ )
2726 return _original_postprocess (self , response )
2827
2928_NormalizedChat ._postprocess_response = _debug_postprocess
You can’t perform that action at this time.
0 commit comments