Function calling: How to control parameter size?

I have a function like below:

tools = [
    {
        "type": "function",
        "name": "post_messages",
        "description": "Create a batch of messages inside a thread",
        "parameters": {
            "type": "object",
            "properties": {
                "texts": {
                    "type": "array",
                    "description": "An array of text contents for posts.",
                    "items": {
                        "type": "string",
                        "description": "text content of one post",
                    },
                },
            },
            "required": ["texts"],
        },
    },
]

If I ask a model (I have tried GPT-5 and GPT-4.1) to do something like “Create a post for each UN country where the content is their name and population”, it looks like the model always calls the function with only 10 elements for the array parameter. If I specifically say “Create 193 posts for all UN countries where each post’s content is the country’s name and population”, the model would call the function with 20 countries. Is there way for me to force it too call the function with all 193 countries/as much data as possible?

Thank you for your help!

Welcome to the forum. I think what you need here is prompt chaining.

It is similar to why you can’t tell the LLM to count to 1 million.

Although some models do have large output specs, there are platform prompts that act as guardrails that make it difficult to generate a large output. Also the larger the output the more likely they are to hallucinate.

Instead of asking for a huge amount of articles, you first only ask for a list of countries.

Then, you trigger a sequel of individual requests for each one or smaller batches like 5 or 10 each.

Thank you, that makes sense. Do you know if there’s a limit to how many tool calls the llm can make per prompt too? i.e. Can I ask it to repeatedly call a function to do batch requests with just 1 prompt or I’ll have to do the “loop” the prompts myself?

This is not a case of “how many tool calls” but rather, “how long of an array will the AI produce”. The AI model training makes anything before gpt-5 very hesitant to write anything over 2000 tokens or so, and a function is a pattern for invoking an external API or code to help satisfy a request, further training to not be a verbose output, but instead to put some action into motion.

It seems like you are using functions as an output, instead of a response format. What is the function going to return to the AI model that is useful, or what does it do otherwise? The function description offers no purpose or utility for it being there.

In this case, I think it is better to use a more deterministic approach an make manual requests.

There isn’t a limit to function call but I think it will fall into similar limitations for this amount of data, not to say much less reliable.