Skip to content

Conversation

ashwinb
Copy link
Contributor

@ashwinb ashwinb commented Oct 1, 2025

This is a sweeping change to clean up some gunk around our "Tool" definitions.

First, we had two types Tool and ToolDef. The first of these was a "Resource" type for the registry but we had stopped registering tools inside the Registry long back (and only registered ToolGroups.) The latter was for specifying tools for the Agents API. This PR removes the former and adds an optional toolgroup_id field to the latter.

Secondly, as pointed out by @bbrowning in #3003 (comment), we were doing a lossy conversion from a full JSON schema from the MCP tool specification into our ToolDefinition to send it to the model. There is no necessity to do this -- we ourselves aren't doing any execution at all but merely passing it to the chat completions API which supports this. By doing this (and by doing it poorly), we encountered limitations like not supporting array items, or not resolving $refs, etc.

To fix this, we replaced the parameters field by { input_schema, output_schema } which can be full blown JSON schemas.

Finally, there were some types in our llama-related chat format conversion which needed some cleanup. We are taking this opportunity to clean those up.

This PR is a substantial breaking change to the API. However, given our window for introducing breaking changes, this suits us just fine. I will be landing a concurrent llama-stack-client change as well since API shapes are changing.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 1, 2025
@ashwinb ashwinb changed the title feat(tools): use { input_schema, output_schema } for ToolDefinition feat(tools)!: use { input_schema, output_schema } for ToolDefinition Oct 1, 2025
@ashwinb ashwinb changed the title feat(tools)!: use { input_schema, output_schema } for ToolDefinition feat(tools)!: substantial clean up of "Tool" related datatypes Oct 2, 2025
@ashwinb
Copy link
Contributor Author

ashwinb commented Oct 2, 2025

Corresponding llama-stack-client PR: llamastack/llama-stack-client-python#277

@ashwinb ashwinb merged commit ef07365 into llamastack:main Oct 2, 2025
23 of 26 checks passed
@ashwinb ashwinb deleted the resp_branching branch October 2, 2025 22:12
from llama_stack.models.llama.datatypes import BuiltinTool, ToolDefinition


class TestToolDefValidation:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are some horrible tests. will nuke.

raghotham pushed a commit to raghotham/llama-stack that referenced this pull request Oct 3, 2025
…stack#3627)

This is a sweeping change to clean up some gunk around our "Tool"
definitions.

First, we had two types `Tool` and `ToolDef`. The first of these was a
"Resource" type for the registry but we had stopped registering tools
inside the Registry long back (and only registered ToolGroups.) The
latter was for specifying tools for the Agents API. This PR removes the
former and adds an optional `toolgroup_id` field to the latter.

Secondly, as pointed out by @bbrowning in
llamastack#3003 (comment),
we were doing a lossy conversion from a full JSON schema from the MCP
tool specification into our ToolDefinition to send it to the model.
There is no necessity to do this -- we ourselves aren't doing any
execution at all but merely passing it to the chat completions API which
supports this. By doing this (and by doing it poorly), we encountered
limitations like not supporting array items, or not resolving $refs,
etc.

To fix this, we replaced the `parameters` field by `{ input_schema,
output_schema }` which can be full blown JSON schemas.

Finally, there were some types in our llama-related chat format
conversion which needed some cleanup. We are taking this opportunity to
clean those up.

This PR is a substantial breaking change to the API. However, given our
window for introducing breaking changes, this suits us just fine. I will
be landing a concurrent `llama-stack-client` change as well since API
shapes are changing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants