NVIDIA-NeMo / NVIDIA-NeMo/Guardrails

feature: Tool call validation for v1/chat/completions requests

Open
#2,268 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement status: needs triage
Dominant language
Python
Stars
7.2k
Forks
842
Avg merge
3d 1h
Merged PRs (30d)
25

Description

Did you check the docs?
  • I have read all the NeMo-Guardrails docs
Is your feature request related to a problem? Please describe.

While the tool_choice and tools params exist in the GuardrailsChatCompletionRequest schema, their behaviour is not perfectly aligned with the OpenAI Chat Completions API. Broadly speaking, there is no currently no validation of the tool_choice param in GuardrailsChatCompletionRequest. In contrast, OpenAI Chat Completion API checks the tool_choice argument in the incoming request with the list of tools. This ensures that all tool choices declared in chat completions requests are valid. In order to align tool-calling behaviour in GuardrailsChatCompletionRequest with OpenAI API Chat Completions API, initialization and run-time validation are necessary.

Describe the solution you'd like
  • Optional configuration of tools on config.yaml to define a list of tools the model can access i.e adding a new field, tools in LLMRails. This is meant to mimic OpenAI's Tool Search where we load all the available tools at server start time rather than having the user send tool definitions at runtime
  • Check if the requested tool_choice in a guardrails v1/chat/completions is available in the list of tools
  • Enrich the existing tools and tool_choice params. with missing subfields
Describe alternatives you've considered

n/a

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the GuardrailsChatCompletionRequest schema and the LLMRails configuration path, then trace handling for tools and tool_choice in v1/chat/completions. Confirm how config.yaml could define server-side tools, where initialization and run-time validation belong, and which missing subfields need to be represented. Done means invalid tool choices are rejected and valid configured tools align with the OpenAI Chat Completions behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.