alpiecode 10.10.3__tar.gz → 10.10.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {alpiecode-10.10.3 → alpiecode-10.10.4}/PKG-INFO +1 -1
  2. {alpiecode-10.10.3 → alpiecode-10.10.4}/pyproject.toml +1 -1
  3. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/PKG-INFO +1 -1
  4. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/SOURCES.txt +2 -0
  5. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/__init__.py +1 -1
  6. alpiecode-10.10.4/src/codeagent/convergence.py +32 -0
  7. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/media.py +9 -1
  8. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/orchestrator.py +164 -15
  9. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/prompt.py +7 -0
  10. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/system1.py +10 -2
  11. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/tools.py +18 -2
  12. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_deloop_and_sessions.py +74 -0
  13. alpiecode-10.10.4/test/test_report_convergence.py +158 -0
  14. {alpiecode-10.10.3 → alpiecode-10.10.4}/README.md +0 -0
  15. {alpiecode-10.10.3 → alpiecode-10.10.4}/setup.cfg +0 -0
  16. {alpiecode-10.10.3 → alpiecode-10.10.4}/setup.py +0 -0
  17. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode/__init__.py +0 -0
  18. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/dependency_links.txt +0 -0
  19. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/entry_points.txt +0 -0
  20. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/requires.txt +0 -0
  21. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/alpiecode.egg-info/top_level.txt +0 -0
  22. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/__main__.py +0 -0
  23. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/agent.py +0 -0
  24. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/assessment.py +0 -0
  25. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/backends/__init__.py +0 -0
  26. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/backends/base.py +0 -0
  27. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/backends/local_backend.py +0 -0
  28. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/backends/openai_backend.py +0 -0
  29. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/blueprints.py +0 -0
  30. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/cache.py +0 -0
  31. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/chat_tags.py +0 -0
  32. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/cli.py +0 -0
  33. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/client.py +0 -0
  34. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/compaction.py +0 -0
  35. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/config.py +0 -0
  36. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/context.py +0 -0
  37. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/diff_preview.py +0 -0
  38. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/discovery.py +0 -0
  39. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/doctor.py +0 -0
  40. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/dream_rsi.py +0 -0
  41. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/executor.py +0 -0
  42. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/git_ops.py +0 -0
  43. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/github.py +0 -0
  44. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/guardian.py +0 -0
  45. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/guardrails.py +0 -0
  46. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/ipython_ext.py +0 -0
  47. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/local_model.py +0 -0
  48. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/memory.py +0 -0
  49. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/metrics.py +0 -0
  50. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/onboarding.py +0 -0
  51. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/paths.py +0 -0
  52. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/progress.py +0 -0
  53. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/project_template.py +0 -0
  54. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/rephraser.py +0 -0
  55. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/server.py +0 -0
  56. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/session.py +0 -0
  57. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/accessibility-audit/SKILL.md +0 -0
  58. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/accessibility-testing/SKILL.md +0 -0
  59. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/accessibility-ui-components/SKILL.md +0 -0
  60. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/agentic-workflows/SKILL.md +0 -0
  61. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/api-design/SKILL.md +0 -0
  62. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/architecture-design/SKILL.md +0 -0
  63. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/backend-engineering/SKILL.md +0 -0
  64. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/browser-automation/SKILL.md +0 -0
  65. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/cli-development/SKILL.md +0 -0
  66. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/cloud-infrastructure/SKILL.md +0 -0
  67. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/code-generation/SKILL.md +0 -0
  68. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/code-review/SKILL.md +0 -0
  69. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/codebase-onboarding/SKILL.md +0 -0
  70. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/cost-optimization/SKILL.md +0 -0
  71. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/data-analysis/SKILL.md +0 -0
  72. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/data-engineering/SKILL.md +0 -0
  73. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/database-engineering/SKILL.md +0 -0
  74. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/dependency-management/SKILL.md +0 -0
  75. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/dependency-security/SKILL.md +0 -0
  76. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/dependency-upgrades/SKILL.md +0 -0
  77. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/devops-ci-cd/SKILL.md +0 -0
  78. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/docker-containers/SKILL.md +0 -0
  79. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/documentation/SKILL.md +0 -0
  80. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/documentation-site/SKILL.md +0 -0
  81. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/e2e-testing/SKILL.md +0 -0
  82. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/error-handling-resilience/SKILL.md +0 -0
  83. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/feature-development/SKILL.md +0 -0
  84. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/frontend-engineering/SKILL.md +0 -0
  85. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/git-workflow/SKILL.md +0 -0
  86. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/incident-response/SKILL.md +0 -0
  87. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/legacy-code-modernization/SKILL.md +0 -0
  88. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/llm-application-engineering/SKILL.md +0 -0
  89. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/localization-i18n/SKILL.md +0 -0
  90. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/mcp-server-development/SKILL.md +0 -0
  91. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/migration-engineering/SKILL.md +0 -0
  92. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/mobile-development/SKILL.md +0 -0
  93. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/model-evaluation/SKILL.md +0 -0
  94. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/nodejs-services/SKILL.md +0 -0
  95. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/observability/SKILL.md +0 -0
  96. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/performance-optimization/SKILL.md +0 -0
  97. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/privacy-data-protection/SKILL.md +0 -0
  98. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/prompt-engineering/SKILL.md +0 -0
  99. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/python-engineering/SKILL.md +0 -0
  100. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/rag-retrieval/SKILL.md +0 -0
  101. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/react-engineering/SKILL.md +0 -0
  102. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/release-management/SKILL.md +0 -0
  103. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/requirements-analysis/SKILL.md +0 -0
  104. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/responsive-design/SKILL.md +0 -0
  105. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/safe-refactoring/SKILL.md +0 -0
  106. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/secure-coding/SKILL.md +0 -0
  107. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/systematic-debugging/SKILL.md +0 -0
  108. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/technical-planning/SKILL.md +0 -0
  109. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/technical-research/SKILL.md +0 -0
  110. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/technical-writing/SKILL.md +0 -0
  111. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/test-engineering/SKILL.md +0 -0
  112. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/tool-integration/SKILL.md +0 -0
  113. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/typescript-engineering/SKILL.md +0 -0
  114. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/visual-regression-testing/SKILL.md +0 -0
  115. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/web-performance/SKILL.md +0 -0
  116. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/web-security-testing/SKILL.md +0 -0
  117. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills/workflow-automation/SKILL.md +0 -0
  118. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/skills.py +0 -0
  119. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/slash.py +0 -0
  120. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/subagent.py +0 -0
  121. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/updater.py +0 -0
  122. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/verifier.py +0 -0
  123. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/vscode_installer.py +0 -0
  124. {alpiecode-10.10.3 → alpiecode-10.10.4}/src/codeagent/walkthrough.py +0 -0
  125. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_adaptive_resilience.py +0 -0
  126. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_chat_tags_and_offline_multimodal.py +0 -0
  127. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_cli_ui.py +0 -0
  128. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_context_and_trajectory.py +0 -0
  129. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_dream_rsi.py +0 -0
  130. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_frontier_architecture.py +0 -0
  131. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_gpu_detection.py +0 -0
  132. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_lifecycle_and_portfolio.py +0 -0
  133. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_local_model_download.py +0 -0
  134. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_memory_optimization.py +0 -0
  135. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_non_thinking_and_local_stream.py +0 -0
  136. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_onboarding.py +0 -0
  137. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_project_templates.py +0 -0
  138. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_security_config.py +0 -0
  139. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_skills_engine.py +0 -0
  140. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_slash_and_diff.py +0 -0
  141. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_subagents.py +0 -0
  142. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_task_assessment.py +0 -0
  143. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_token_economy_and_256k.py +0 -0
  144. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_truncation_resilience.py +0 -0
  145. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_verifier.py +0 -0
  146. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_walkthrough.py +0 -0
  147. {alpiecode-10.10.3 → alpiecode-10.10.4}/test/test_web_resilience_and_guardrails.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.10.3
3
+ Version: 10.10.4
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alpiecode"
7
- version = "10.10.3"
7
+ version = "10.10.4"
8
8
  description = "AlpieCode"
9
9
  requires-python = ">=3.9"
10
10
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.10.3
3
+ Version: 10.10.4
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -20,6 +20,7 @@ src/codeagent/client.py
20
20
  src/codeagent/compaction.py
21
21
  src/codeagent/config.py
22
22
  src/codeagent/context.py
23
+ src/codeagent/convergence.py
23
24
  src/codeagent/diff_preview.py
24
25
  src/codeagent/discovery.py
25
26
  src/codeagent/doctor.py
@@ -131,6 +132,7 @@ test/test_memory_optimization.py
131
132
  test/test_non_thinking_and_local_stream.py
132
133
  test/test_onboarding.py
133
134
  test/test_project_templates.py
135
+ test/test_report_convergence.py
134
136
  test/test_security_config.py
135
137
  test/test_skills_engine.py
136
138
  test/test_slash_and_diff.py
@@ -17,7 +17,7 @@ Supports:
17
17
  from pathlib import Path
18
18
  from typing import Optional, Any, Dict
19
19
 
20
- __version__ = "10.10.3"
20
+ __version__ = "10.10.4"
21
21
 
22
22
  def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
23
23
  """Run an autonomous coding task programmatically."""
@@ -0,0 +1,32 @@
1
+ """Task-local limits for retries that do not change the observed outcome."""
2
+
3
+ import hashlib
4
+ import json
5
+ from typing import Any, Dict, Optional
6
+
7
+
8
+ class ConvergenceGuard:
9
+ def __init__(self) -> None:
10
+ self._failures: Dict[str, tuple] = {}
11
+ self._writes: Dict[str, str] = {}
12
+
13
+ def observe(self, name: str, args: Dict[str, Any], output: str,
14
+ failed: bool) -> Optional[str]:
15
+ target = str(args.get("path") or args.get("file") or args.get("filepath")
16
+ or args.get("filename") or args.get("command") or "")
17
+ key = json.dumps([name, target])
18
+ if failed:
19
+ # Ignore changing generated content: the same rejection is no progress.
20
+ previous, count = self._failures.get(key, (None, 0))
21
+ count = count + 1 if previous == output else 1
22
+ self._failures[key] = (output, count)
23
+ if count >= 2:
24
+ return f"Stopped after the same {name} error twice for {target or 'this action'}: {output[:500]}"
25
+ else:
26
+ self._failures.pop(key, None)
27
+ if name == "write_file" and not args.get("append"):
28
+ signature = hashlib.sha256(json.dumps(args, sort_keys=True).encode()).hexdigest()
29
+ if self._writes.get(key) == signature:
30
+ return f"Repeated identical write_file for {target}; preserve the existing file and summarize the result."
31
+ self._writes[key] = signature
32
+ return None
@@ -466,7 +466,12 @@ def build_media_content(
466
466
  try:
467
467
  frames = extract_frames(str(vid_file), max_frames=frames_per_vid)
468
468
  if frames:
469
- header = f"--- Video {idx}/{num_vids}: {vid_file.name} ({len(frames)} keyframes) ---"
469
+ header = (
470
+ f"--- Video {idx}/{num_vids}: {vid_file.name} ({len(frames)} keyframes) ---\n"
471
+ "Coverage: sampled still frames only; no audio or transcript was extracted. "
472
+ "Do not claim to have watched the entire video or heard the review. "
473
+ "Separate visible observations from unknown spoken claims."
474
+ )
470
475
  content.append({"type": "text", "text": header})
471
476
  for i, (mime, raw_bytes) in enumerate(frames):
472
477
  b64 = base64.b64encode(raw_bytes).decode("utf-8")
@@ -490,6 +495,9 @@ def build_media_content(
490
495
  console.print(f" ✅ Downloaded: {Path(downloaded).name}", style="green")
491
496
  console.print(f"🎬 Extracting frames...", style="cyan")
492
497
  frames = extract_frames(downloaded)
498
+ content.append({"type": "text", "text":
499
+ "Video coverage: sampled still frames only; no audio or transcript was extracted. "
500
+ "Do not claim full-video or spoken-review analysis."})
493
501
  for mime, raw_bytes in frames:
494
502
  b64 = base64.b64encode(raw_bytes).decode("utf-8")
495
503
  content.append({
@@ -21,11 +21,12 @@ from .config import Config, is_server_reachable, is_internet_available, is_local
21
21
  from .memory import extract_and_save_memories
22
22
  from .discovery import build_task_context, gather_relevant_context, COMPLEXITY_CONFIG
23
23
  from .progress import ProgressMonitor
24
+ from .convergence import ConvergenceGuard
24
25
  from .rephraser import PromptRephraser
25
26
  from .prompt import PromptBuilder, classify_task
26
27
  from .session import Session, SessionManager
27
28
  from .metrics import TaskMetrics
28
- from .system1 import get_system1_controller, ActionCategory
29
+ from .system1 import System1Controller, ActionCategory
29
30
  from .paths import is_ios
30
31
  from .dream_rsi import (
31
32
  TrajectoryRecord,
@@ -94,9 +95,18 @@ def _check_tool_results_had_error(results) -> bool:
94
95
  if not results:
95
96
  return False
96
97
  import json
97
- for res in results:
98
+
99
+ # Only a later successful mutation of the exact same path can recover an
100
+ # earlier file error. Basenames collide across directories and on case-sensitive FS.
101
+ succeeded_files = set()
102
+ for res in reversed(results):
98
103
  content = getattr(res, "content", "") or ""
99
104
  name = getattr(res, "name", "") or ""
105
+ if name in ("write_file", "edit_file", "append_file"):
106
+ match = re.match(r"^(?:wrote \d+ bytes to |edit applied to )([^\n]+)", content)
107
+ if match:
108
+ succeeded_files.add(str(Path(match.group(1))))
109
+ continue
100
110
 
101
111
  # 1. Bash execution exit code and stderr
102
112
  if name == "bash":
@@ -115,6 +125,11 @@ def _check_tool_results_had_error(results) -> bool:
115
125
  # 2. File tool or general error messages
116
126
  content_lower = content.lower()
117
127
  if content_lower.startswith("error:") or content_lower.startswith("error "):
128
+ err_files = set()
129
+ for ef in re.findall(r"['\"]([^'\"\n]+\.[a-zA-Z0-9]+)['\"]", content):
130
+ err_files.add(str(Path(ef)))
131
+ if name in ("write_file", "edit_file", "append_file") and err_files and err_files <= succeeded_files:
132
+ continue
118
133
  return True
119
134
  if "command blocked by safety gate" in content_lower:
120
135
  return True
@@ -195,8 +210,12 @@ class AgentOrchestrator:
195
210
  # ── Phase 0: Discovery — pre-compute task intelligence ──
196
211
  task_start_time = time.time()
197
212
  task_metrics = TaskMetrics(task_id=session.id).start()
198
- system1 = get_system1_controller()
199
- system1.reset()
213
+ system1 = System1Controller()
214
+ convergence = ConvergenceGuard()
215
+ # Recovery budgets belong to this request, not the persistent chat session.
216
+ for attr in ("_text_response_nudges", "_empty_response_retries", "_unmet_goal_nudges",
217
+ "_auto_verify_attempts", "_auto_verify_passed", "_last_verification_result"):
218
+ session.__dict__.pop(attr, None)
200
219
  task_context = build_task_context(task, session.workdir)
201
220
  complexity = complexity or task_context.complexity
202
221
  assessment = getattr(task_context, "assessment", None)
@@ -494,8 +513,9 @@ class AgentOrchestrator:
494
513
  f"[ARCHITECTURE DIRECTIVE: {bp.name.upper()}]\n"
495
514
  f"- Required Deliverables: {', '.join(bp.target_files)}\n"
496
515
  f"- Primary Entry Point: {bp.entry_point}\n"
497
- f"- TECHNICAL RESEARCH REPORT STANDARD:\n"
498
- f" * Create 'RESEARCH_REPORT.md' with: 1) Executive Summary; 2) Comparative Analysis Matrix Table; 3) Deep-Dive Technical Breakdown with code; 4) Actionable Production Recommendations.\n\n"
516
+ f"- RESEARCH REPORT STANDARD:\n"
517
+ f" * Create 'RESEARCH_REPORT.md' addressing the user's actual criteria, with a comparative table, evidence, trade-offs and practical recommendations. Include code only if the user requests software analysis.\n"
518
+ f" * Distinguish observed evidence, estimates and unknowns. State unavailable research or media coverage explicitly. Once the report is complete, return a final summary; do not keep rewriting it.\n\n"
499
519
  )
500
520
  else:
501
521
  bp_directive = (
@@ -561,14 +581,17 @@ class AgentOrchestrator:
561
581
  base_enable_thinking = task_context.enable_thinking
562
582
 
563
583
  task_metrics.record_context_prep((time.time() - ctx_prep_start) * 1000.0)
564
- # Extract explicitly named deliverable files from task prompt (e.g. auth.py, test_auth.py)
584
+ # Extract explicitly named deliverable files from task prompt (e.g. auth.py, test_auth.py, RESEARCH_REPORT.md)
565
585
  named_deliverables = list(dict.fromkeys(
566
- re.findall(r"\b([a-zA-Z0-9_\-]+\.(?:py|js|ts|html|css|json|toml|sh))\b", task)
586
+ re.findall(r"\b([a-zA-Z0-9_\-]+\.(?:py|js|ts|html|css|json|toml|sh|md|txt|csv|yaml|yml))\b", task)
567
587
  ))
588
+ if bp:
589
+ named_deliverables = list(dict.fromkeys(named_deliverables + list(bp.target_files)))
568
590
 
569
591
  progress_monitor = ProgressMonitor()
570
592
  turn = 0
571
593
  prior_turn_had_error = False
594
+ finalization_reason = None
572
595
  trajectory_finalized = False
573
596
 
574
597
  def _ensure_trajectory_saved(outcome_str: str) -> None:
@@ -590,7 +613,7 @@ class AgentOrchestrator:
590
613
  if session.cancelled:
591
614
  _ensure_trajectory_saved('cancelled')
592
615
  yield AgentEvent("cancelled", {"turn": turn})
593
- break
616
+ return
594
617
 
595
618
  # ── Active rolling compaction for historical tool outputs ──
596
619
  if hasattr(session.context, "rolling_compact_old_tools"):
@@ -670,17 +693,28 @@ class AgentOrchestrator:
670
693
  # Guide the model with workspace progress, DOM element contract, and light-mode theming
671
694
  if session_touched_files:
672
695
  file_list = ", ".join(sorted(list(session_touched_files)))
673
- if getattr(session, "_auto_verify_attempts", 0) > 0 or prior_turn_had_error:
696
+ verify_attempts = getattr(session, "_auto_verify_attempts", 0)
697
+ if verify_attempts > 0:
674
698
  last_failure = getattr(session, "_last_verification_result", None)
675
- err_msg = last_failure.message if last_failure else "Previous turn failed verification."
699
+ err_msg = last_failure.message if last_failure else "Previous verification check failed."
676
700
  sug_action = last_failure.suggested_action if last_failure else "Use edit_file or write_file."
677
701
  state_hint = (
678
702
  f"[Workspace State: Active verification error in touched files: {err_msg}. "
679
703
  f"Action required: {sug_action}. "
680
- f"You MUST use edit_file or write_file to apply the fix now. DO NOT declare DONE without tool execution.]"
704
+ f"You MUST use edit_file or write_file to apply the fix now.]"
705
+ )
706
+ elif prior_turn_had_error:
707
+ state_hint = (
708
+ f"[Workspace State: Files created so far: {file_list}. "
709
+ "A previous tool encountered an issue. Address it if needed, "
710
+ "or if all deliverables and requirements are already satisfied, conclude with DONE: <summary>.]"
681
711
  )
682
712
  else:
683
- state_hint = f"[Workspace State: Files created so far: {file_list}. Do NOT re-create these files. Proceed with remaining files or tests.]"
713
+ state_hint = (
714
+ f"[Workspace State: Files created so far: {file_list}. "
715
+ "If all deliverables and requirements are completed, output: DONE: <summary>. "
716
+ "Otherwise, proceed with remaining files or tests.]"
717
+ )
684
718
 
685
719
  # If index.html exists but styles.css hasn't been written yet, inject the Light-Mode-First styling directive
686
720
  if any(f.endswith("index.html") or f == "index.html" for f in session_touched_files) and not any(f.endswith(".css") for f in session_touched_files):
@@ -889,6 +923,21 @@ class AgentOrchestrator:
889
923
  if extracted_tcs and not resp.tool_calls:
890
924
  resp.tool_calls = extracted_tcs
891
925
 
926
+ # One final answer opportunity after an unchanged report write. Tools are
927
+ # disabled, and textual tool calls must not bypass that boundary.
928
+ if finalization_reason:
929
+ success = bool(resp.content and resp.content.strip() and not resp.tool_calls)
930
+ summary = resp.content if success else finalization_reason + " Existing files preserved; completion is unverified."
931
+ if success and not hasattr(task_backend, "chat_completion_stream"):
932
+ yield AgentEvent("message", {"content": summary})
933
+ task_metrics.finish()
934
+ yield AgentEvent("metrics", task_metrics.summary())
935
+ _ensure_trajectory_saved("success" if success else "stalled")
936
+ if not success:
937
+ yield AgentEvent("failed", {"reason": "repeated_tool_outcome", "message": summary})
938
+ yield AgentEvent("done", {"summary": summary, "success": success})
939
+ return
940
+
892
941
  # Truncation cleanup: If any tool call was truncated, ensure arguments retain clean dict structure
893
942
  # with path and parsed content preserved so tools (e.g. write_file partial save) can execute cleanly.
894
943
  for tc in resp.tool_calls or []:
@@ -936,6 +985,30 @@ class AgentOrchestrator:
936
985
  })
937
986
  session.context.add_tool_result(res.tool_call_id, res.content)
938
987
 
988
+ if _check_tool_results_had_error(results):
989
+ for tc, res in zip(tool_calls, results):
990
+ args = tc.arguments
991
+ if isinstance(args, str):
992
+ import json as _json
993
+ try:
994
+ args = _json.loads(args)
995
+ except ValueError:
996
+ args = {}
997
+ reason = convergence.observe(tc.name, args or {}, res.content,
998
+ _check_tool_results_had_error([res]))
999
+ if reason:
1000
+ task_metrics.finish()
1001
+ yield AgentEvent("metrics", task_metrics.summary())
1002
+ _ensure_trajectory_saved("stalled")
1003
+ yield AgentEvent("failed", {"reason": "repeated_tool_outcome", "message": reason})
1004
+ yield AgentEvent("done", {"summary": reason, "success": False})
1005
+ return
1006
+ prior_turn_had_error = True
1007
+ session.context.add_user_message(
1008
+ "The final tool call failed. Resolve the reported error before declaring completion."
1009
+ )
1010
+ continue
1011
+
939
1012
  # Track touched files and executed commands from final tool calls
940
1013
  for tc in tool_calls:
941
1014
  tc_args = tc.arguments if isinstance(tc.arguments, dict) else {}
@@ -1245,6 +1318,44 @@ class AgentOrchestrator:
1245
1318
  })
1246
1319
  session.context.add_tool_result(res.tool_call_id, res.content)
1247
1320
 
1321
+ # Bound recovery independently of model compliance and changing arguments.
1322
+ # Never call a repeated failure a verified completion.
1323
+ for tc, res in zip(tool_calls, results):
1324
+ args = tc.arguments
1325
+ if isinstance(args, str):
1326
+ import json as _json
1327
+ try:
1328
+ args = _json.loads(args)
1329
+ except ValueError:
1330
+ args = {}
1331
+ failed = _check_tool_results_had_error([res])
1332
+ reason = convergence.observe(tc.name, args or {}, res.content, failed)
1333
+ if reason:
1334
+ reports_ready = bool(named_deliverables) and all(
1335
+ Path(f).suffix.lower() in (".md", ".txt", ".rst", ".csv")
1336
+ and f in session_touched_files and (session.workdir / f).is_file()
1337
+ and (session.workdir / f).stat().st_size > 200
1338
+ for f in named_deliverables
1339
+ )
1340
+ if not failed and not turn_had_err and reports_ready:
1341
+ finalization_reason = reason
1342
+ active_tools = []
1343
+ session.context.add_user_message(
1344
+ "[FINAL ANSWER REQUIRED] The report write was unchanged. Stop tool use now. "
1345
+ "Return the final recommendation/summary, identify the report file, and state "
1346
+ "any unavailable research or media coverage. Do not claim unverified facts."
1347
+ )
1348
+ break
1349
+ task_metrics.finish()
1350
+ yield AgentEvent("metrics", task_metrics.summary())
1351
+ _ensure_trajectory_saved("stalled")
1352
+ yield AgentEvent("failed", {"reason": "repeated_tool_outcome", "message": reason})
1353
+ yield AgentEvent("done", {"summary": reason + " Existing files have been preserved; task completion is unverified.", "success": False})
1354
+ return
1355
+
1356
+ if finalization_reason:
1357
+ continue
1358
+
1248
1359
  # ── System 1 Jev Decision Plane Evaluation ──
1249
1360
  for tc, res in zip(tool_calls, results):
1250
1361
  tc_args = tc.arguments if isinstance(tc.arguments, dict) else {}
@@ -1266,7 +1377,11 @@ class AgentOrchestrator:
1266
1377
  })
1267
1378
 
1268
1379
  # ── Hard Circuit Breaker: Auto-verify and fast-forward to finish if inspection loop detected ──
1269
- if decision.action == ActionCategory.SKIP_LLM_FINISH:
1380
+ required_ready = bool(named_deliverables) and all(
1381
+ f in session_touched_files and (session.workdir / f).is_file()
1382
+ and (session.workdir / f).stat().st_size > 0 for f in named_deliverables
1383
+ )
1384
+ if decision.action == ActionCategory.SKIP_LLM_FINISH and required_ready and not turn_had_err:
1270
1385
  from .verifier import IntelligentVerificationEngine
1271
1386
  v_engine = IntelligentVerificationEngine(session.workdir)
1272
1387
  v_res = v_engine.run_full_verification(
@@ -1372,7 +1487,35 @@ class AgentOrchestrator:
1372
1487
  )
1373
1488
  prior_turn_had_error = True
1374
1489
  continue
1375
- elif complexity in ("medium", "high") and turn < safety_ceiling and text_nudges < 6 and "DONE:" not in resp.content.upper():
1490
+ elif task_requires_actions and complexity in ("medium", "high") and turn < safety_ceiling and text_nudges < 6 and "DONE:" not in resp.content.upper():
1491
+ all_deliverables_created = False
1492
+ if session_touched_files:
1493
+ if named_deliverables:
1494
+ all_deliverables_created = all(
1495
+ f in session_touched_files and (session.workdir / f).exists() and (session.workdir / f).stat().st_size > 50
1496
+ for f in named_deliverables
1497
+ )
1498
+ else:
1499
+ all_deliverables_created = any(
1500
+ (session.workdir / f).exists() and (session.workdir / f).stat().st_size > 200
1501
+ for f in session_touched_files
1502
+ )
1503
+
1504
+ has_code_files = any(
1505
+ f.endswith((".py", ".js", ".ts", ".jsx", ".tsx", ".rs", ".go", ".java", ".c", ".cpp"))
1506
+ for f in session_touched_files
1507
+ )
1508
+
1509
+ if all_deliverables_created and not has_code_files and not prior_turn_had_error and not getattr(session, "_auto_verify_attempts", 0) and len(resp.content.strip()) >= 50:
1510
+ # Report / documentation / analysis task where deliverables are already written:
1511
+ # The textual response is the final executive summary. Finish cleanly!
1512
+ resp.content = f"DONE: {resp.content}"
1513
+ task_metrics.finish()
1514
+ yield AgentEvent("metrics", task_metrics.summary())
1515
+ _ensure_trajectory_saved('success')
1516
+ yield AgentEvent("done", {"summary": resp.content, "success": True})
1517
+ return
1518
+
1376
1519
  session._text_response_nudges = text_nudges + 1
1377
1520
  session.context.add_user_message(
1378
1521
  "You responded with text but did not execute a tool call. "
@@ -1467,3 +1610,9 @@ class AgentOrchestrator:
1467
1610
  _ensure_trajectory_saved('stalled')
1468
1611
  yield AgentEvent("max_turns_reached", {"max_turns": safety_ceiling, "progress": status})
1469
1612
  extract_and_save_memories(session.workdir, getattr(session.context, 'all_messages', session.context.messages))
1613
+ task_metrics.finish()
1614
+ yield AgentEvent("metrics", task_metrics.summary())
1615
+ yield AgentEvent("done", {
1616
+ "summary": f"Stopped at the {safety_ceiling}-turn limit. Existing files preserved; completion is unverified.",
1617
+ "success": False,
1618
+ })
@@ -482,6 +482,13 @@ OFFLINE_SYSTEM_PROMPT = """\
482
482
  You are AlpieCode, an autonomous software engineering AI agent built by 169Pi.
483
483
  You are running in OFFLINE mode — there is NO internet access.
484
484
 
485
+ For analysis or comparison requests, answer the user's actual question. Code creation
486
+ and compilation instructions apply only to software implementation tasks. State that
487
+ current prices, official specifications and independent research cannot be verified
488
+ offline; label estimates and unknowns, and never invent sources or video dialogue.
489
+ Sampled video frames are partial visual evidence, not full video or audio analysis.
490
+ When the analysis/report is complete, provide the final answer and stop using tools.
491
+
485
492
  ## Technical Focus Scope
486
493
  Strictly software engineering. For technical tasks, bypass all non-applicable geopolitical policy deliberation in internal reasoning traces. Focus purely on technical implementation, correctness, and execution.
487
494
 
@@ -129,6 +129,10 @@ class System1Controller:
129
129
  html = workdir / "index.html"
130
130
  if html.exists() and html.stat().st_size > 100:
131
131
  return True
132
+ # Documentation / Research reports / Markdown deliverables (e.g. RESEARCH_REPORT.md)
133
+ md_files = [f for f in workdir.glob("*.md") if f.is_file() and f.stat().st_size > 200 and f.name.lower() not in ("walkthrough.md", "readme.md", "agents.md")]
134
+ if len(md_files) >= 1:
135
+ return True
132
136
  # Python project with code
133
137
  py_files = [f for f in workdir.glob("*.py") if f.is_file() and f.stat().st_size > 50 and not f.name.startswith("test_")]
134
138
  if len(py_files) >= 1:
@@ -137,6 +141,10 @@ class System1Controller:
137
141
  js_files = [f for f in workdir.glob("*.js") if f.is_file() and f.stat().st_size > 50 and not f.name.startswith("test_")]
138
142
  if len(js_files) >= 1:
139
143
  return True
144
+ # Data or config files
145
+ data_files = [f for f in workdir.glob("*.json") if f.is_file() and f.stat().st_size > 100 and not f.name.startswith(".")]
146
+ if len(data_files) >= 1:
147
+ return True
140
148
  return False
141
149
 
142
150
  # ── 1. Test Result Checking ─────────────────────────────────────────
@@ -320,7 +328,7 @@ class System1Controller:
320
328
  if path and not str(tool_result).strip().startswith("error:"):
321
329
  count = self._file_write_counts.get(path, 0) + 1
322
330
  self._file_write_counts[path] = count
323
- if count >= 2:
331
+ if count >= 2 and Path(path).suffix.lower() not in (".md", ".txt", ".rst", ".csv"):
324
332
  self.total_interventions += 1
325
333
  directive = (
326
334
  f"[SYSTEM 1 INTERVENTION] Repeated rewrite loop detected for '{path}'. "
@@ -561,4 +569,4 @@ def get_system1_controller() -> System1Controller:
561
569
  global _SYSTEM1_CONTROLLER
562
570
  if _SYSTEM1_CONTROLLER is None:
563
571
  _SYSTEM1_CONTROLLER = System1Controller()
564
- return _SYSTEM1_CONTROLLER
572
+ return _SYSTEM1_CONTROLLER
@@ -1345,9 +1345,13 @@ def make_dispatch(workdir: Path):
1345
1345
  p = _resolve_safe_path(workdir, str(path))
1346
1346
  force = bool(a.get("force") or a.get("overwrite"))
1347
1347
  p_name = Path(path).name.lower()
1348
+ ext = Path(path).suffix.lower()
1348
1349
 
1349
- # Guard against repetitive rewrite loops of existing files from line 0
1350
- if not force and p_name in session_written_files and p.exists() and p.is_file():
1350
+ # Documentation, reports, and data files can always be freely updated or rewritten
1351
+ is_doc_or_data = ext in (".md", ".txt", ".rst", ".json", ".csv", ".log", ".yaml", ".yml")
1352
+
1353
+ # Guard against repetitive rewrite loops of existing code files from line 0
1354
+ if not force and not is_doc_or_data and p_name in session_written_files and p.exists() and p.is_file():
1351
1355
  try:
1352
1356
  existing_lines = len(p.read_text(encoding="utf-8", errors="replace").splitlines())
1353
1357
  except Exception:
@@ -1412,6 +1416,18 @@ def make_dispatch(workdir: Path):
1412
1416
  return "error: 'path' parameter is required for edit_file"
1413
1417
  old_str = a.get("old_str") if a.get("old_str") is not None else a.get("old_string") if a.get("old_string") is not None else a.get("target")
1414
1418
  if old_str is None:
1419
+ # Resilient fallback: if the model passed content/code/text to update the file
1420
+ content_val = None
1421
+ for k in ("content", "code", "text", "body", "replacement", "new_str", "new_string"):
1422
+ if k in a and a[k] is not None:
1423
+ content_val = str(a[k])
1424
+ break
1425
+ if content_val is not None:
1426
+ p = _resolve_safe_path(workdir, str(path))
1427
+ p.parent.mkdir(parents=True, exist_ok=True)
1428
+ res = _write_file(workdir, str(path), content_val, append=False)
1429
+ session_written_files.add(Path(path).name.lower())
1430
+ return res
1415
1431
  return "error: 'old_str' parameter is required for edit_file (the exact string to replace)"
1416
1432
  new_str = a.get("new_str") if a.get("new_str") is not None else a.get("new_string") if a.get("new_string") is not None else a.get("replacement") if a.get("replacement") is not None else a.get("code") if a.get("code") is not None else ""
1417
1433
  return _edit_file(workdir, str(path), str(old_str), str(new_str))
@@ -351,4 +351,78 @@ def test_youtube_cookies_auto_detection(tmp_path, monkeypatch):
351
351
  assert str(fake_cookies.resolve()) in called_cmd
352
352
 
353
353
 
354
+ def test_write_file_allows_markdown_overwrite_and_expansion(tmp_path):
355
+ """Verify write_file allows updating documentation/reports without session overwrite blocks."""
356
+ from codeagent.tools import make_dispatch
357
+ dispatch = make_dispatch(tmp_path)
358
+ wf = dispatch["write_file"]
359
+
360
+ # Initial write of research report
361
+ res1 = wf({"path": "RESEARCH_REPORT.md", "content": "# Initial Car Report\nPreliminary notes."})
362
+ assert "wrote" in res1
363
+ assert "RESEARCH_REPORT.md" in res1
364
+
365
+ # Overwrite with comprehensive expanded content
366
+ full_content = "# Comprehensive Car Comparison Report\n" + "Detailed analysis matrix with all specs.\n" * 20
367
+ res2 = wf({"path": "RESEARCH_REPORT.md", "content": full_content})
368
+ assert "wrote" in res2
369
+ assert "error:" not in res2
370
+ assert (tmp_path / "RESEARCH_REPORT.md").read_text(encoding="utf-8") == full_content
371
+
372
+
373
+ def test_edit_file_fallback_to_content(tmp_path):
374
+ """Verify edit_file gracefully updates a file when content is passed without old_str."""
375
+ from codeagent.tools import make_dispatch
376
+ dispatch = make_dispatch(tmp_path)
377
+ ef = dispatch["edit_file"]
378
+
379
+ target = tmp_path / "notes.md"
380
+ target.write_text("Old notes.")
381
+
382
+ # Model calls edit_file with content instead of old_str/new_str
383
+ res = ef({"path": "notes.md", "content": "# Updated Notes\nClean structured content."})
384
+ assert "error:" not in res
385
+ assert "wrote" in res or "Successfully updated" in res
386
+ assert target.read_text(encoding="utf-8") == "# Updated Notes\nClean structured content."
387
+
388
+
389
+ def test_system1_does_not_treat_report_expansion_as_verified_completion(tmp_path):
390
+ """A report can be expanded; file existence cannot prove research completion."""
391
+ report = tmp_path / "RESEARCH_REPORT.md"
392
+ report.write_text("# Car Comparison Matrix\n" + "Detailed evaluation points.\n" * 15)
354
393
 
394
+ controller = System1Controller()
395
+ controller.reset()
396
+
397
+ # First write
398
+ d1 = controller.evaluate_turn("write_file", {"path": "RESEARCH_REPORT.md"}, "wrote 500 bytes", 1, workdir=tmp_path)
399
+ assert d1.action == ActionCategory.CONTINUE_LLM
400
+
401
+ # A second write could expand a draft and must not skip the final answer.
402
+ d2 = controller.evaluate_turn("write_file", {"path": "RESEARCH_REPORT.md"}, "wrote 500 bytes", 2, workdir=tmp_path)
403
+ assert d2.action == ActionCategory.CONTINUE_LLM
404
+
405
+
406
+ def test_check_tool_results_had_error_with_turn_self_correction():
407
+ """Verify _check_tool_results_had_error ignores transient parameter errors if file succeeded in same turn."""
408
+ from codeagent.orchestrator import _check_tool_results_had_error
409
+ from codeagent.executor import ToolResult
410
+
411
+ res_err = ToolResult(
412
+ tool_call_id="call_1",
413
+ name="write_file",
414
+ content="error: 'content' parameter is required for write_file to 'RESEARCH_REPORT.md'. Please provide the file content.",
415
+ duration_ms=10.0,
416
+ )
417
+ res_ok = ToolResult(
418
+ tool_call_id="call_2",
419
+ name="write_file",
420
+ content="wrote 14059 bytes to RESEARCH_REPORT.md",
421
+ duration_ms=15.0,
422
+ )
423
+
424
+ # Both results in same turn: turn had a self-correcting success on RESEARCH_REPORT.md
425
+ assert not _check_tool_results_had_error([res_err, res_ok])
426
+
427
+ # Uncorrected error should still return True
428
+ assert _check_tool_results_had_error([res_err])