Problem (one or two sentences)
Sometimes apply_diff starts refusing to work even though the content matches 100%
Context (who is affected and when)
Happens after a while when the model's context fills up. I'd suspect attention issues but the code fragments in the error message fully match.
Reproduction steps
Just running the usual editing loop. Here's the message:
<error_details>
No sufficiently similar match found (92% similar, needs 100%)
Debug Info:
- Similarity Score: 92%
- Required Threshold: 100%
- Search Range: start to end
- Tried both standard and aggressive line number stripping
- Tip: Use the read_file tool to get the latest content of the file before attempting to use the apply_diff tool again, as the file content may have changed
Search Content:
:start_line=18
-------
// MatrixConfig holds Matrix connection settings.
type MatrixConfig struct {
HomeserverURL string `yaml:"homeserver_url"`
AccessToken string `yaml:"access_token"`
UserID string `yaml:"user_id"`
BotDisplayName string `yaml:"bot_display_name"`
Rooms []string `yaml:"rooms"`
}
Best Match Found:
16 | }
17 |
18 | // MatrixConfig holds Matrix connection settings.
19 | type MatrixConfig struct {
20 | HomeserverURL string `yaml:"homeserver_url"`
21 | AccessToken string `yaml:"access_token"`
22 | UserID string `yaml:"user_id"`
23 | BotDisplayName string `yaml:"bot_display_name"`
24 | Rooms []string `yaml:"rooms"`
25 | }
Original Content:
1 | package config
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "gopkg.in/yaml.v3"
8 | )
9 |
10 | // Config holds all configuration for the bot.
11 | type Config struct {
12 | Matrix MatrixConfig `yaml:"matrix"`
13 | LLM LLMConfig `yaml:"llm"`
14 | Personality PersonalityConfig `yaml:"personality"`
15 | Context ContextConfig `yaml:"context"`
16 | }
17 |
18 | // MatrixConfig holds Matrix connection settings.
19 | type MatrixConfig struct {
20 | HomeserverURL string `yaml:"homeserver_url"`
21 | AccessToken string `yaml:"access_token"`
22 | UserID string `yaml:"user_id"`
23 | BotDisplayName string `yaml:"bot_display_name"`
24 | Rooms []string `yaml:"rooms"`
25 | }
26 |
27 | // LLMConfig holds LLM API settings.
28 | type LLMConfig struct {
29 | APIKey string `yaml:"api_key"`
30 | BaseURL string `yaml:"base_url"` // Optional custom base URL
31 | Model string `yaml:"model"`
32 | MaxTokens int `yaml:"max_tokens"`
33 | Temperature float64 `yaml:"temperature"`
34 | }
35 |
36 | // PersonalityConfig holds bot personality settings.
37 | type PersonalityConfig struct {
38 | Name string `yaml:"name"`
39 | Description string `yaml:"description"`
40 | Traits []string `yaml:"traits"`
41 | Tone string `yaml:"tone"`
42 | LanguagePref string `yaml:"language_preference"`
43 | }
44 |
45 | // ContextConfig holds chat context settings.
46 | type ContextConfig struct {
47 | MaxHistoryMessages int `yaml:"max_history_messages"`
48 | MaxContextTokens int `yaml:"max_context_tokens"`
49 | }
</error_details>
And another one:
<error_details>
No sufficiently similar match found (83% similar, needs 100%)
Debug Info:
- Similarity Score: 83%
- Required Threshold: 100%
- Search Range: start to end
- Tried both standard and aggressive line number stripping
- Tip: Use the read_file tool to get the latest content of the file before attempting to use the apply_diff tool again, as the file content may have changed
Search Content:
:start_line=195
-------
// Check for /reset command
if strings.HasPrefix(body, "/reset") {
if evt.Sender.String() == cfg.Matrix.UserID {
Best Match Found:
193 | }
194 |
195 | // Check for /reset command
196 | if strings.HasPrefix(body, "/reset") {
197 | if evt.Sender.String() == cfg.Matrix.UserID {
Expected result
apply_diff works
Actual result
apply_diff complains about insufficient match
Variations tried (optional)
I would suspect tab/spaces mix up as in Go indentation is strictly tab-based. So I copied the code fragments from the error message to two text files, carefully removed the line numbers with an extra space after the pipe symbol, and then calculated sha256sum on both. It matched.
Another idea is there might be some kind of wrong escaping being applied internally. For example, another time the model couldn't produce an HTML escaping function with simple string replacement because it looked like strings.ReplaceAll("&", "&") instead of strings.ReplaceAll("&", "&"). It really tried hard and even sed command failed, though in finish_task report the replacement was reported correctly. Eventually it managed to implement it as "&"+"amp;". This issue is (probably) NOT directly related to the main apply_diff issue but it looked weird enough to also mention here because the model also struggled with editing where it shouldn't have.
App Version
Version: 3.53.0 (44f6bba)
API Provider (optional)
OpenAI Compatible
Model Used (optional)
Qwen3.6 35B A3B APEX
Roo Code Task Links (optional)
No response
Relevant logs or errors (optional)
Problem (one or two sentences)
Sometimes apply_diff starts refusing to work even though the content matches 100%
Context (who is affected and when)
Happens after a while when the model's context fills up. I'd suspect attention issues but the code fragments in the error message fully match.
Reproduction steps
Just running the usual editing loop. Here's the message:
And another one:
Expected result
apply_diff works
Actual result
apply_diff complains about insufficient match
Variations tried (optional)
I would suspect tab/spaces mix up as in Go indentation is strictly tab-based. So I copied the code fragments from the error message to two text files, carefully removed the line numbers with an extra space after the pipe symbol, and then calculated sha256sum on both. It matched.
Another idea is there might be some kind of wrong escaping being applied internally. For example, another time the model couldn't produce an HTML escaping function with simple string replacement because it looked like
strings.ReplaceAll("&", "&")instead ofstrings.ReplaceAll("&", "&"). It really tried hard and evensedcommand failed, though infinish_taskreport the replacement was reported correctly. Eventually it managed to implement it as"&"+"amp;". This issue is (probably) NOT directly related to the mainapply_diffissue but it looked weird enough to also mention here because the model also struggled with editing where it shouldn't have.App Version
Version: 3.53.0 (44f6bba)
API Provider (optional)
OpenAI Compatible
Model Used (optional)
Qwen3.6 35B A3B APEX
Roo Code Task Links (optional)
No response
Relevant logs or errors (optional)