An output limit belongs in the caller's request policy. A friendly instruction to be brief does not enforce a resource cap. Decide how the requested allowance interacts with the remaining budget, including the smallest valid request, before constructing the client call.
Return None without creating a model request when case.budget is zero or negative. Otherwise return the recorded request. Set max_output_tokens to the smaller of requested and budget, with a minimum of one. Use a fresh client, case.model and case.user. Do not send unsupported parameters.
The notebook executes your Python against an original local mock. Use the supplied case rather than copying visible values. The hidden checks change identities, revisions and boundary inputs; no provider endpoint or external tool is contacted.
An example implementation of the function contract.