Skip to content

Conversation

ArneZsng
Copy link
Contributor

@ArneZsng ArneZsng commented Oct 6, 2025

Using Gemini, we are frequently running into the MALFORMED_FUNCTION_CALL as the finish reason.
Google seemingly does not provide any context in the response for the reason of the MALFORMED_FUNCTION_CALL.

In these cases, the agent can continue retrying which I why I suggest to simply continue in the case of a MALFORMED_FUNCTION_CALL.

Related to #631

The issue is most prevalent when using Gemini 2.5 Flash (compared to Gemini 2.5 Pro where it also happens but less frequently).

Example chunk:

sdk_http_response=HttpResponse(
  headers=<dict len=11>
) candidates=[Candidate(
  finish_reason=<FinishReason.MALFORMED_FUNCTION_CALL: 'MALFORMED_FUNCTION_CALL'>,
  index=0
)] create_time=None model_version=None prompt_feedback=None response_id=None usage_metadata=GenerateContentResponseUsageMetadata(
  prompt_token_count=2595,
  prompt_tokens_details=[
    ModalityTokenCount(
      modality=<MediaModality.TEXT: 'TEXT'>,
      token_count=2595
    ),
  ],
  total_token_count=2595
) automatic_function_calling_history=None parsed=None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant