"ADK Bug: before_model_callback causes AttributeError on Agent Engine" #3798
Closed
Saoussen-CH
started this conversation in
General
Replies: 1 comment
-
|
Please refer to the guidance on how callbacks should be implemented: https://google.github.io/adk-docs/callbacks/types-of-callbacks/#after-agent-callback The call back method should either return None to ensure that the processing continues or the call back should return an object of type LLM Response to essentially short-circuit the call the model. If your intent was to perform some kind of mutations to LLMRequest object, then you are free to do so. Your callback method gets the same object that will be passed down to the model. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ADK Bug Report: before_model_callback causes AttributeError on Agent Engine
Bug Summary
When deploying an ADK agent with
before_model_callbackto Vertex AI Agent Engine, the agent fails with:This error occurs in ADK's internal
_nl_planning.py:79file, preventing the agent from processing any requests.Impact
before_model_callbackon Agent Enginebefore_model_callbackentirelyEnvironment
Steps to Reproduce
Full Error Traceback
Root Cause Analysis
In
_nl_planning.py:79, the code tries to accessllm_response.content:However, after
before_model_callbackexecutes, the variable is actually anLlmRequestobject (notLlmResponse), which doesn't have acontentattribute.This appears to be a type confusion bug in ADK's internal flow processing.
Expected Behavior
before_model_callbackshould execute successfullyActual Behavior
_nl_planning.pyimmediately crashesUse Case
We're trying to implement Memory Bank integration with a custom callback (since PreloadMemoryTool has its own bugs). This is the recommended approach per Google's documentation:
Workaround
None - The only option is to completely disable
before_model_callback, which removes the ability to:Additional Context
projects/773461168680/locations/us-central1/reasoningEngines/1794943936251297792projects/773461168680/locations/us-central1/reasoningEngines/3116750426884538368projects/773461168680/locations/us-central1/reasoningEngines/6440406951883964416Logs
Cloud Logging query to see the error:
Request
Please fix the type confusion in
_nl_planning.py:79to properly handleLlmRequestobjects returned frombefore_model_callback.Beta Was this translation helpful? Give feedback.
All reactions