In the past day or so, our code that asks Gemini (2.x, doesn’t seem to matter which model) to call a function with data is now producing inline text with and tags surrounding python code.
We upload data in JSON format for the model to work with, and this issue appears related to the size of that data set. If the data set is small, perhaps 10KB, the model calls our function as requested in the system instructions. If the data set is larger, perhaps over 1MB, the model instead includes the data that should go to the function inline.
The snippet of inline code the model produces always takes this form:
<ctrl97>tool_code
print(default_api.store_results(values=[{
"rules": [
{
"id": "metric_1",
"name": "Channel",
"tab": "Channel",
"value": -129.7696269166154,
"change_type": "fromCurrent",
"interval_type": "absolute"
}
],
"start_date": "2026-01",
"end_date": "2026-12",
"changes_name": "5% Uplift (Channel Spend)",
"changes_summary_text": "Channel update"
}]))<ctrl98>
We’ve seen embedded Python and JSON in responses before, but it’s been due to badly-worded instructions. This suddenly started happening in all our queries in the past 24 hours and is always included instead of calling our function, assuming our included data is large enough.
Any ideas? Has anyone else seen this behavior?