tao-shen Claude Opus 4.6 commited on
Commit
20ccd66
ยท
1 Parent(s): 8982430

fix: expand emoji action parser to handle ๐Ÿ› ๏ธ in addition to ๐Ÿ”ง

Browse files
Files changed (1) hide show
  1. scripts/conversation-loop.py +6 -4
scripts/conversation-loop.py CHANGED
@@ -404,8 +404,10 @@ def parse_and_execute_actions(raw_text):
404
  executed = set() # Deduplicate
405
 
406
  # 1. Handle write_file with [CONTENT]...[/CONTENT] block
 
 
407
  write_match = re.search(
408
- r'\[ACTION:\s*write_file\s*:\s*(\w+)\s*:\s*([^\]]+)\]\s*\[CONTENT\](.*?)\[/CONTENT\]',
409
  raw_text, re.DOTALL
410
  )
411
  if write_match:
@@ -494,9 +496,9 @@ def parse_and_execute_actions(raw_text):
494
  results.append({"action": action_str, "result": result})
495
  print(f"[ACTION] {action_str} โ†’ {result[:120]}")
496
 
497
- # 3. Fallback: parse ๐Ÿ”งaction:arg1:arg2 emoji format (LLM sometimes uses this)
498
  if not results:
499
- for match in re.finditer(r'๐Ÿ”ง\s*(\w+(?::\S+)*)', raw_text):
500
  action_str = match.group(1).strip()
501
  if action_str in executed:
502
  continue
@@ -558,7 +560,7 @@ def parse_and_execute_actions(raw_text):
558
  # Clean the text: remove action tags, content blocks, and emoji actions
559
  clean = re.sub(r'\[ACTION:[^\]]*\]', '', raw_text)
560
  clean = re.sub(r'\[CONTENT\].*?\[/CONTENT\]', '', clean, flags=re.DOTALL)
561
- clean = re.sub(r'๐Ÿ”ง\s*\w+(?::\S+)*', '', clean)
562
  clean = clean.strip()
563
 
564
  return clean, results
 
404
  executed = set() # Deduplicate
405
 
406
  # 1. Handle write_file with [CONTENT]...[/CONTENT] block
407
+ # Tolerates: [ACTION: write_file:...], [write_file:...], missing ACTION: prefix,
408
+ # and [/CONTENT] with whitespace/newline before closing bracket
409
  write_match = re.search(
410
+ r'\[(?:ACTION:\s*)?write_file\s*:\s*(\w+)\s*:\s*([^\]]+)\]\s*\[CONTENT\](.*?)\[/\s*CONTENT\s*\]',
411
  raw_text, re.DOTALL
412
  )
413
  if write_match:
 
496
  results.append({"action": action_str, "result": result})
497
  print(f"[ACTION] {action_str} โ†’ {result[:120]}")
498
 
499
+ # 3. Fallback: parse emoji action format (๐Ÿ”ง ๐Ÿ› ๏ธ etc.) โ€” LLM sometimes uses this
500
  if not results:
501
+ for match in re.finditer(r'[๐Ÿ”ง๐Ÿ› ๏ธ]\ufe0f?\s*(\w+(?::\S+)*)', raw_text):
502
  action_str = match.group(1).strip()
503
  if action_str in executed:
504
  continue
 
560
  # Clean the text: remove action tags, content blocks, and emoji actions
561
  clean = re.sub(r'\[ACTION:[^\]]*\]', '', raw_text)
562
  clean = re.sub(r'\[CONTENT\].*?\[/CONTENT\]', '', clean, flags=re.DOTALL)
563
+ clean = re.sub(r'[๐Ÿ”ง๐Ÿ› ๏ธ]\ufe0f?\s*\w+(?::\S+)*', '', clean)
564
  clean = clean.strip()
565
 
566
  return clean, results