Skip to content

BYOK editTools config has no effect — never reaches endpoint.supportedEditTools #301052

@rwoll

Description

@rwoll

Bug

The editTools field in BYOK model configuration (e.g., editTools: ['apply-patch']) is accepted by the schema but has no effect on which edit tools are exposed to the model.

Root Cause

The plumbing between BYOKModelCapabilities.editTools and IChatEndpoint.supportedEditTools is broken:

  1. BYOKModelCapabilities (in vscode-copilot-chat: src/extension/byok/common/byokProvider.ts) defines editTools?: EndpointEditToolName[]
  2. resolveModelInfo() (same file) converts capabilities to IChatModelInformation but drops editTools — it's not mapped to any field
  3. ExtensionContributedChatEndpoint (in vscode-copilot-chat: src/platform/endpoint/vscode-node/extChatEndpoint.ts) reads edit tools from languageModel.capabilities.editToolsHint — a VS Code API capability
  4. EditToolLearningService.getPreferredEndpointEditTool() checks endpoint.supportedEditTools first, but it's always empty for BYOK models, so it falls through to hardcoded name matching or the learning state machine

Expected Behavior

Setting editTools: ['apply-patch'] in a BYOK model config should cause the model to use applyPatch instead of the default replace_string_in_file.

Actual Behavior

editTools is silently ignored. The edit tool is determined by:

  1. Hardcoded model name matching (_getHardcodedPreferences — names containing 'gpt'/'openai' → applyPatch, 'sonnet' → replaceString)
  2. The learning state machine (defaults to replaceString for unknown models)

Suggested Fix

Either:

  • Map BYOKModelCapabilities.editTools through to languageModel.capabilities.editToolsHint during BYOK model registration so ExtensionContributedChatEndpoint picks it up
  • Or have resolveModelInfo() include editTools in a field that EditToolLearningService can read from the endpoint

Reproduction

customModels:
  customoai:
    my-model:
      name: 'My Model'
      url: 'http://localhost:3234/v1/responses'
      toolCalling: true
      vision: false
      maxInputTokens: 200000
      maxOutputTokens: 32768
      requiresAPIKey: true
      editTools: ['apply-patch']  # <-- this has no effect

The model will still get replace_string_in_file / insert_edit_into_file instead of applyPatch.

Workaround

Name the model to include 'gpt' or 'openai' to trigger the hardcoded preference in _getHardcodedPreferences().

References (in microsoft/vscode-copilot-chat)

  • src/extension/byok/common/byokProvider.tsBYOKModelCapabilities.editTools and resolveModelInfo()
  • src/platform/endpoint/vscode-node/extChatEndpoint.tssupportedEditTools from editToolsHint
  • src/extension/tools/common/editToolLearningService.tsgetPreferredEndpointEditTool() and _getHardcodedPreferences()

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions