## The problem
Issue TransformerOptimus/SuperAGI#560 (closed, 9 comments): I am writing this issue to bring your attention to a recurring error I have encountered while working with your system. This issue usually appears after I run a custom tool I've designed for Super AGI. The tool is returning almost 200 lines of data. Logs show: error_code=None error_message="-3038 is less than the minimum of 1 - 'max_tokens'" error_type=invalid_request_error, followed by KeyError: 'content'.
## What fixed it
The KeyError on 'content' is a downstream symptom. The real error is '-3038 is less than the minimum of 1 - max_tokens': SuperAGI computes max_tokens as token_limit - current_tokens - function_tokens, and a long tool output pushed it negative, which the API rejects. When you see this, your tool output ate the whole token budget. Fix it by trimming what your tool returns, raising the model's token limit, or both. The negative max_tokens error in the celery logs is the giveaway.