Skip to content

Commit d19a8f6

Browse files
viniciusdsmellogustavocidornelas
authored andcommitted
fix(closes OPEN-8223): enhance Google ADK tracing with improved user query handling and output management
1 parent 994c541 commit d19a8f6

File tree

2 files changed

+348
-353
lines changed

2 files changed

+348
-353
lines changed

examples/tracing/google-adk/google_adk_tracing.ipynb

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@
8181
"cell_type": "code",
8282
"execution_count": null,
8383
"metadata": {},
84-
"outputs": [],
84+
"outputs": [
85+
{
86+
"name": "stderr",
87+
"output_type": "stream",
88+
"text": [
89+
"/Users/vini/Workspace/Openlayer/integrations-sdks/openlayer-python/.venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
90+
" from .autonotebook import tqdm as notebook_tqdm\n"
91+
]
92+
}
93+
],
8594
"source": [
8695
"from openlayer.lib.integrations import trace_google_adk\n",
8796
"\n",
@@ -102,7 +111,17 @@
102111
"cell_type": "code",
103112
"execution_count": null,
104113
"metadata": {},
105-
"outputs": [],
114+
"outputs": [
115+
{
116+
"name": "stdout",
117+
"output_type": "stream",
118+
"text": [
119+
"Successfully streamed data to Openlayer. Response: {\n",
120+
" \"success\": true\n",
121+
"}\n"
122+
]
123+
}
124+
],
106125
"source": [
107126
"\n",
108127
"from google.genai import types\n",
@@ -167,7 +186,24 @@
167186
"cell_type": "code",
168187
"execution_count": null,
169188
"metadata": {},
170-
"outputs": [],
189+
"outputs": [
190+
{
191+
"name": "stderr",
192+
"output_type": "stream",
193+
"text": [
194+
"Warning: there are non-text parts in the response: ['function_call', 'function_call'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response.\n"
195+
]
196+
},
197+
{
198+
"name": "stdout",
199+
"output_type": "stream",
200+
"text": [
201+
"Successfully streamed data to Openlayer. Response: {\n",
202+
" \"success\": true\n",
203+
"}\n"
204+
]
205+
}
206+
],
171207
"source": [
172208
"import os\n",
173209
"\n",
@@ -286,7 +322,7 @@
286322
"\n",
287323
"# 1. Before Agent Callback\n",
288324
"# Called before the agent starts processing a request\n",
289-
"def before_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n",
325+
"def before_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n",
290326
" \"\"\"\n",
291327
" Called before the agent starts its main work.\n",
292328
" \n",
@@ -305,7 +341,7 @@
305341
"\n",
306342
"# 2. After Agent Callback\n",
307343
"# Called after the agent finishes processing\n",
308-
"def after_agent_callback(callback_context: CallbackContext) -> Optional[Any]:\n",
344+
"def after_agent_callback(callback_context: CallbackContext, **_kwargs: Any) -> Optional[Any]:\n",
309345
" \"\"\"\n",
310346
" Called after the agent has finished all its steps.\n",
311347
" \n",
@@ -324,8 +360,9 @@
324360
"# 3. Before Model Callback\n",
325361
"# Called before each LLM call\n",
326362
"def before_model_callback(\n",
327-
" _callback_context: CallbackContext, \n",
328-
" llm_request: LlmRequest\n",
363+
" _callback_context: CallbackContext,\n",
364+
" llm_request: LlmRequest,\n",
365+
" **_kwargs: Any\n",
329366
") -> Optional[LlmResponse]:\n",
330367
" \"\"\"\n",
331368
" Called before sending a request to the LLM.\n",
@@ -346,8 +383,9 @@
346383
"# 4. After Model Callback\n",
347384
"# Called after receiving LLM response\n",
348385
"def after_model_callback(\n",
349-
" _callback_context: CallbackContext, \n",
350-
" llm_response: LlmResponse\n",
386+
" _callback_context: CallbackContext,\n",
387+
" llm_response: LlmResponse,\n",
388+
" **_kwargs: Any\n",
351389
") -> Optional[LlmResponse]:\n",
352390
" \"\"\"\n",
353391
" Called after receiving a response from the LLM.\n",
@@ -370,8 +408,9 @@
370408
"# Called before tool execution\n",
371409
"def before_tool_callback(\n",
372410
" tool: BaseTool, \n",
373-
" args: Dict[str, Any], \n",
374-
" _tool_context: ToolContext\n",
411+
" _args: Dict[str, Any], \n",
412+
" _tool_context: ToolContext,\n",
413+
" **_kwargs: Any\n",
375414
") -> Optional[Dict]:\n",
376415
" \"\"\"\n",
377416
" Called before executing a tool.\n",
@@ -395,7 +434,8 @@
395434
" tool: BaseTool, \n",
396435
" _args: Dict[str, Any], \n",
397436
" _tool_context: ToolContext, \n",
398-
" tool_response: Dict\n",
437+
" tool_response: Dict,\n",
438+
" **_kwargs: Any\n",
399439
") -> Optional[Dict]:\n",
400440
" \"\"\"\n",
401441
" Called after a tool finishes execution.\n",
@@ -436,7 +476,7 @@
436476
"\n",
437477
"# Use different session IDs for callback agent\n",
438478
"CALLBACK_USER_ID = \"user_789\"\n",
439-
"CALLBACK_SESSION_ID = \"session_789\"\n",
479+
"CALLBACK_SESSION_ID = \"session_788\"\n",
440480
"\n",
441481
"# Create agent with ALL 6 callbacks\n",
442482
"callback_agent = LlmAgent(\n",

0 commit comments

Comments
 (0)