ADK input and output for llm function call using Gemini model

When it comes to tool calling, it can quickly get complicated - as tool calling can behave quite differently for different models, how do you pass those response back to the LLM model so that it can be used. 

If we were to use a 2 billion paramater smaller model, those tool calling cane challenging. Having said that, it is worth look behind the scene how tool happens - what is the input and output when using it with Google ADK 

This is what an input to the model using Google ADK looks like using Gemini-2.5-flash



model='gemini-2.5-flash' contents=[Content(
  parts=[
    Part(
      text='What is my account balance including pending charges for user_123?'
    ),
  ],
  role='user'
)] config=GenerateContentConfig(
  system_instruction="""You are a helpful customer support agent. Answer questions concisely.

You are an agent. Your internal name is "account_assistant".""",
  tools=[
    Tool(
      function_declarations=[
        FunctionDeclaration(
          description="""Retrieves the current bank balance for a specific user ID.

    Args:
        user_id: The unique account identifier for the customer.
        include_pending: Whether to include pending uncleared transactions.
    """,
          name='get_user_account_balance',
          parameters=Schema(
            properties={<... 2 items at Max depth ...>},
            required=[<... 1 item at Max depth ...>],
            type=<Type.OBJECT: 'OBJECT'>
          ),
          response=Schema(
            type=<Type.OBJECT: 'OBJECT'>
          )
        ),
      ]
    ),
  ]
) live_connect_config=LiveConnectConfig(
  input_audio_transcription=AudioTranscriptionConfig(),
  output_audio_transcription=AudioTranscriptionConfig()
) tools_dict={'get_user_account_balance': <google.adk.tools.function_tool.FunctionTool object at 0x00000128D5D0F350>} cache_config=None cache_metadata=None cacheable_contents_token_count=None previous_interaction_id=None



And this is the model response after calling a tool :- 


model_version='gemini-2.5-flash' content=Content(
  parts=[
    Part(
      function_call=FunctionCall(
        args={
          'include_pending': True,
          'user_id': 'user_123'
        },
        id='adk-654df889-9e47-4d3b-b9c9-5af09d953e7d',
        name='get_user_account_balance'
      ),
      thought_signature=b'\n\xef\x04\x01\x8f=k_>B\x88M\x84\xf2l\xb9\x8a\xe7\xe0\xfb\xfaV\x97\xc2\xf56X,Nt\x86\x05v\xeeK\xd3\xae\x8e\xf4\xf0\x11\x08\x19\x92\xe0A\x9f\x89R"q-\x97\xcbz\xee\x84-\x9b\xd7\xb7^k\x00/\xa8\x99\x83\xdc\x96\x84X\x830a\x8c\xcbv\xbdZ\xe6vL1{\xceu\xf1\xae\xfc:\x92\xed\xb7\xc6\x9b\x15...'
    ),
  ],
  role='model'
) grounding_metadata=None partial=None turn_complete=None finish_reason=<FinishReason.STOP: 'STOP'> error_code=None error_message=None interrupted=None custom_metadata=None usage_metadata=GenerateContentResponseUsageMetadata(
  candidates_token_count=19,
  candidates_tokens_details=[
    ModalityTokenCount(
      modality=<MediaModality.TEXT: 'TEXT'>,
      token_count=19
    ),
  ],
  prompt_token_count=109,
  prompt_tokens_details=[
    ModalityTokenCount(
      modality=<MediaModality.TEXT: 'TEXT'>,
      token_count=109
    ),
  ],
  thoughts_token_count=157,
  total_token_count=285,
  traffic_type=<TrafficType.ON_DEMAND: 'ON_DEMAND'>
) live_session_resumption_update=None live_session_id=None go_away=None input_transcription=None output_transcription=None avg_logprobs=-1.1227462166234066 logprobs_result=None cache_metadata=None citation_metadata=None interaction_id=None invocation_id='e-f7385a76-e699-4c7f-8e62-a45337a4c641' author='account_assistant' actions=EventActions(skip_summarization=None, state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None, requested_auth_configs={}, requested_tool_confirmations={}, compaction=None, end_of_agent=None, agent_state=None, rewind_before_invocation_id=None, render_ui_widgets=None) long_running_tool_ids=set() branch=None id='eba8311a-358c-4bd0-b494-1f4ac2a920ed' timestamp=1791398392.1044016
[TOOL RESULT]: {'user_id': 'user_123', 'balance': '$4,250.00', 'pending': '$120.00'}
-------------------------------------------------------------
model_version=None content=Content(
  parts=[
    Part(
      function_response=FunctionResponse(
        id='adk-654df889-9e47-4d3b-b9c9-5af09d953e7d',
        name='get_user_account_balance',
        response={
          'balance': '$4,250.00',
          'pending': '$120.00',
          'user_id': 'user_123'
        }
      )
    ),
  ],
  role='user'
) grounding_metadata=None partial=None turn_complete=None finish_reason=None error_code=None error_message=None interrupted=None custom_metadata=None usage_metadata=None live_session_resumption_update=None live_session_id=None go_away=None input_transcription=None output_transcription=None avg_logprobs=None logprobs_result=None cache_metadata=None citation_metadata=None interaction_id=None invocation_id='e-f7385a76-e699-4c7f-8e62-a45337a4c641' author='account_assistant' actions=EventActions(skip_summarization=None, state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None, requested_auth_configs={}, requested_tool_confirmations={}, compaction=None, end_of_agent=None, agent_state=None, rewind_before_invocation_id=None, render_ui_widgets=None) long_running_tool_ids=None branch=None id='d30c7032-81ef-4324-bb36-18f6ee36c3c5' timestamp=1791398396.7262437
[TEXT OUTPUT]: Your account balance is $4,250.00 and there is $120.00 in pending charges.
-------------------------------------------------------------
model_version='gemini-2.5-flash' content=Content(
  parts=[
    Part(
      text='Your account balance is $4,250.00 and there is $120.00 in pending charges.'
    ),
  ],
  role='model'
) grounding_metadata=None partial=None turn_complete=None finish_reason=<FinishReason.STOP: 'STOP'> error_code=None error_message=None interrupted=None custom_metadata=None usage_metadata=GenerateContentResponseUsageMetadata(
  candidates_token_count=27,
  candidates_tokens_details=[
    ModalityTokenCount(
      modality=<MediaModality.TEXT: 'TEXT'>,
      token_count=27
    ),
  ],
  prompt_token_count=318,
  prompt_tokens_details=[
    ModalityTokenCount(
      modality=<MediaModality.TEXT: 'TEXT'>,
      token_count=318
    ),
  ],
  total_token_count=345,
  traffic_type=<TrafficType.ON_DEMAND: 'ON_DEMAND'>
) live_session_resumption_update=None live_session_id=None go_away=None
input_transcription=None output_transcription=None avg_logprobs=
None logprobs_result=None cache_metadata=None citation_metadata=None
interaction_id=None invocation_id='e-f7385a76-e699-4c7f-8e62-a45337a4c641'
author='account_assistant' actions=EventActions(skip_summarization=None,
state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None,
requested_auth_configs={}, requested_tool_confirmations={}, compaction=None,
end_of_agent=None, agent_state=None, rewind_before_invocation_id=None,
render_ui_widgets=None) long_running_tool_ids=None
branch=None id='a14ed34d-dc67-48db-b4a1-59cc0c2bdfcc' timestamp=1791398396.7282667




Gwen 2-B parameter distill LLM in tool calling 

Then we run the same code but this time using another model. Let's see what the output looks like this below. As you can see, gwen tend to see this differently. Instead of running the tool, it returns output to run the function in a python environment. For Gemini, the get_user_balance is ran. What does this means - it means you will not get the output results. 



21:52:47 - LiteLLM:INFO: utils.py:3995 -
LiteLLM completion() model= empero-ai/Qwen3.8-2B-Distill-GGUF; provider = openai
2026-10-08 21:52:47,960 - INFO -
LiteLLM completion() model= empero-ai/Qwen3.8-2B-Distill-GGUF; provider = openai
[TEXT OUTPUT]: The user wants to know their account balance including pending
charges for a specific user ID (user_123). I need to use
the get_user_account_balance function with the appropriate parameters.
The include_pending parameter defaults to false, but since
the user explicitly requested "including pending charges," I should set it to true.

[TEXT OUTPUT]: ```python
from get_user_account_balance import get_user_account_balance

balance = get_user_account_balance(user_id="user_123", include_pending=True)
print(balance)

```

**Expected output:** A numeric value representing the current balance,
including any pending charges that haven't been cleared yet.
-------------------------------------------------------------
model_version='empero-ai/Qwen3.8-2B-Distill-GGUF' content=Content(
  parts=[
    Part(
      text="""The user wants to know their account balance including
pending charges for a specific user ID (user_123). I need to use the
get_user_account_balance function with the appropriate parameters.
The include_pending parameter defaults to false, but since the user explicitly
requested "including pending charges," I should set it to true.
""",
      thought=True
    ),
    Part(
      text="""```python
from get_user_account_balance import get_user_account_balance

balance = get_user_account_balance(user_id="user_123", include_pending=True)
print(balance)
```

**Expected output:** A numeric value representing the current balance,
including any pending charges that haven't been cleared yet."""
    ),
  ],
  role='model'
) grounding_metadata=None partial=False turn_complete=None
finish_reason=<FinishReason.STOP: 'STOP'> error_code=None error_message=None
interrupted=None custom_metadata=None
usage_metadata=GenerateContentResponseUsageMetadata(
  cached_content_token_count=0,
  candidates_token_count=131,
  prompt_token_count=372,
  total_token_count=503
) live_session_resumption_update=None
live_session_id=None go_away=None input_transcription=None
output_transcription=None avg_logprobs=None logprobs_result=None
cache_metadata=None citation_metadata=None interaction_id=None
invocation_id='e-cb137e6c-6143-4bed-8de6-cbaf12e13b22'
uthor='account_assistant' actions=EventActions(skip_summarization=None,
state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None,
requested_auth_configs={}, requested_tool_confirmations={}, compaction=None,
end_of_agent=None, agent_state=None, rewind_before_invocation_id=None, render_ui_widgets=None) long_running_tool_ids=None branch=None id='8ae15f64-0af2-4a1d-a379-f3f7eb279db6' timestamp=1791449565.5706277





Comments

Popular posts from this blog

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

llama cpp running it in google colab