Skip to content

Fix toolcall error #40547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Fix toolcall error #40547

wants to merge 15 commits into from

Conversation

howieleung
Copy link
Member

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

dargilco and others added 15 commits March 28, 2025 14:01
* Add Prompty as dependency

* Ignore linters

* Fix linter issues

* Address PR review comments
This reverts commit 47eea99.
* [AI] [Projects] add latest TypeSpec commit

* auto-genned code in PR branch

* update custom code with openapi optional parameter

* update openapi sample to use default_parameters param

* add bing custom search tool definition

* add bing custom search sample

* mypy error

* revert bad doc strings

* fix tox sphinx

* add content

* revert operations upload_file methods

* fix one lint issue

* make default_parameter an optional

* fix lint error - line too long

* add type annotation to default_params

* update snippets
* [AI] [Projects] List Threads operation commit from TypeSpec

* generated code

* show sample usage of list_threads API

* add doc link for sample

* review feedback
* Redesign automatic toolcalls

* fix test
Image input support for assistants create message
dargilco
dargilco previously approved these changes Apr 16, 2025
@@ -734,7 +734,7 @@ def execute(self, tool_call: RequiredFunctionToolCall) -> Any:
try:
function, parsed_arguments = self._get_func_and_args(tool_call)
return function(**parsed_arguments) if parsed_arguments else function()
except TypeError as e:
except Exception as e:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes both execute function are only called by the following code:

        for tool_call in tool_calls:
            try:
                if tool_call.type == "function":
                    tool = self.get_tool(FunctionTool)
                    output = tool.execute(tool_call)
                    tool_output = {
                        "tool_call_id": tool_call.id,
                        "output": output,
                    }
                    tool_outputs.append(tool_output)
            except Exception as e:  # pylint: disable=broad-exception-caught
                tool_output = {"tool_call_id": tool_call.id, "output": str(e)}
                tool_outputs.append(tool_output)

With that said, before this change, output field is the error message for non-TypeError exception. With this change all exceptions will cause the output to be {error = }

@howieleung howieleung changed the base branch from feature/azure-ai-projects-beta9 to main April 16, 2025 20:10
@howieleung howieleung dismissed dargilco’s stale review April 16, 2025 20:10

The base branch was changed.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants