Repository navigation
Conversation
… invocations against TypeError
… tool Check the model's arguments against the tool signature (inspect.bind) before calling it, and hand back an error only when one is missing or unexpected. Wrapping the whole call in `except TypeError` also reported a TypeError caused by a bug inside the tool as "Invalid tool arguments", hiding the real problem; that now propagates as before. Add tests for an unexpected argument, a valid call, and a bug inside a tool.
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.
Summary
This PR addresses two resilience issues in tool execution during AI-driven mode:
search_public_contextdefault parameter:search_public_contextpreviously had no default for itsqueryargument (def search_public_context(query: str)). When an LLM model invoked the tool without providing arguments or passing an empty object, Python raised an unhandledTypeError: missing 1 required positional argument: 'query'.query: str = ""and returns a structured validation error ({"error": "Specify a public landmark, venue, brand, or event to search for."}) if omitted._run_tool_callinvocation:try ... except TypeError as ehandler aroundfn(**args)in_run_tool_callso that if any model hallucinates argument names or omits required keys on any tool, the error is returned to the model as a structured tool result instead of bubbling up as an uncaught exception that abruptly aborts the entire AI worker thread withLLM error.tests/test_web_search.pyfor empty/omitted queries.tests/test_app_endpoints.pyverifying_run_tool_callcatches argumentTypeErrors gracefully.