tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK Reasoning Traces and Explainability

ADK Reasoning Traces and Explainability

Author: Venkata Sudhakar

When an ADK agent makes a decision, customers and operations teams sometimes need to understand why. For ShopMax India, if the agent declines a return request or recommends a specific product, the support team may need to audit the reasoning. ADK's event stream exposes every step of the agent's decision process - tool calls, intermediate responses, and final answers.

The example below captures the full event stream from an ADK runner, formats it as a human-readable reasoning trace, and logs it alongside the final response. This trace can be stored for audit, displayed to supervisors, or used to debug unexpected agent behaviour.


It gives the following output,

Query: Can I return order ORD-881?
Reasoning Trace:
  Step 1: Called tool [get_return_policy] with args {}
  Step 2: Tool [get_return_policy] returned: {window_days: 10, condition: ...}
  Step 3: Called tool [check_return_eligibility] with args {order_id: ORD-881}
  Step 4: Tool [check_return_eligibility] returned: {days_since_delivery: 5, eligible: True}
  Step 5: Agent produced final answer
Answer: Yes, order ORD-881 is eligible for return. It was delivered 5 days ago
and is unopened, which meets our 10-day return window and condition requirements.

Query: Can I return order ORD-992?
Reasoning Trace:
  Step 1: Called tool [get_return_policy] with args {}
  Step 2: Tool [get_return_policy] returned: {window_days: 10, ...}
  Step 3: Called tool [check_return_eligibility] with args {order_id: ORD-992}
  Step 4: Tool [check_return_eligibility] returned: {days_since_delivery: 18, eligible: False}
  Step 5: Agent produced final answer
Answer: Unfortunately, order ORD-992 is not eligible for return. It was delivered
18 days ago, which exceeds our 10-day return window.

The trace shows exactly how the agent reasoned - first checking policy, then checking order eligibility, then forming its decision. For ORD-881 it approved the return; for ORD-992 it declined. The operations team can audit this trace to verify the agent applied the correct policy, which is critical for dispute resolution.

For ShopMax India production, persist reasoning traces to Cloud Logging with a structured log format. Tag each trace with the user_id, session_id, and outcome (approved/declined). Set up a Log-based metric that counts declined returns and trigger a Cloud Monitoring alert if the decline rate spikes above 40% - which might indicate a policy misconfiguration in the agent instruction.


 
  


  
bl  br