adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

'LlmRequest' object has no attribute 'content'

Open ayferkrd opened this issue 1 year ago • 4 comments

** Please make sure you read the contribution guide and file the issues in the right place. ** Contribution guide.

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Install '...'
  2. Run '....'
  3. Open '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Image Image and error: Image

Desktop (please complete the following information):

  • OS: [e.g. iOS]--gcp cloud shell don't know os
  • Python version(python -V): 3.12
  • ADK version(pip show google-adk): 1.4.1

Additional context Add any other context about the problem here.

When I added guardrails to LLmAgent creation, I got this error:

".local/lib/python3.12/site-packages/google/adk/flows/llm_flows/_nl_planning.py", line 80, in run_async or not llm_response.content ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pydantic/main.py", line 989, in getattr raise AttributeError(f'{type(self).name!r} object has no attribute {item!r}') AttributeError: 'LlmRequest' object has no attribute 'content'. Did you mean: 'contents'?"

ayferkrd avatar Jun 20 '25 05:06 ayferkrd

[image: Screenshot 2025-06-20 at 4.31.15 PM.png]

this is library file and error comes from it as ".local/lib/python3.12/site-packages/google/adk/flows/llm_flows/_nl_planning.py", line 80, in run_async or not llm_response.content ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pydantic/main.py", line 989, in getattr raise AttributeError(f'{type(self).name!r} object has no attribute {item!r}') AttributeError: 'LlmRequest' object has no attribute 'content'. Did you mean: 'contents'?"

so yes it is an issue I can run my code..

On Fri, Jun 20, 2025 at 4:06 PM pretbc @.***> wrote:

pretbc left a comment (google/adk-python#1534) https://github.com/google/adk-python/issues/1534#issuecomment-2989898526

is it an issue ? due to implementation:

class LlmRequest(BaseModel): """LLM request class that allows passing in tools, output schema and system instructions to the model. Attributes: model: The model name. contents: The contents to send to the model. config: Additional config for the generate content request. tools_dict: The tools dictionary. """

model_config = ConfigDict(arbitrary_types_allowed=True) """The pydantic model config."""

model: Optional[str] = None """The model name."""

contents: list[types.Content] = Field(default_factory=list) """The contents to send to the model."""

...

— Reply to this email directly, view it on GitHub https://github.com/google/adk-python/issues/1534#issuecomment-2989898526, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTZU53ZCTD2ZKBSVHFZ6PD3EOQFPAVCNFSM6AAAAAB7XMBQHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOBZHA4TQNJSGY . You are receiving this because you authored the thread.Message ID: @.***>

ayferkrd avatar Jun 20 '25 06:06 ayferkrd

@ayferkrd you must have returned modified LLMRequest from your before_model_callback. It only expects None (to let request go for LLM) or an LLMResponse (which means it bypasses LLM call all together)

If you wish to modify LLMRequest, simply modify it in place and return None.

jasveer-os avatar Jun 20 '25 11:06 jasveer-os

@ayferkrd you must have returned modified LLMRequest from your before_model_callback. It only expects None (to let request go for LLM) or an LLMResponse (which means it bypasses LLM call all together)

If you wish to modify LLMRequest, simply modify it in place and return None.

Please try the suggestion here. Closing this and feel free to re-open if the issue persists.

hangfei avatar Aug 14 '25 21:08 hangfei

thank you

On Fri, Aug 15, 2025 at 7:59 AM Hangfei Lin @.***> wrote:

hangfei left a comment (google/adk-python#1534) https://github.com/google/adk-python/issues/1534#issuecomment-3189977704

@ayferkrd https://github.com/ayferkrd you must have returned modified LLMRequest from your before_model_callback. It only expects None (to let request go for LLM) or an LLMResponse (which means it bypasses LLM call all together)

If you wish to modify LLMRequest, simply modify it in place and return None.

Please try the suggestion here. Closing this and feel free to re-open if the issue persists.

— Reply to this email directly, view it on GitHub https://github.com/google/adk-python/issues/1534#issuecomment-3189977704, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTZU55UOGYRFIWFH42577L3NUBFLAVCNFSM6AAAAAB7XMBQHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBZHE3TONZQGQ . You are receiving this because you were mentioned.Message ID: @.***>

ayferkrd avatar Aug 14 '25 23:08 ayferkrd