Charles Grandjean commited on
Commit
56aa261
Β·
1 Parent(s): de9078a

more logs

Browse files
subagents/doc_editor.py CHANGED
@@ -322,6 +322,23 @@ class DocumentEditorAgent:
322
  logger.info(f"πŸ“ˆ Size change: {size_change:+d} bytes ({size_change/len(doc_text)*100:+.1f}%)")
323
  logger.info(f"πŸ’¬ Message: {message[:100]}{'...' if len(message) > 100 else ''}")
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  if not success:
326
  max_iters = final_state.get("max_iterations", 10)
327
  if iteration_count >= max_iters:
 
322
  logger.info(f"πŸ“ˆ Size change: {size_change:+d} bytes ({size_change/len(doc_text)*100:+.1f}%)")
323
  logger.info(f"πŸ’¬ Message: {message[:100]}{'...' if len(message) > 100 else ''}")
324
 
325
+ # Log final document content
326
+ logger.info("=" * 80)
327
+ logger.info("πŸ“„ FINAL DOCUMENT CONTENT")
328
+ logger.info("=" * 80)
329
+ if final_doc_size <= 1000:
330
+ # Log full document if small enough
331
+ logger.info(final_state["doc_text"])
332
+ else:
333
+ # Log first 500 and last 500 characters for readability
334
+ doc_content = final_state["doc_text"]
335
+ logger.info(f"[BEGINNING - first 500 chars]")
336
+ logger.info(doc_content[:500])
337
+ logger.info(f"...")
338
+ logger.info(f"[ENDING - last 500 chars]")
339
+ logger.info(doc_content[-500:])
340
+ logger.info("=" * 80)
341
+
342
  if not success:
343
  max_iters = final_state.get("max_iterations", 10)
344
  if iteration_count >= max_iters:
utils/doc_editor_tools.py CHANGED
@@ -87,10 +87,11 @@ async def replace_html(doc_text: str, search: str, replace: str, expected_matche
87
  logger.info(f" πŸ”’ Actual matches found: {m}")
88
 
89
  if m != expected_matches:
90
- logger.warning(f" ⚠️ Match count mismatch: found {m}, expected {expected_matches}")
 
91
  return {
92
  "ok": False,
93
- "error": f"Match count mismatch: found {m} occurrences, expected {expected_matches}",
94
  "matches": m
95
  }
96
 
@@ -164,10 +165,15 @@ async def add_html(doc_text: str, anchor_search: str, insert: str,
164
  logger.info(f" πŸ”’ Actual anchor matches found: {m}")
165
 
166
  if m != expected_matches:
167
- logger.warning(f" ⚠️ Anchor match count mismatch: found {m}, expected {expected_matches}")
 
 
 
 
 
168
  return {
169
  "ok": False,
170
- "error": f"Anchor match count mismatch: found {m} occurrences, expected {expected_matches}",
171
  "matches": m
172
  }
173
 
 
87
  logger.info(f" πŸ”’ Actual matches found: {m}")
88
 
89
  if m != expected_matches:
90
+ error_msg = f"Search pattern not found in document. Searched for: '{search[:100]}{'...' if len(search) > 100 else ''}'. Found {m} occurrences, expected {expected_matches}. The HTML must match exactly (including whitespace and attributes). Please examine the document content and try again with a different search pattern that exists in the document."
91
+ logger.warning(f" ⚠️ {error_msg}")
92
  return {
93
  "ok": False,
94
+ "error": error_msg,
95
  "matches": m
96
  }
97
 
 
165
  logger.info(f" πŸ”’ Actual anchor matches found: {m}")
166
 
167
  if m != expected_matches:
168
+ error_msg = f"Anchor not found in document. Searched for: '{anchor_search[:100]}{'...' if len(anchor_search) > 100 else ''}'. Found {m} occurrences, expected {expected_matches}. The anchor HTML must match exactly (including whitespace and attributes). Please examine the document content and try again with a different anchor that exists in the document."
169
+ logger.error(f" ❌ ANCHOR NOT FOUND!")
170
+ logger.error(f" πŸ” Searched for anchor ({len(anchor_search)} chars):")
171
+ logger.error(f" {anchor_search[:200]}{'...' if len(anchor_search) > 200 else ''}")
172
+ logger.error(f" πŸ”’ Found {m} occurrence(s), expected {expected_matches}")
173
+ logger.error(f" πŸ’‘ LLM has been notified and will retry with a different anchor")
174
  return {
175
  "ok": False,
176
+ "error": error_msg,
177
  "matches": m
178
  }
179