euron-code 1.2.0__tar.gz → 1.3.1__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 (136) hide show
  1. {euron_code-1.2.0 → euron_code-1.3.1}/CHANGELOG.md +30 -0
  2. {euron_code-1.2.0 → euron_code-1.3.1}/PKG-INFO +1 -1
  3. {euron_code-1.2.0 → euron_code-1.3.1}/pyproject.toml +3 -2
  4. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/__init__.py +1 -1
  5. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/agent.py +332 -26
  6. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/cli.py +6 -1
  7. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/licensing.py +20 -0
  8. euron_code-1.3.1/src/euron_code/progress.py +277 -0
  9. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/prompts.py +31 -11
  10. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/erie.py +148 -13
  11. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/fs.py +48 -7
  12. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/normalize.py +9 -1
  13. {euron_code-1.2.0 → euron_code-1.3.1}/tests/mock_gateway.py +2 -1
  14. euron_code-1.3.1/tests/test_bench_harness.py +132 -0
  15. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_erie.py +4 -4
  16. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_reuse_honesty.py +1 -1
  17. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v11_byo.py +1 -0
  18. euron_code-1.3.1/tests/test_v130_cut_writes.py +119 -0
  19. euron_code-1.3.1/tests/test_v130_reliability.py +295 -0
  20. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v31_security.py +2 -2
  21. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_context.py +5 -5
  22. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v4.py +1 -1
  23. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v5.py +1 -1
  24. {euron_code-1.2.0 → euron_code-1.3.1}/.gitignore +0 -0
  25. {euron_code-1.2.0 → euron_code-1.3.1}/LICENSE +0 -0
  26. {euron_code-1.2.0 → euron_code-1.3.1}/README.md +0 -0
  27. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/__main__.py +0 -0
  28. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/activity.py +0 -0
  29. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/api.py +0 -0
  30. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/attachments.py +0 -0
  31. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/auth.py +0 -0
  32. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -0
  33. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
  34. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
  35. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
  36. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/cache.py +0 -0
  37. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/checkpoints.py +0 -0
  38. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/config.py +0 -0
  39. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/context.py +0 -0
  40. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/contextforge/LICENSE +0 -0
  41. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/contextforge/__init__.py +0 -0
  42. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/contextforge/text.py +0 -0
  43. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/contextforge/toolout.py +0 -0
  44. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/credentials.py +0 -0
  45. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/doctor.py +0 -0
  46. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/documents.py +0 -0
  47. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/error_hints.py +0 -0
  48. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/errorlog.py +0 -0
  49. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/frontmatter.py +0 -0
  50. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/hooks.py +0 -0
  51. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/keys.py +0 -0
  52. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/knowledge.py +0 -0
  53. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/llm/__init__.py +0 -0
  54. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/llm/anthropic.py +0 -0
  55. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/llm/base.py +0 -0
  56. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/llm/openai_compat.py +0 -0
  57. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/llm/setup.py +0 -0
  58. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/logo.py +0 -0
  59. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/markdown_view.py +0 -0
  60. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/memory.py +0 -0
  61. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/osscache.py +0 -0
  62. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/ossgithub.py +0 -0
  63. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/pathfix.py +0 -0
  64. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/permissions.py +0 -0
  65. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/project_setup.py +0 -0
  66. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/repl.py +0 -0
  67. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/repomap.py +0 -0
  68. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/rules.py +0 -0
  69. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/security_scan.py +0 -0
  70. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/sessions.py +0 -0
  71. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/skills.py +0 -0
  72. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/textsafe.py +0 -0
  73. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/__init__.py +0 -0
  74. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/background.py +0 -0
  75. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/base.py +0 -0
  76. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/db.py +0 -0
  77. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/document.py +0 -0
  78. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/ignore.py +0 -0
  79. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/oss.py +0 -0
  80. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/pathfind.py +0 -0
  81. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/reuse.py +0 -0
  82. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/search.py +0 -0
  83. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/shell.py +0 -0
  84. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/skill.py +0 -0
  85. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/symbols.py +0 -0
  86. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/task.py +0 -0
  87. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/todo.py +0 -0
  88. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/tools/web.py +0 -0
  89. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/transcript.py +0 -0
  90. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/trust.py +0 -0
  91. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/ui.py +0 -0
  92. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/update_check.py +0 -0
  93. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/usage_view.py +0 -0
  94. {euron_code-1.2.0 → euron_code-1.3.1}/src/euron_code/version_info.py +0 -0
  95. {euron_code-1.2.0 → euron_code-1.3.1}/tests/conftest.py +0 -0
  96. {euron_code-1.2.0 → euron_code-1.3.1}/tests/fake_providers.py +0 -0
  97. {euron_code-1.2.0 → euron_code-1.3.1}/tests/helpers.py +0 -0
  98. {euron_code-1.2.0 → euron_code-1.3.1}/tests/measure_floor.py +0 -0
  99. {euron_code-1.2.0 → euron_code-1.3.1}/tests/serve_helper.py +0 -0
  100. {euron_code-1.2.0 → euron_code-1.3.1}/tests/sim_long_session.py +0 -0
  101. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_agent_mock.py +0 -0
  102. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_api_shell.py +0 -0
  103. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_bench.py +0 -0
  104. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_cli_e2e.py +0 -0
  105. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_context_memory_sessions.py +0 -0
  106. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_dashboard_fixes.py +0 -0
  107. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_dashboard_fixes_102.py +0 -0
  108. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_db.py +0 -0
  109. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_knowledge_security.py +0 -0
  110. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_markdown_view.py +0 -0
  111. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_oss_local.py +0 -0
  112. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_permissions.py +0 -0
  113. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_powershell_exit_codes.py +0 -0
  114. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_qa_attach_secrets.py +0 -0
  115. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_qa_long_task.py +0 -0
  116. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_qa_print_output.py +0 -0
  117. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_qa_reuse_unrelated.py +0 -0
  118. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_qa_yolo_outside.py +0 -0
  119. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_repl.py +0 -0
  120. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_search.py +0 -0
  121. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_textsafe.py +0 -0
  122. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_tools_fs.py +0 -0
  123. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_transcript_ui.py +0 -0
  124. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_update_check.py +0 -0
  125. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v111_user_reports.py +0 -0
  126. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v113_fix_path.py +0 -0
  127. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v11_speed.py +0 -0
  128. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v11_tool_fixes.py +0 -0
  129. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v2_rules_skills_hooks.py +0 -0
  130. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v2_tokens_shortcuts.py +0 -0
  131. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v2_usage_headers.py +0 -0
  132. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_accounts_value_setup.py +0 -0
  133. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_activity.py +0 -0
  134. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_attachments.py +0 -0
  135. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_live_repl.py +0 -0
  136. {euron_code-1.2.0 → euron_code-1.3.1}/tests/test_v3_single_login.py +0 -0
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.1 (2026-11-09)
4
+
5
+ - A new build in an empty folder no longer gets the "here is every file in this small project" note (it only held
6
+ EURON.md and made the model answer with nothing). EURON.md is never repeated in it.
7
+ - GitHub references must be about the product asked for (a FastAPI todo API was offered a WhatsApp bot repo).
8
+
9
+ ## 1.3.0 (2026-11-09)
10
+
11
+ Finishes coding jobs more reliably: no more loops, no cut-off files, no unrelated repositories.
12
+
13
+ - Long files are written in parts. When a file write hits the model's output limit, the lines that arrived
14
+ are kept and Euron Code continues the file from there (`write_file` with `append`), instead of writing the
15
+ whole file again and getting cut off again. Files over about 300 lines are written in parts from the start.
16
+ - Loop guard: the same error coming back, a file edited back and forth, or a long run of failing tool calls
17
+ first makes Euron Code change approach, then stops with a short report (what works, the exact error that
18
+ blocks it, what it tried, the next step) instead of using up the whole time budget.
19
+ - Done means checked: after the last change a real check (build, tests or running the program) has to pass.
20
+ Listing files or installing packages no longer counts. If the last check fails, Euron Code goes back and
21
+ fixes it, or says exactly which check fails and why.
22
+ - Fewer, bigger steps: a small project (up to 12 small files) is read whole into the first step, so Euron Code
23
+ does not list and read the files one by one; the tests run once, and it stops as soon as they pass.
24
+ - Reuse only when it fits: Euron repositories and GitHub references are suggested only when they are about
25
+ the same product (a calculator is no longer pointed at an HR app), in the same language, small, and only
26
+ in a new, empty project. HTML / CSS / JavaScript requests stay plain JavaScript. Adopted code that still does not
27
+ build after 3 checks is removed again, with its licence notice, and that part is written from scratch.
28
+ - `@` followed by punctuation ("exactly one @, a dot") is plain text, not a file to attach (it used to stop
29
+ `euron -p` before it started).
30
+ - `read_file` on a folder shows what is in it; editing a folder names the files in it; `multi_edit` with the
31
+ file named inside each edit, and `read_file` past the end of a file, now work instead of failing.
32
+
3
33
  ## 1.2.0 (2026-11-09)
4
34
 
5
35
  Faster steps on the Euron model: more of every request reuses the prompt the model has already read.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: euron-code
3
- Version: 1.2.0
3
+ Version: 1.3.1
4
4
  Summary: Euron Code: an agentic coding assistant in your terminal for Euron Plus and Super 30 students.
5
5
  Project-URL: Homepage, https://euron.one/code-agent
6
6
  Author-email: Euron <contact@euron.one>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "euron-code"
7
- version = "1.2.0"
7
+ version = "1.3.1"
8
8
  description = "Euron Code: an agentic coding assistant in your terminal for Euron Plus and Super 30 students."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -55,7 +55,8 @@ packages = ["src/euron_code"]
55
55
  "CHANGELOG.md" = "euron_code/CHANGELOG.md"
56
56
 
57
57
  [tool.hatch.build.targets.sdist]
58
- include = ["src/euron_code", "tests", "README.md", "CHANGELOG.md", "LICENSE", "pyproject.toml"]
58
+ include = ["/src/euron_code", "/tests", "/README.md", "/CHANGELOG.md", "/LICENSE", "/pyproject.toml"]
59
+ exclude = ["/bench"] # the benchmark never ships (CI checks wheel and sdist)
59
60
 
60
61
  [tool.pytest.ini_options]
61
62
  testpaths = ["tests"]
@@ -1,3 +1,3 @@
1
1
  """Euron Code: an agentic coding assistant for the terminal."""
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.3.1"
@@ -19,7 +19,7 @@ from dataclasses import dataclass, field
19
19
  from pathlib import Path
20
20
  from typing import Any, Callable, Dict, List, Optional, Tuple
21
21
 
22
- from euron_code import api, context, licensing, memory, prompts, rules, skills
22
+ from euron_code import api, context, licensing, memory, progress, prompts, rules, skills
23
23
  from euron_code.activity import Activity, phase_from_comment, tool_label
24
24
  from euron_code.api import (BusyError, ContextTooLongError, EuronError, Interrupted, MidStreamError,
25
25
  NetworkError, RateLimitedError)
@@ -68,6 +68,10 @@ MAX_CONTINUES = 3 # automatic continuations after an answer hit the output limi
68
68
  LOOP_NOTE_AT = 3 # identical failing calls before the model is told to change approach
69
69
  LOOP_STOP_AT = 5 # ... and before the turn is stopped
70
70
  REPEAT_NOTE_AT = 4 # identical successful calls (re-reads) before a note
71
+ MAX_DONE_NUDGES = 2 # "check your change" / "the last check still fails" before the agent may finish
72
+ ADOPT_ROLLBACK_AT = 3 # failing checks after an oss_adopt (none passing) before the adopted code is removed
73
+ NEW_PROJECT_MAX_FILES = 0 # a folder with no source file yet is a new project (reuse only there; bench 2026-11-09:
74
+ # a stub + test repo got GitHub references and spent steps reading flutter / whitepaper repos)
71
75
  REPEAT_STOP_AT = 8
72
76
  SEARCH_BUDGET = 4 # reference searches per request before a "pick one" note
73
77
  READ_BUDGET = 6 # reference file reads per request
@@ -77,6 +81,9 @@ READ_TOOLS = ("euron_reuse_read", "oss_read", "oss_tree", "oss_grep")
77
81
  _LIC_RE = re.compile(r"\[(MIT|Apache-2\.0|BSD-[23]-Clause|ISC|0BSD|Unlicense|MPL-2\.0|CC0-1\.0|Zlib)\]|licence (\S+)")
78
82
  DEFAULT_STEP_BUDGET = 60
79
83
  _EXIT_RE = re.compile(r"^Exit code: (-?\d+)")
84
+ _DOC_RE = re.compile(r"(\.(md|txt|rst|adoc)$|^(LICENSE|NOTICE|THIRD_PARTY_NOTICES)|(^|/)\.euron/)", re.I)
85
+ _SOURCE_RE = re.compile(r"\.(py|ipynb|js|jsx|ts|tsx|mjs|cjs|vue|svelte|html|css|scss|java|kt|go|rs|c|cc|cpp|h|cs|"
86
+ r"php|rb|swift|dart|sql)$", re.I)
80
87
  SIMPLE_FOLLOWUP = re.compile(
81
88
  r"^(ok(ay)?|yes|yep|y|no|n|thanks?( you)?|thx|ty|continue|go( on| ahead)?|sure|do it|proceed|next|"
82
89
  r"great|perfect|nice|cool|looks good|lgtm|done)[.!\s]*$", re.IGNORECASE)
@@ -229,6 +236,15 @@ class Agent:
229
236
  self._reuse_nudged = False
230
237
  self._calls: Dict[tuple, int] = {}
231
238
  self._nudged = False
239
+ self.guard = progress.ProgressGuard() # loops, stalls, edit-revert cycles (1.3.0)
240
+ self._stuck = "" # why the guard stopped this request
241
+ self._done_nudges = 0
242
+ self._last_check: Optional[Tuple[str, int, str]] = None # (command, exit code, error tail)
243
+ self._adopt_fails = 0
244
+ self._rolled_back: List[str] = [] # repos whose adopted code was removed this request
245
+ self._cut_calls: Dict[str, Tuple[str, str]] = {} # tool call id -> ("saved" | "skip", note)
246
+ self.cut_writes = 0 # tool calls cut by the output limit this session
247
+ self.new_project = False
232
248
  self.test_command: Optional[str] = None
233
249
  self.plan: Optional[Dict[str, Any]] = None # find_reusable's decision table for this request
234
250
  self.stack: Optional[Dict[str, Any]] = None
@@ -419,12 +435,18 @@ class Agent:
419
435
 
420
436
  def _run_top_turn(self, user_text: str, max_turns: Optional[int]) -> TurnResult:
421
437
  self.client.task_id = api.new_task_id() # X-Euron-Task: one per user prompt
422
- self.ledger = {"edits": [], "commands": [], "reused": [], "read": []}
438
+ self.ledger = {"edits": [], "commands": [], "reused": [], "read": [], "adopted": []}
423
439
  self._reuse_chars = {}
424
440
  self._read_bodies = {}
425
441
  self._references = []
426
442
  self._reuse_nudged = False
427
443
  self._calls = {}
444
+ self.guard.reset()
445
+ self._stuck = ""
446
+ self._done_nudges = 0
447
+ self._last_check = None
448
+ self._adopt_fails = 0
449
+ self._rolled_back = []
428
450
  self.plan = None
429
451
  self._reused_components = {}
430
452
  self._published = set()
@@ -495,6 +517,8 @@ class Agent:
495
517
  text += "\n\n" + prompts.PLAN_MODE_NOTE
496
518
  if not self.is_subagent:
497
519
  text += self._build_context(user_text)
520
+ if len(self.messages) == 1:
521
+ text += self._small_project_snapshot()
498
522
  content: Any = text
499
523
  if self.pending_images and not self.is_subagent:
500
524
  content = [{"type": "text", "text": text}] + self.pending_images
@@ -566,13 +590,17 @@ class Agent:
566
590
  return TurnResult(last_text, "error", turns, error=e)
567
591
  if resp.finish_reason == "length":
568
592
  kind = _cut_kind(resp)
569
- if kind == "tool" and cut_tools < 2:
570
- # never run a call whose arguments were cut; ask for smaller steps instead
593
+ if resp.tool_calls:
594
+ # the limit hit while the last call was being written: never run a cut call as if it were
595
+ # whole. A cut write_file keeps what arrived (whole lines) and continues from there in
596
+ # parts; anything else is answered "not run, smaller steps" (1.3.0; 1.1.x re-sent whole
597
+ # files, each cut again after 4-5 minutes)
571
598
  cut_tools += 1
572
- self._append({"role": "assistant", "content": resp.content or "(tool call cut off)"})
573
- self._append({"role": "user", "content": prompts.CUT_TOOL_NUDGE})
574
- self.ui.dim("(That tool call was too long for one step; asking for smaller steps.)")
575
- continue
599
+ saved = self._repair_cut_calls(resp)
600
+ self.ui.dim(f"(the output limit cut a tool call; kept the first {saved} lines, continuing "
601
+ "in parts)" if saved else "(a tool call was too long for one step; asking for "
602
+ "smaller steps)")
603
+ kind = None
576
604
  if kind == "text" and continues < MAX_CONTINUES:
577
605
  continues += 1
578
606
  partial += resp.content
@@ -636,10 +664,13 @@ class Agent:
636
664
  self._append({"role": "user", "content": prompts.NOTICE_NUDGE.format(repos=missing)})
637
665
  self.ui.dim("(asking Euron Code to record the reused sources in THIRD_PARTY_NOTICES.md)")
638
666
  continue
639
- if self._needs_verify_nudge():
640
- self._nudged = True
641
- self._append({"role": "user", "content": prompts.verify_nudge(self.test_command)})
642
- self.ui.dim("(asking Euron Code to check its change)")
667
+ done = self._done_nudge()
668
+ if done:
669
+ self._done_nudges += 1
670
+ self._append({"role": "user", "content": done})
671
+ self.ui.dim("(asking Euron Code to check its change)" if self._done_nudges == 1 and
672
+ not done.startswith("[Euron Code: the last check") else
673
+ "(the last check still fails; asking Euron Code to fix it)")
643
674
  continue
644
675
  open_todos = [t for t in self.ctx.todos if isinstance(t, dict)
645
676
  and t.get("status") in ("pending", "in_progress")]
@@ -663,10 +694,10 @@ class Agent:
663
694
  todos_before = list(self.ctx.todos)
664
695
  if stop == DENIED:
665
696
  return TurnResult(last_text, "denied", turns)
666
- if stop == "loop":
667
- self.ui.warn("Stopped: the model kept repeating the same call without progress. Tell Euron Code "
668
- "what to try instead.")
669
- return TurnResult(last_text, "loop", turns)
697
+ if stop in ("loop", "stuck"):
698
+ why = self._stuck or "the model kept repeating the same call"
699
+ self.ui.warn(f"Stopped: no progress ({why}). Asking Euron Code for what works and what blocks it.")
700
+ return self._wrap_up(turns, last_text, nudge=prompts.STUCK_NUDGE.format(why=why), reason=stop)
670
701
  if stop == "interrupted":
671
702
  self.ui.warn("Interrupted. Tell Euron Code what to do instead.")
672
703
  self.pending_note = "[The user interrupted the previous tool call.]"
@@ -686,11 +717,12 @@ class Agent:
686
717
  return True
687
718
  return bool(steps > 0 and turns >= steps)
688
719
 
689
- def _wrap_up(self, turns: int, last_text: str) -> TurnResult:
720
+ def _wrap_up(self, turns: int, last_text: str, nudge: Optional[str] = None, reason: str = "budget") -> TurnResult:
690
721
  """Ask once, without tools, for: what is done, what is left, the next step. Then stop cleanly."""
691
- self.ui.warn("This request reached its time / step budget (taskTimeBudgetMinutes, taskStepBudget); "
692
- "asking Euron Code to wrap up. Say \"continue\" to keep going.")
693
- self._append({"role": "user", "content": prompts.WRAP_UP_NUDGE})
722
+ if nudge is None:
723
+ self.ui.warn("This request reached its time / step budget (taskTimeBudgetMinutes, taskStepBudget); "
724
+ "asking Euron Code to wrap up. Say \"continue\" to keep going.")
725
+ self._append({"role": "user", "content": nudge or prompts.WRAP_UP_NUDGE})
694
726
  self._effort_once = "low"
695
727
  saved = self.tool_schemas
696
728
  try:
@@ -715,7 +747,7 @@ class Agent:
715
747
  self._append({"role": "assistant", "content": resp.content or "(no summary)"})
716
748
  if not self.is_subagent:
717
749
  self._footer()
718
- return TurnResult(resp.content or last_text, "budget", turns + 1)
750
+ return TurnResult(resp.content or last_text, reason, turns + 1)
719
751
 
720
752
  # ---------------------------------------------------------- model request
721
753
  # ---------------------------------------------------------- budget
@@ -1151,6 +1183,8 @@ class Agent:
1151
1183
  stop = outcome
1152
1184
  elif looping:
1153
1185
  stop = "loop"
1186
+ elif self._stuck:
1187
+ stop = "stuck"
1154
1188
  return stop
1155
1189
 
1156
1190
  def _run_parallel(self, calls: List[Dict[str, Any]], truncated: bool) -> Dict[str, Tuple[str, Optional[str]]]:
@@ -1242,6 +1276,194 @@ class Agent:
1242
1276
  # too (live 2026-11-05: the nudge asked to re-verify after check_app).
1243
1277
  self.ledger["commands"].append((step, "check_app", 0))
1244
1278
 
1279
+ # ---------------------------------------------------------- calls cut by the output limit
1280
+ def _repair_cut_calls(self, resp: "Response") -> int:
1281
+ """The answer stopped at the output limit while writing its tool calls. Complete calls before the last
1282
+ one run as usual; the last one (and any that does not parse) is cut. A cut write_file of a NEW file, or
1283
+ an append, is rewritten to save the whole lines that arrived and the model continues the file from
1284
+ there with append=true; any other cut call is not run. Returns the number of lines saved."""
1285
+ saved = 0
1286
+ calls = resp.tool_calls or []
1287
+ for i, tc in enumerate(calls):
1288
+ fn = tc.get("function") or {}
1289
+ raw = fn.get("arguments") or ""
1290
+ try:
1291
+ json.loads(raw) if raw.strip() else {}
1292
+ whole = i < len(calls) - 1
1293
+ except ValueError:
1294
+ whole = False
1295
+ if whole:
1296
+ continue
1297
+ self.cut_writes += 1
1298
+ cid = tc.get("id") or f"cut{i}"
1299
+ tc["id"] = cid
1300
+ kb = max(1, len(raw) // 1024)
1301
+ if fn.get("name") == "write_file":
1302
+ path, content, append = progress.salvage_write(raw)
1303
+ keep = progress.complete_lines(content)
1304
+ target = self.ctx.resolve(path) if path else None
1305
+ fresh = target is not None and (append or not target.exists())
1306
+ if fresh and keep.strip():
1307
+ fn["arguments"] = json.dumps({"path": path, "content": keep, "append": append})
1308
+ lines = keep.count("\n")
1309
+ tail = "\n".join(keep.rstrip("\n").splitlines()[-3:])
1310
+ self._cut_calls[cid] = ("saved", prompts.CUT_WRITE_NOTE.format(
1311
+ path=path, lines=lines, tail=tail[-600:]))
1312
+ saved += lines
1313
+ continue
1314
+ self._cut_calls[cid] = ("skip", prompts.CUT_WRITE_SKIPPED.format(path=path or "the file", kb=kb))
1315
+ continue
1316
+ self._cut_calls[cid] = ("skip", prompts.CUT_TOOL_NUDGE)
1317
+ self._effort_once = "low" # the next step is mechanical: keep writing
1318
+ return saved
1319
+
1320
+ # ---------------------------------------------------------- progress guard, done gate, adoption rollback
1321
+ def _progress(self, name: str, req: Optional[Request], args: Dict[str, Any], content: str, is_error: bool) -> str:
1322
+ """Feed one tool result to the guard; returns the content with any note for the model. Sets
1323
+ self._stuck when the request should stop and report (the loop then asks for a summary)."""
1324
+ command = (req.command if req is not None else "") or ""
1325
+ is_check = name == "check_app" or (name == "bash" and progress.is_check_command(command))
1326
+ failed = is_error or progress.failed_result(content)
1327
+ if is_check:
1328
+ m = _EXIT_RE.match(content)
1329
+ code = 0 if (name == "check_app" and not failed) else (int(m.group(1)) if m else (1 if failed else 0))
1330
+ self._last_check = (command or name, code, progress.tail_for(content) if code else "")
1331
+ v = self.guard.tool_result(name, content, is_check=is_check)
1332
+ notes = [v.note] if v.note else []
1333
+ if not failed and req is not None and req.category == "Edit" and name != "oss_adopt":
1334
+ for p in req.paths[:4]:
1335
+ try:
1336
+ text = p.read_text(encoding="utf-8", errors="replace") if p.is_file() and \
1337
+ p.stat().st_size < 2_000_000 else None
1338
+ except OSError:
1339
+ text = None
1340
+ w = self.guard.file_written(self.ctx.rel(p), text)
1341
+ if w.note:
1342
+ notes.append(w.note)
1343
+ if w.stop:
1344
+ v = w
1345
+ if is_check and self.ledger.get("adopted"):
1346
+ if failed:
1347
+ self._adopt_fails += 1
1348
+ if self._adopt_fails >= ADOPT_ROLLBACK_AT:
1349
+ notes.append(self._rollback_adoption())
1350
+ else:
1351
+ self._adopt_fails = 0
1352
+ self.ledger["adopted"] = [] # it builds: the adopted code stays
1353
+ if v.stop and not self._stuck:
1354
+ self._stuck = v.stop
1355
+ if notes:
1356
+ self._effort_once = "high" # re-plan with more thought instead of spinning
1357
+ content += "\n\n" + "\n".join(n for n in notes if n)
1358
+ return content
1359
+
1360
+ def _track_adopted(self, args: Dict[str, Any], req: Optional[Request]) -> None:
1361
+ """Remember what oss_adopt wrote (it only ever creates new files), so it can be rolled back."""
1362
+ if req is None:
1363
+ return
1364
+ notices = (self.root / licensing.NOTICES_FILE).resolve()
1365
+ files = [p for p in req.paths if p.resolve() != notices and p.exists()]
1366
+ self.ledger.setdefault("adopted", []).append((str(args.get("repo") or ""), files))
1367
+ self._adopt_fails = 0
1368
+
1369
+ def _rollback_adoption(self) -> str:
1370
+ """The adopted code still does not build after ADOPT_ROLLBACK_AT checks: remove it (files, licence copy,
1371
+ notice entry) so the user is never left with someone else's broken repo; the model builds that part
1372
+ itself on the project's own scaffold."""
1373
+ removed: List[str] = []
1374
+ repos: List[str] = []
1375
+ for repo, files in self.ledger.get("adopted") or []:
1376
+ for p in files:
1377
+ try:
1378
+ if p.is_file():
1379
+ p.unlink()
1380
+ removed.append(self.ctx.rel(p))
1381
+ parent = p.parent
1382
+ while parent != self.root and parent.is_dir() and not any(parent.iterdir()):
1383
+ parent.rmdir()
1384
+ parent = parent.parent
1385
+ except OSError:
1386
+ continue
1387
+ if repo:
1388
+ repos.append(repo)
1389
+ try:
1390
+ licensing.remove_notice(self.root, repo)
1391
+ except OSError:
1392
+ pass
1393
+ self.ledger["reused"] = [r for r in self.ledger.get("reused") or [] if r[0] != repo]
1394
+ self.ledger["adopted"] = []
1395
+ self._adopt_fails = 0
1396
+ self._rolled_back += repos
1397
+ names = ", ".join(repos) or "the reference repo"
1398
+ self.ui.warn(f"The code adopted from {names} did not build after {ADOPT_ROLLBACK_AT} tries; removed it "
1399
+ f"({len(removed)} file(s)). Euron Code continues on your project's own scaffold.")
1400
+ return (f"[Euron Code: the code adopted from {names} still failed after {ADOPT_ROLLBACK_AT} checks, so it "
1401
+ f"was REMOVED from the project ({', '.join(removed[:8]) or 'no files left'}) together with its "
1402
+ "notice. Do not adopt or copy it again. Write that part yourself on the project's own scaffold, "
1403
+ "in small steps, and run the check after each one.]")
1404
+
1405
+ def _check_command(self) -> Optional[str]:
1406
+ """The project's own proof that it builds: the configured test command, else the build / test scripts."""
1407
+ if self.test_command:
1408
+ return self.test_command
1409
+ scripts: Dict[str, str] = {}
1410
+ try:
1411
+ pkg = self.root / "package.json"
1412
+ if pkg.is_file():
1413
+ scripts = dict((json.loads(pkg.read_text(encoding="utf-8") or "{}").get("scripts") or {}))
1414
+ except (OSError, ValueError, AttributeError):
1415
+ scripts = {}
1416
+ tests = False
1417
+ try:
1418
+ # pytest only when there are pytest-style tests (a test_x.py script with bare asserts collects
1419
+ # nothing and pytest exits 5)
1420
+ cands = list(self.root.glob("test*.py"))[:10] + [
1421
+ p for d in ("tests", "test") for p in list((self.root / d).glob("test_*.py"))[:10]]
1422
+ tests = any(re.search(r"^\s*(async\s+)?def test_", p.read_text(encoding="utf-8", errors="replace"),
1423
+ re.M) for p in cands if p.is_file() and p.stat().st_size < 1_000_000)
1424
+ except OSError:
1425
+ tests = False
1426
+ return progress.detect_check_command(self.files_changed(), scripts, tests)
1427
+
1428
+ def _done_nudge(self) -> Optional[str]:
1429
+ """Definition of done: after the last change a real check (build / tests / running it) must pass. Up
1430
+ to MAX_DONE_NUDGES times the model is sent back: to run one, or to fix the one that fails."""
1431
+ if (self.is_subagent or self._done_nudges >= MAX_DONE_NUDGES or not self.ledger["edits"]
1432
+ or self.permissions.mode == "plan" or self.settings.get("verifyNudge", True) is False):
1433
+ return None
1434
+ if all(_DOC_RE.search(rel) for rel in self.files_changed()):
1435
+ return None # docs / notes only: nothing to build
1436
+ if self._verified():
1437
+ return None
1438
+ last_edit = max(step for step, _ in self.ledger["edits"])
1439
+ after = [(c, code) for step, c, code in self.ledger["commands"] if step >= last_edit
1440
+ and progress.is_check_command(c)]
1441
+ if after and after[-1][1] != 0 and self._last_check:
1442
+ cmd, code, tail = self._last_check
1443
+ return prompts.CHECK_FAILED_NUDGE.format(cmd=cmd[:160], code=code, tail=tail[:900] or "(no output)")
1444
+ if self._nudged:
1445
+ return None # asked once to verify and it chose not to: it says why in its answer
1446
+ self._nudged = True
1447
+ return prompts.verify_nudge(self._check_command())
1448
+
1449
+ def _is_new_project(self) -> bool:
1450
+ """An empty or near-empty folder: a new build, where reuse references make sense. In an existing project
1451
+ the model works with the project's own code (prod: debounce in src/timing.js, a React counter or a
1452
+ Dockerfile got "REUSE euron-open-hrms" plans)."""
1453
+ n = 0
1454
+ skip = {"node_modules", ".git", ".venv", "venv", "env", "__pycache__", ".euron", "dist", "build", ".next"}
1455
+ try:
1456
+ for dirpath, dirnames, filenames in os.walk(self.root):
1457
+ dirnames[:] = [d for d in dirnames if d not in skip and not d.startswith(".")]
1458
+ for f in filenames:
1459
+ if _SOURCE_RE.search(f):
1460
+ n += 1
1461
+ if n > NEW_PROJECT_MAX_FILES:
1462
+ return False
1463
+ except OSError:
1464
+ return False
1465
+ return True
1466
+
1245
1467
  # ---------------------------------------------------------- ERIE: plan-driven phases, component library
1246
1468
  def _planned(self, args: Dict[str, Any]) -> Optional[Dict[str, Any]]:
1247
1469
  """The plan component whose pinned code this read is about."""
@@ -1403,6 +1625,60 @@ class Agent:
1403
1625
  def files_changed(self) -> List[str]:
1404
1626
  return list(dict.fromkeys(rel for _, rel in self.ledger["edits"]))
1405
1627
 
1628
+ # ---------------------------------------------------------- tiny projects: every file in the first message
1629
+ SNAPSHOT_MAX_FILES = 12
1630
+ SNAPSHOT_MAX_FILE = 12_000
1631
+ SNAPSHOT_MAX_TOTAL = 40_000
1632
+
1633
+ def _small_project_snapshot(self) -> str:
1634
+ """A project of a few small files goes into the first message whole (counted as read), so the model
1635
+ does not spend its first steps listing and reading them one by one (bench 2026-11-09: Euron 1.2.0 took
1636
+ 14-45 steps on tasks other agents finish in 4). Dot-folders, dependencies and lockfiles are skipped."""
1637
+ if self.settings.get("smallProjectSnapshot", True) is False:
1638
+ return ""
1639
+ skip = {"node_modules", "venv", "env", "__pycache__", "dist", "build", "target", "coverage"}
1640
+ locks = {"package-lock.json", "yarn.lock", "pnpm-lock.yaml", "poetry.lock", "uv.lock", "Cargo.lock"}
1641
+ files: List[Path] = []
1642
+ total = 0
1643
+ try:
1644
+ for dirpath, dirnames, filenames in os.walk(self.root):
1645
+ dirnames[:] = sorted(d for d in dirnames if d not in skip and not d.startswith("."))
1646
+ for f in sorted(filenames):
1647
+ if f.startswith(".") or f in locks or f in (licensing.NOTICES_FILE, "EURON.md"):
1648
+ continue
1649
+ p = Path(dirpath) / f
1650
+ try:
1651
+ size = p.stat().st_size
1652
+ except OSError:
1653
+ return ""
1654
+ if size > self.SNAPSHOT_MAX_FILE:
1655
+ return "" # one big file: not a tiny project, the normal tools are better
1656
+ files.append(p)
1657
+ total += size
1658
+ if len(files) > self.SNAPSHOT_MAX_FILES or total > self.SNAPSHOT_MAX_TOTAL:
1659
+ return ""
1660
+ except OSError:
1661
+ return ""
1662
+ if not any(_SOURCE_RE.search(p.name) for p in files):
1663
+ return "" # nothing to change yet (a new build): the note would only confuse it (live 1.3.0)
1664
+ from euron_code.tools.fs import TO_END
1665
+ blocks: List[str] = []
1666
+ for p in files:
1667
+ try:
1668
+ raw = p.read_bytes()
1669
+ if b"\x00" in raw[:4096]:
1670
+ continue
1671
+ body = raw.decode("utf-8")
1672
+ except (OSError, UnicodeDecodeError):
1673
+ continue
1674
+ self.ctx.tracker.mark_read(p, (1, TO_END), self.ctx.turn, len(body), None)
1675
+ blocks.append(f'<project-file path="{self.ctx.rel(p)}">\n{body}\n</project-file>')
1676
+ if not blocks:
1677
+ return ""
1678
+ return ("\n\n[This project is small: here is every file in it, as on disk now (you have read them; do not "
1679
+ "list or read them again). Make the change, run the tests once, and stop when they pass.]\n"
1680
+ + "\n".join(blocks))
1681
+
1406
1682
  # ---------------------------------------------------------- build requests: reuse first, your details
1407
1683
  def _build_context(self, user_text: str) -> str:
1408
1684
  """For a build request: ask the reuse engine BEFORE the first model call (a cheap local split, no
@@ -1415,7 +1691,8 @@ class Agent:
1415
1691
  if not erie.is_build_request(user_text):
1416
1692
  return ""
1417
1693
  out = ""
1418
- if erie.reuse_enabled(self.settings):
1694
+ self.new_project = self._is_new_project()
1695
+ if erie.reuse_enabled(self.settings) and self.new_project:
1419
1696
  comps = erie.split_components(user_text, self.stack)
1420
1697
  data = erie.request_plan(self, self.ui, user_text.strip()[:500], comps, erie.external_allowed(self.settings))
1421
1698
  out += "\n\n" + (erie.plan_note(data["components"]) if data and data.get("components")
@@ -1471,6 +1748,11 @@ class Agent:
1471
1748
  of MIT calculators exist)."""
1472
1749
  if self.is_subagent or self._reuse_nudged or not self._references or self.permissions.mode == "plan":
1473
1750
  return False
1751
+ r = self.settings.get("reuse") if isinstance(self.settings.get("reuse"), dict) else {}
1752
+ if r.get("nudge") is not True:
1753
+ # off by default since 1.3.0: sending a finished build back to read GitHub repos (prod: 45 tasks)
1754
+ # made it adopt code it did not need, which then had to be made to build
1755
+ return False
1474
1756
  if not self.ledger.get("edits"):
1475
1757
  return False
1476
1758
  looked = {r.lower() for r, _, _ in (self.ledger.get("read") or []) + (self.ledger.get("reused") or [])}
@@ -1527,7 +1809,11 @@ class Agent:
1527
1809
  if not self.ledger["edits"]:
1528
1810
  return True
1529
1811
  last_edit = max(step for step, _ in self.ledger["edits"])
1530
- return any(step >= last_edit and code == 0 for step, _, code in self.ledger["commands"])
1812
+ # a real check (tests, build, running it) after the last change, and the latest one passed;
1813
+ # 1.2.0 counted ANY exit 0, so `ls` after a broken build was "verified"
1814
+ after = [code for step, c, code in self.ledger["commands"] if step >= last_edit
1815
+ and progress.is_check_command(c)]
1816
+ return bool(after) and after[-1] == 0
1531
1817
 
1532
1818
  def _needs_verify_nudge(self) -> bool:
1533
1819
  return (not self.is_subagent and not self._nudged and bool(self.ledger["edits"])
@@ -1576,6 +1862,10 @@ class Agent:
1576
1862
  if tool is None:
1577
1863
  self.ui.tool_start(name, "(unknown tool)")
1578
1864
  return f"Error: unknown tool `{name}`. Available: {', '.join(self.tool_map)}.", None
1865
+ cut = self._cut_calls.pop(tc.get("id") or "", None)
1866
+ if cut is not None and cut[0] == "skip":
1867
+ self.ui.tool_start(name, "(cut off by the output limit, not run)")
1868
+ return "Error: " + cut[1], None
1579
1869
  try:
1580
1870
  args = json.loads(raw) if raw.strip() else {}
1581
1871
  if not isinstance(args, dict):
@@ -1590,6 +1880,8 @@ class Agent:
1590
1880
  args = normalize_args(args, getattr(tool, "parameters", None))
1591
1881
  except Exception: # repairing is best effort; the tool still validates
1592
1882
  pass
1883
+ if cut is not None:
1884
+ args["_partial"] = True # a file written in parts: no syntax check of its missing end
1593
1885
  try:
1594
1886
  summary = tool.describe(args, self.ctx)
1595
1887
  except Exception:
@@ -1599,7 +1891,10 @@ class Agent:
1599
1891
  if act is not None:
1600
1892
  act.tool_started(self._erie_label(name, args) or tool_label(name, summary))
1601
1893
  try:
1602
- return self._execute_tool(tool, name, args, tc, truncated)
1894
+ content, outcome = self._execute_tool(tool, name, args, tc, truncated)
1895
+ if cut is not None and not content.startswith("Error"):
1896
+ content += "\n" + cut[1]
1897
+ return content, outcome
1603
1898
  finally:
1604
1899
  if act is not None:
1605
1900
  act.tool_finished()
@@ -1678,10 +1973,13 @@ class Agent:
1678
1973
  if result.is_error and not content.startswith(("Error", "Exit code")):
1679
1974
  content = "Error: " + content
1680
1975
  self._record(name, req, content, result.is_error)
1976
+ if not self.is_subagent:
1977
+ content = self._progress(name, req, args, content, result.is_error)
1681
1978
  if not result.is_error and name.startswith("oss_") and isinstance(args.get("repo"), str) and "/" in args["repo"]:
1682
1979
  self.ctx.last_repo = args["repo"].strip()
1683
1980
  if not result.is_error and name == "oss_adopt":
1684
1981
  self._record_adoption(args, content)
1982
+ self._track_adopted(args, req)
1685
1983
  if not result.is_error and name == "add_third_party_notice":
1686
1984
  self._record_notice(args)
1687
1985
  if not result.is_error and (name in SEARCH_TOOLS or name in READ_TOOLS):
@@ -2131,8 +2429,16 @@ class Agent:
2131
2429
  for m in MENTION.finditer(text):
2132
2430
  raw = m.group(1)
2133
2431
  for cand in (raw, raw.rstrip(".,;:!?)]}'\"")):
2134
- p = self.ctx.resolve(cand)
2135
- if p.exists():
2432
+ # "@)." or "exactly one @, a dot" is text, not a path (bench 2026-11-09: 4 of 75 tasks crashed
2433
+ # with "A non-empty path is required" before any model call)
2434
+ if not cand or not re.search(r"[\w~]", cand):
2435
+ continue
2436
+ try:
2437
+ p = self.ctx.resolve(cand)
2438
+ found = p.exists()
2439
+ except (ToolError, OSError, ValueError):
2440
+ continue
2441
+ if found:
2136
2442
  paths.append(p)
2137
2443
  break
2138
2444
  for p in paths:
@@ -733,10 +733,12 @@ def run_print(agent, ui, client, prompt: str, args, session) -> int:
733
733
  err.message = message
734
734
  code = _report(ui, err) # message on stderr in both formats
735
735
  message = err.message
736
- elif res.stop_reason in ("max_turns", "loop", "budget"):
736
+ elif res.stop_reason in ("max_turns", "loop", "stuck", "budget"):
737
737
  code = EXIT_MAX_TURNS
738
738
  message = (f"Stopped after --max-turns {args.max_turns}." if args.max_turns and res.stop_reason == "max_turns"
739
739
  else "Stopped: the model kept repeating the same call." if res.stop_reason == "loop"
740
+ else f"Stopped: no progress ({agent._stuck}); see the summary of what blocks it."
741
+ if res.stop_reason == "stuck"
740
742
  else "Stopped at the time / step budget after a summary of what is done and left (--no-budget "
741
743
  "turns it off)." if res.stop_reason == "budget"
742
744
  else f"Stopped after {res.turns} steps (the step budget; raise it with --max-turns or "
@@ -761,6 +763,9 @@ def run_print(agent, ui, client, prompt: str, args, session) -> int:
761
763
  "reuse": agent.reuse_report(),
762
764
  "task_id": client.task_id,
763
765
  "commands": [{"command": c, "exit_code": code_} for _, c, code_ in agent.ledger["commands"]],
766
+ "verified": agent._verified() if agent.ledger["edits"] else None,
767
+ "guard": dict(agent.guard.summary(), done_nudges=agent._done_nudges,
768
+ rolled_back=list(agent._rolled_back)),
764
769
  "usage": {"prompt_tokens": t.session_prompt, "completion_tokens": t.session_completion,
765
770
  "total_tokens": t.session_total, "requests": t.requests,
766
771
  "cached_tokens": t.session_cached, "saved_tokens": agent.savings.tokens()},
@@ -67,6 +67,26 @@ def add_notice(root: Path, source: str, license_id: str, url: str = "", files: s
67
67
  return path
68
68
 
69
69
 
70
+ def remove_notice(root: Path, source: str) -> bool:
71
+ """Drop `source`'s entry from THIRD_PARTY_NOTICES.md (its code was rolled back). The file goes when it is
72
+ left with no entry. True when an entry was removed."""
73
+ path = root / NOTICES_FILE
74
+ if not path.exists():
75
+ return False
76
+ text = path.read_text(encoding="utf-8")
77
+ heading = f"## {source}\n"
78
+ if heading not in text:
79
+ return False
80
+ start = text.index(heading)
81
+ nxt = text.find("\n## ", start + len(heading))
82
+ text = text[:start].rstrip("\n") + "\n" + (text[nxt + 1:] if nxt != -1 else "")
83
+ if "\n## " not in "\n" + text:
84
+ path.unlink()
85
+ else:
86
+ path.write_text(text.rstrip("\n") + "\n", encoding="utf-8")
87
+ return True
88
+
89
+
70
90
  MPL_HEADER = ("This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of "
71
91
  "the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.")
72
92
  _COMMENT = {