Skip to content

fix: functions are missing from parse_schema's return#1263

Closed
xavierchanth wants to merge 2 commits intoCopilotC-Nvim:mainfrom
xavierchanth:patch-1
Closed

fix: functions are missing from parse_schema's return#1263
xavierchanth wants to merge 2 commits intoCopilotC-Nvim:mainfrom
xavierchanth:patch-1

Conversation

@xavierchanth
Copy link
Copy Markdown

I'll use the file function's schema as an example of the problem:

    schema = {
      type = 'object',
      required = { 'path' },
      properties = {
        path = {
          type = 'string',
          description = 'Path to file to include in chat context.',
          enum = function(source)
            local glob = utils.glob(source.cwd(), {
              max_count = 0,
            })
            return glob
          end,
        },
      },
    }

At the end of parse_schema, the schema is filtered. After this gets called, only type and description are in the returned schema, but enum should be in there too.

  if schema then
    schema = filter_schema(schema, true)
  end

  return schema

Prior to this, completing #file: in the picker would give me an input field to type my file path:

image

This change restores the behavior visible in the demo in the README where that file can be picked using vim.ui.select:

image

I'll use the `file` function's schema as an example of the problem:

```lua
    schema = {
      type = 'object',
      required = { 'path' },
      properties = {
        path = {
          type = 'string',
          description = 'Path to file to include in chat context.',
          enum = function(source)
            local glob = utils.glob(source.cwd(), {
              max_count = 0,
            })
            return glob
          end,
        },
      },
    }
```

At the end of `parse_schema`, the schema is filtered:

```lua
  if schema then
    schema = filter_schema(schema, true)
  end

  return schema
```

This change leaves functions as is in the results table.
Prior to this, completing `#file:` in the picker would give me an input field to type my file path. This restores the behavior visible in the demo in the README where that file can be picked using `vim.ui.select`.
deathbeam added a commit to deathbeam/CopilotChat.nvim that referenced this pull request Aug 3, 2025
It still need to be filtered when preparing tool use as we cant send json
functions to API.

Closes CopilotC-Nvim#1263

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
deathbeam added a commit that referenced this pull request Aug 3, 2025
It still need to be filtered when preparing tool use as we cant send json
functions to API.

Closes #1263

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
@deathbeam
Copy link
Copy Markdown
Collaborator

Good catch thanks. I fixed it myself because if I did this, the enum function would also be sent to the copilot API, and serializing functions as json is not pretty and it can break the API for some models, so the fix needed to be done only for when the input is being entered.

@xavierchanth
Copy link
Copy Markdown
Author

Good catch thanks. I fixed it myself because if I did this, the enum function would also be sent to the copilot API, and serializing functions as json is not pretty and it can break the API for some models, so the fix needed to be done only for when the input is being entered.

Np, I had a feeling what I did wasn’t correct, but at least raising the PR identifies the issue. Thanks for the quick response!

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.

2 participants