Skip to content

support default arguments on function tools - #2076

Merged
theomonnom merged 1 commit into
mainfrom
theo/default-values-fnc
Apr 22, 2025
Merged

theomonnom merged 1 commit into
mainfrom
theo/default-values-fnc

Conversation

@theomonnom

@theomonnom theomonnom commented Apr 22, 2025 •

Copy link
Copy Markdown
Member
  • also cleanup the function description given to the LLMs

fix #1987

Note that the LLM isn't aware of the default value, this context isn't added, it isn't supported by strict function descriptions.

Users need to add it on their function tool description if necessary

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Changeset Required

We detected changes in the following package(s) but no changeset file was found. Please add one for proper versioning:

  • livekit-agents

👉 Create a changeset file by clicking here.

@theomonnom
theomonnom requested a review from a team April 22, 2025 12:18

@longcw longcw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@theomonnom
theomonnom merged commit 3ca93a1 into main Apr 22, 2025
@theomonnom
theomonnom deleted the theo/default-values-fnc branch April 22, 2025 12:52
if json_schema.get("default", NOT_GIVEN) is None:
json_schema.pop("default")
# strict mode doesn't support default
if json_schema.get("default") is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This needs to be if "default" in json_schema.

A standard default value is None, so if a user wants to specify a default value as None this won't catch it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, I just did it here #2187

u9g added a commit that referenced this pull request Aug 3, 2026
…inator

The guard fired on a keyword the API does not object to: a live strict tool call
is accepted with `discriminator` present, and only `oneOf` is rejected — which
_ensure_strict_json_schema already converts. So the guard rejected schemas that
work, and refusing them broke discriminated unions that used to build fine.

The `discriminator` pop it replaced had no stated purpose either (added in #2076
alongside pop("title"), not inherited from openai-python, and unreachable for
discriminated unions until #5324 converted oneOf), and nothing reads the keyword
back — pydantic re-derives the tag from the model. Leave it in the schema.

The fidelity problem the guard was aimed at is the null sentinel landing on a
defaulted tag field, fixed separately against main.
u9g added a commit that referenced this pull request Aug 6, 2026
…inator

The guard fired on a keyword the API does not object to: a live strict tool call
is accepted with `discriminator` present, and only `oneOf` is rejected — which
_ensure_strict_json_schema already converts. So the guard rejected schemas that
work, and refusing them broke discriminated unions that used to build fine.

The `discriminator` pop it replaced had no stated purpose either (added in #2076
alongside pop("title"), not inherited from openai-python, and unreachable for
discriminated unions until #5324 converted oneOf), and nothing reads the keyword
back — pydantic re-derives the tag from the model. Leave it in the schema.

The fidelity problem the guard was aimed at is the null sentinel landing on a
defaulted tag field, fixed separately against main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default value for function tool argument doesn't work for some types

3 participants