Skip to content

Commit c72fca0

Browse files
author
Your Name
committed
More hashline efficiency changes, closer to diff performance for most models
1 parent aa3be1c commit c72fca0

14 files changed

Lines changed: 664 additions & 624 deletions

File tree

cecli/coders/agent_coder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,10 @@ def _generate_tool_context(self, repetitive_tools):
993993
self.model_kwargs["frequency_penalty"] = min(freq_penalty + 0.1, 1)
994994

995995
if random.random() < 0.25:
996-
self.model_kwargs["temperature"] = max(temperature - 0.2, 1)
997-
self.model_kwargs["frequency_penalty"] = max(freq_penalty - 0.2, 0)
996+
self.model_kwargs["temperature"] = min(
997+
(self.main_model.use_temperature or 1), max(temperature - 0.15, 1)
998+
)
999+
self.model_kwargs["frequency_penalty"] = min(0, max(freq_penalty - 0.15, 0))
9981000

9991001
# One tenth of the time, just straight reset the randomness
10001002
if random.random() < 0.1:

cecli/coders/hashline_coder.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def apply_edits(self, edits, dry_run=False):
6565
start_hash, end_hash, operation = original
6666

6767
# Validate operation
68-
if operation in ["replace", "insert", "delete"]:
68+
if operation in ["replace", "insert", "delete", "cancel"]:
6969
# Validate hashline format
7070
if isinstance(start_hash, str) and (
7171
operation == "insert" or isinstance(end_hash, str)
@@ -225,7 +225,7 @@ def apply_edits(self, edits, dry_run=False):
225225
res += (
226226
"The LOCATE section must be a valid JSON array in the format:\n"
227227
'["{start hashline}", "{end hashline}", "{operation}"]\n'
228-
"Hashline prefixes must have the structure `{line_num}{hash_fragment}` (e.g., `20Bv`)"
228+
"Hashline prefixes must have the structure `{4 char hash}` (e.g., `20Bv`)"
229229
" and match one found directly in the file"
230230
)
231231
if passed:
@@ -650,14 +650,15 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE, valid_fnames=None)
650650
# Check if original_text is a hashline JSON block
651651
try:
652652
# Try to parse as JSON
653-
parsed = json.loads(original_text_str.strip())
653+
# parsed = json.loads(original_text_str.strip())
654+
parsed = extract_base64url_parts(original_text_str.strip())
654655
# Check if it's a list with 3 elements (start_hash, end_hash, operation)
655656
if isinstance(parsed, list) and len(parsed) == 3:
656657
# Validate the format: all strings
657658
if all(isinstance(item, str) for item in parsed):
658659
# Check if first two items look like hashline format (e.g., "1ab")
659660

660-
if parsed[2] in ["replace", "insert", "delete"]:
661+
if parsed[2] in ["replace", "insert", "delete", "cancel"]:
661662
# This is a hashline JSON block
662663
yield filename, parsed, updated_text_str
663664
continue
@@ -675,6 +676,17 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE, valid_fnames=None)
675676
i += 1
676677

677678

679+
def extract_base64url_parts(input_string):
680+
# Remove any character that is NOT a-z, A-Z, 0-9, -, or _
681+
clean_str = re.sub(r"[^a-zA-Z0-9\-_]", "", input_string)
682+
683+
return [
684+
clean_str[:4], # First 4 chars
685+
clean_str[4:8], # Second 4 chars
686+
clean_str[8:], # The rest
687+
]
688+
689+
678690
def find_filename(lines, fence, valid_fnames):
679691
"""
680692
Deepseek Coder v2 has been doing this:

cecli/helpers/conversation/files.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ def update_file_diff(cls, fname: str) -> Optional[str]:
242242
# Add diff message to conversation
243243
diff_message = {
244244
"role": "user",
245-
"content": f"File Diff For:\n{rel_fname}\n\n{diff}",
245+
"content": (
246+
f"{rel_fname} has been updated. Here is a diff of the changes:\n\n{diff}"
247+
),
246248
}
247249

248250
ConversationManager.add_message(

cecli/helpers/conversation/integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,14 @@ def add_file_context_messages(cls, coder) -> None:
646646
message_dict=user_msg,
647647
tag=MessageTag.FILE_CONTEXTS,
648648
hash_key=("file_context_user", file_path),
649+
force=True,
649650
)
650651

651652
ConversationManager.add_message(
652653
message_dict=assistant_msg,
653654
tag=MessageTag.FILE_CONTEXTS,
654655
hash_key=("file_context_assistant", file_path),
656+
force=True,
655657
)
656658

657659
@classmethod

0 commit comments

Comments
 (0)