fix: add configurable tool count validation to prevent empty AI responses - #7
Open
lireno wants to merge 1 commit into
Open
fix: add configurable tool count validation to prevent empty AI responses#7lireno wants to merge 1 commit into
lireno wants to merge 1 commit into
Conversation
…nses (aipotheosis-labs#337) Add MAX_TOOLS validation in the /chat route and openai_chat_stream to prevent cryptic OpenAI API errors when too many functions are selected. OpenAI's Responses API has undocumented limits (~128 tools or ~200k tokens of tool definitions). Exceeding them returns an unhelpful APIError that surfaces as a 500, causing empty AI responses. Improvements over PR aipotheosis-labs#604: - MAX_TOOLS is configurable via SERVER_AGENT_MAX_TOOLS env var (default 64) - Error message lists affected app names so users know which apps to disable - Error message mentions the env var so operators can adjust the limit - Error message truncates long app lists (>10 apps) - Added unit tests for validate_tool_count covering under/at/over limit, app name extraction, env var reference, and empty tools edge case Closes aipotheosis-labs#337 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes aipotheosis-labs#337 — validate_tool_count() with SERVER_AGENT_MAX_TOOLS config, early 400 error, 10 unit tests. Improves on PR aipotheosis-labs#604.