@@ -276,48 +276,22 @@ async def security_check(state: AgentState) -> Dict[str, Any]:
276276 # Step 4: LLM Security Analysis (if enabled)
277277 llm_result = {}
278278 if settings .SECURITY_LLM_CHECK_ENABLED :
279- logger .info ("CRASH_DEBUG: Starting LLM Security Check setup" )
280-
281279 # Reconstruct the chain manually as before
282280 try :
283- logger .info ("CRASH_DEBUG: About to import ChatPromptTemplate" )
284281 from langchain_core .prompts import ChatPromptTemplate
285-
286- logger .info ("CRASH_DEBUG: ChatPromptTemplate imported successfully" )
287-
288- logger .info ("CRASH_DEBUG: About to import JsonOutputParser" )
289282 from langchain_core .output_parsers import JsonOutputParser
290283
291- logger .info ("CRASH_DEBUG: JsonOutputParser imported successfully" )
292-
293- logger .info ("CRASH_DEBUG: About to create prompt template" )
294284 prompt = ChatPromptTemplate .from_template (SECURITY_PROMPT )
295- logger .info ("CRASH_DEBUG: Prompt template created successfully" )
296-
297- logger .info ("CRASH_DEBUG: About to call get_llm()" )
298285 llm = get_llm ()
299- logger .info ("CRASH_DEBUG: get_llm() returned successfully" )
300-
301- logger .info ("CRASH_DEBUG: About to create output parser" )
302286 parser = JsonOutputParser ()
303- logger .info ("CRASH_DEBUG: Output parser created successfully" )
304287
305- logger .info ("CRASH_DEBUG: About to create chain with pipe operator" )
306288 chain = prompt | llm | parser
307- logger .info ("CRASH_DEBUG: LLM chain initialized successfully" )
308289 except Exception as e :
309- logger .error (f"CRASH_DEBUG: Failed to initialize LLM chain: { e } " )
290+ logger .error (f"Failed to initialize LLM chain: { e } " )
310291 raise
311292
312- logger .info (
313- "CRASH_DEBUG: Preparing LLM input" ,
314- input_length = len (user_input ),
315- threshold = settings .SECURITY_LLM_CHECK_THRESHOLD ,
316- )
317-
318293 # Using current time for detailed timing
319294 llm_start = time .perf_counter ()
320- logger .info (f"CRASH_DEBUG: Invoking LLM chain... (Time: { llm_start } )" )
321295
322296 try :
323297 # Add a timeout to the LLM call if possible or just log around it
@@ -327,18 +301,13 @@ async def security_check(state: AgentState) -> Dict[str, Any]:
327301 "threshold" : settings .SECURITY_LLM_CHECK_THRESHOLD ,
328302 }
329303 )
330- logger .info ("CRASH_DEBUG: LLM chain returned successfully" )
331304 except Exception as llm_exc :
332- logger .error (f"CRASH_DEBUG: LLM chain raised exception: { llm_exc } " )
305+ logger .error (f"LLM chain raised exception: { llm_exc } " )
333306 # Depending on policy, you might want to block here or set a default score
334307 # For now, re-raise to be caught by the outer try/except
335308 raise
336309
337310 check_time_ms = (time .perf_counter () - llm_start ) * 1000
338-
339- logger .info (
340- f"CRASH_DEBUG: LLM Security Check completed in { check_time_ms :.2f} ms"
341- )
342311 metrics .record_stage_latency ("llm_check" , check_time_ms )
343312 metrics_builder .add_latency ("llm_check" , check_time_ms )
344313
0 commit comments