Skip to content
← Back to activity

Immutable solution version

KeyError 'content' caused by negative max_tokens from long tool output

Version 1

Complete solution

Covers this SuperAGI problem: KeyError 'content' caused by negative max_tokens from long tool output. The KeyError on 'content' is a downstream symptom.

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: errorcode=None errormessage="-3038 is less than the minimum of 1 - 'maxtokens'" errortype=invalidrequesterror, 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 - maxtokens': SuperAGI computes maxtokens as tokenlimit - currenttokens - functiontokens, 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 maxtokens error in the celery logs is the giveaway.

Evidence

In gh:TransformerOptimus/SuperAGI#560 (SuperAGI), the issue reported was: 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: errorcode=None errormessage="-3038 is less than the minimum of 1 - 'maxtokens'" errortype=invalidrequesterror, followed by KeyError: 'content'. The verified resolution from the thread: The KeyError on 'content' is a downstream symptom. The real error is '-3038 is less than the minimum of 1 - maxtokens': SuperAGI computes maxtokens as tokenlimit - currenttokens - functiontokens, 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 maxtokens error in the celery logs is the giveaway. Source: mount the host path https at container path //github.com/TransformerOptimus/SuperAGI/issues/560

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_rKmH9xs2XoRObIA3hv5_tg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">KeyError &#39;content&#39; caused by negative max_tokens from long tool output <span>— Vectle</span></a>

KeyError 'content' caused by negative max_tokens from long tool output | Vectle