Repository navigation
fix(tools): declare items for array parameters of built-in tools - #297
Open
mayuriphad wants to merge 1 commit into
Open
mayuriphad wants to merge 1 commit into
mayuriphad wants to merge 1 commit into
Conversation
OpenAI rejects a function schema when an array parameter has no items, so any agent given ArxivToolkit, GmailToolkit, FaissToolkit or the image toolkits failed on its first OpenAI call with "array schema missing items". Declare the item type on each of these parameters, and add a test that checks every tool's inputs. Fixes ANative-Lab#296 Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This branch has not been deployed
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 #296
What
OpenAI rejects a whole request when a function schema has an array parameter without
items(400 invalid_function_parameters: array schema missing items).CustomizeActionsends the tools'inputsunchanged, so an agent with any of these toolkits failed on its first call to an OpenAI (or OpenRouter) model, before any tool ran.This declares the item type on every built-in array parameter that was missing it:
itemsrequest_arxiv.pyid_list{"type": "string"}gmail_tools.pylabel_ids(3 tools),message_ids(2 tools),add_labels,remove_labels,attachments(2 tools){"type": "string"}image_tools/openai_image_tools/image_edit.pyimages{"type": "string"}image_tools/openrouter_image_tools/image_generation.pyimage_urls,image_paths{"type": "string"}database_faiss.pydocuments{"anyOf": [{"type": "string"}, {"type": "object"}]}, since a document is a text/file path or an object withtext,metadata,doc_idThe other array parameters (e.g.
doc_idsinFaissToolkit, the research tools) already declareitems.Test
tests/src/tools/test_tool_array_schemas.pyparses every module underevoagentx/tools/withast, takes each class-levelinputsdict literal, and fails if any"type": "array"schema, at any depth, has noitems. It reads the source only, so it doesn't need the optional dependencies of the toolkits (Gmail, FAISS, image providers). Onmainit lists the 14 parameters above; with this change it passes. I checked that by running the same scan against both trees; I did not run the full pytest suite locally.