Skip to content

edit_existing_file may need an improved description to help GLM-4.6 use it correctly all the time #8189

@ianbmacdonald

Description

@ianbmacdonald

Before submitting your bug report

Relevant environment info

- OS: Ubuntu 25.04
- Continue version: 1.3.17
- IDE version: vscode 1.105.0
- Model: GLM-4.6 BF16
- config:
  
name: GLM 4.6
version: 1.0.0
schema: v1
models:
  - name: GLM 4.6 BF16
    provider: openai
    apiBase: http://localhost:8000/v1
    model: zai-org/GLM-4.6
    defaultCompletionOptions:
      contextLength: 202752
    capabilities:
      - tool_use
    roles:
      - apply
      - chat
      - edit
      - embed
  # GLM-4.6 without tool-use (Standard Chat Mode)
  - name: GLM-4.6 (No Tools)
    provider: openai
    apiBase: http://localhost:8000/v1
    model: zai-org/GLM-4.6
    roles:
      - apply
      - chat
      - edit
      - embed
    defaultCompletionOptions:
      temperature: 0.7
context:
  - provider: code
  - provider: docs
  - provider: diff
  - provider: terminal
  - provider: file
  - provider: currentFile
  - provider: open
    params:
      onlyPinned: true

mcpServers:
  # Google Search MCP (stdio)
  - name: google-search
    transport:
      type: stdio
    command: node
    args:
      - "/home/imac/src/Google-Search-MCP-Server/dist/google-search.js"
    env:
      GOOGLE_API_KEY: "XXXXXXX8MWKoRiNHomUfE"
      GOOGLE_SEARCH_ENGINE_ID: "XXXXXXX7c4c2c"


  - name: playwright
    command: npx
    args:
      - "@playwright/mcp@latest"
      - "--browser"
      - "chromium"
      #- "--no-sandbox"
      #- "--headless"

In agent mode with tools, when GLM-4.6 decides to read very specific lines of a file using read_file_range, and proposes edits, it uses the edit_existing_file function, which attempts to wipe the entire file. When I point that out, it then iterates through single_find_and_replace to get the job done.

I think this might be is an issue with how the built in edit_existing_file function is described.

The tool description says "If you don't know the contents of the file, read it first." -> Well GLM-4.6 is using the read_file_range which smartly can reduce overall context when used properly.

Then for changes, the description says "Any modifications to the file, showing only needed changes. Do NOT wrap this in a codeblock or write anything besides the code changes. In larger files, use brief language-appropriate placeholders for large unmodified sections, e.g. '// ... existing code ...'" -> Well GLM-4.6 only read a specific line set, and so it passes that back in full, edited, with no need for ...existing code ... because there was no additional code in the read_file_range.

At a glance, it looks like GLM-4.6 is following instructions, but they need to be modified to account for the use of read_file_range rather than considering only the scenario where the entire file was just read.

I think the correct workaround is to add a via uses: in config.yaml, though right now I added a system messages section to the bottom of .continue/rules to see if that makes a difference. (it hasn't)

This model is new ground for me, so hopefully not completely off track here.

Description

Image

To reproduce

No response

Log output

Metadata

Metadata

Labels

area:editRelates to side panel Edit featureide:vscodeRelates specifically to VS Code extensionkind:enhancementIndicates a new feature request, imrovement, or extensionos:linuxHappening specifically on Linux

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions