euron-code 1.5.5__tar.gz → 1.5.7__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.
- {euron_code-1.5.5 → euron_code-1.5.7}/CHANGELOG.md +46 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/PKG-INFO +2 -2
- {euron_code-1.5.5 → euron_code-1.5.7}/README.md +1 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/pyproject.toml +1 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/__init__.py +1 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/agent.py +119 -20
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/api.py +58 -6
- euron_code-1.5.7/src/euron_code/autoupdate.py +334 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/cli.py +76 -5
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/context.py +16 -3
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/llm/base.py +1 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/llm/openai_compat.py +5 -1
- euron_code-1.5.7/src/euron_code/pasteinput.py +208 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/prompts.py +2 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/repl.py +56 -7
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/background.py +12 -4
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/fs.py +145 -3
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/ignore.py +75 -75
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/shell.py +11 -2
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/update_check.py +2 -2
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_agent_mock.py +4 -4
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_permissions.py +91 -91
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_repl.py +10 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v11_speed.py +2 -2
- euron_code-1.5.7/tests/test_v156_autoupdate.py +173 -0
- euron_code-1.5.7/tests/test_v156_paste_and_edits.py +249 -0
- euron_code-1.5.7/tests/test_v157_zero_errors.py +460 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_context.py +1 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_live_repl.py +5 -1
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_single_login.py +4 -4
- {euron_code-1.5.5 → euron_code-1.5.7}/.gitignore +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/LICENSE +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/__main__.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/activity.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/attachments.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/auth.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/builtin_skills/build-from-reference/SKILL.md +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/builtin_skills/explain-codebase/SKILL.md +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/builtin_skills/review/SKILL.md +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/builtin_skills/test-writer/SKILL.md +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/cache.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/checkpoints.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/config.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/contextforge/LICENSE +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/contextforge/__init__.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/contextforge/text.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/contextforge/toolout.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/credentials.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/doctor.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/documents.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/dotnet.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/error_hints.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/errorlog.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/friendly.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/frontmatter.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/hooks.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/keys.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/knowledge.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/licensing.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/llm/__init__.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/llm/anthropic.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/llm/setup.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/logo.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/markdown_view.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/memory.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/migration.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/mvc5.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/osscache.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/ossgithub.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/pathfix.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/permissions.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/progress.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/project_setup.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/repomap.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/rules.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/security_scan.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/sessions.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/skills.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/textsafe.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/__init__.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/base.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/db.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/document.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/erie.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/normalize.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/oss.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/pathfind.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/port.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/reuse.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/search.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/skill.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/symbols.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/task.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/todo.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/tools/web.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/transcript.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/trust.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/ui.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/usage_view.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/version_info.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/src/euron_code/webforms.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/conftest.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/fake_providers.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/helpers.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/measure_floor.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/mock_gateway.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/serve_helper.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/sim_long_session.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_api_shell.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_bench.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_bench_harness.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_cli_e2e.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_context_memory_sessions.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_dashboard_fixes.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_dashboard_fixes_102.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_db.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_erie.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_knowledge_security.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_markdown_view.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_oss_local.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_powershell_exit_codes.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_qa_attach_secrets.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_qa_long_task.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_qa_print_output.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_qa_reuse_unrelated.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_qa_yolo_outside.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_reuse_honesty.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_search.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_textsafe.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_tools_fs.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_transcript_ui.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_update_check.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v111_user_reports.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v113_fix_path.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v11_byo.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v11_tool_fixes.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v130_cut_writes.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v130_reliability.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v140_parity.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v152_migration.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v153_user_errors.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v155_user_errors.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v15_hosted_models.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v15_reuse_off_subagent_hooks.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v2_rules_skills_hooks.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v2_tokens_shortcuts.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v2_usage_headers.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v31_security.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_accounts_value_setup.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_activity.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v3_attachments.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v4.py +0 -0
- {euron_code-1.5.5 → euron_code-1.5.7}/tests/test_v5.py +0 -0
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.7 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
No errors to act on: what went wrong for people this week is now handled by Euron Code itself.
|
|
6
|
+
|
|
7
|
+
- A dropped connection or a cut stream in the middle of an answer (long sessions, "The answer stopped before it
|
|
8
|
+
finished", "peer closed connection", WinError 10054) is picked up again by itself, with one short line
|
|
9
|
+
("Connection dropped, resuming..."). Nothing is applied twice: tools only run once an answer is complete, and an
|
|
10
|
+
answer that ends without its last part is never taken as whole. A connection that is down for a while (Wi-Fi
|
|
11
|
+
switching, "getaddrinfo failed") is retried for about a minute and a half.
|
|
12
|
+
- A full queue ("You already have a request running and one waiting", "Euron Code is very busy") is waited out, for
|
|
13
|
+
up to about 10 minutes, for the main agent and for sub-agents. Parallel sub-agents never send more requests than
|
|
14
|
+
your account may have at once, and a sub-agent stopped by a busy server continues where it was instead of failing.
|
|
15
|
+
- A conversation too long for the model is summarised and shortened automatically before it is sent, and again if
|
|
16
|
+
the server still says it is too long; the summary request itself shrinks when it is too long.
|
|
17
|
+
- Signed in on another device: one question, "Sign in here and continue?", then your message carries on.
|
|
18
|
+
- Your own model: a provider that signs each tool call no longer stops with "Function call is missing a
|
|
19
|
+
thought_signature" on steps answered by another model or saved by an older version.
|
|
20
|
+
- Never more than 128 tool definitions in one request.
|
|
21
|
+
- Edits whose text differs from the file only in spaces, tabs or line breaks are applied (in the file's own
|
|
22
|
+
indentation) instead of being refused. Writing a `.gitignore` (or another ignore file) that already existed keeps
|
|
23
|
+
the rules your new content left out; writing a file that keeps every line of the old one goes through at once.
|
|
24
|
+
- Network problems are described in plain words, never as socket or library messages.
|
|
25
|
+
|
|
26
|
+
## 1.5.6 (2026-11-11)
|
|
27
|
+
|
|
28
|
+
Fixes from this week's usage review.
|
|
29
|
+
|
|
30
|
+
- Euron Code now keeps itself up to date. When a newer release is out (checked at most every 6 hours), `euron`
|
|
31
|
+
installs it into the same Python it runs from (venv, pipx, user or system install) and starts your command
|
|
32
|
+
again on it, so you carry on without doing anything. When Euron's servers ask for a newer version mid-session,
|
|
33
|
+
it updates and continues the conversation. If the update cannot run (offline, no permission) you stay on your
|
|
34
|
+
version with one line saying how to update. Turn it off with `euron config set autoUpdate false` or
|
|
35
|
+
`EURON_NO_AUTO_UPDATE=1`.
|
|
36
|
+
|
|
37
|
+
- Pasting several lines (a spec, a list, a SQL `CREATE TABLE`) sends them as ONE message. Before, the Windows
|
|
38
|
+
console (cmd, PowerShell) and Git Bash sent every line as its own task. Works in the normal prompt and the
|
|
39
|
+
simple one (Git Bash, IDE consoles), on Windows, macOS and Linux. Lines you type one by one stay separate
|
|
40
|
+
messages.
|
|
41
|
+
- Output never stops on a character your terminal cannot show (an ASCII-only locale now writes UTF-8), and
|
|
42
|
+
Python scripts Euron Code runs for you print UTF-8 too.
|
|
43
|
+
- A failed command's hint no longer breaks if Euron Code is updated while a session runs ("No module named
|
|
44
|
+
'euron_code.error_hints'").
|
|
45
|
+
- Edits: when the text to replace is not in the file, a small file comes back with the error, so the next try
|
|
46
|
+
uses the real text instead of another read. The agent is told more firmly to read a file before editing it
|
|
47
|
+
and never to type the text to replace from memory.
|
|
48
|
+
|
|
3
49
|
## 1.5.5 (2026-11-11)
|
|
4
50
|
|
|
5
51
|
Fixes for errors people met this week.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: euron-code
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.7
|
|
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>
|
|
@@ -772,7 +772,7 @@ number; inside a session use `/version` or `/status`.
|
|
|
772
772
|
| `paused for you until` | too many rejected requests in a few minutes; wait until the time shown |
|
|
773
773
|
| `Images aren't available right now` | the image service is off; describe the picture in text |
|
|
774
774
|
| `untrusted project hook(s)` | the folder has hooks you have not approved; run `euron` there interactively once to review them |
|
|
775
|
-
| `
|
|
775
|
+
| `Connection dropped, resuming...` | the connection dropped mid-answer; Euron Code asks again by itself and nothing is applied twice. If it keeps dropping, your message is kept: send `/retry` |
|
|
776
776
|
| `Cannot reach Euron Code ... WinError 10054` (connection forcibly closed) | your network reset the connection (often a broken IPv6 route, a VPN, a proxy or an antivirus web shield). 1.1.1 and later retry and switch to IPv4 by themselves; you can force it with `EURON_IPV4=1`. If it still fails, allow euron.one in the VPN/antivirus and run `euron doctor` |
|
|
777
777
|
| `pip install -U euron-code` did not change the version | pip updated a different Python. `euron version` prints the exact upgrade command for the Python that runs `euron` |
|
|
778
778
|
| `Client_Requirement_Document.docx looks like a binary file` | fixed in 1.1.1: Word, Excel, PowerPoint and PDF files are read as text |
|
|
@@ -706,7 +706,7 @@ number; inside a session use `/version` or `/status`.
|
|
|
706
706
|
| `paused for you until` | too many rejected requests in a few minutes; wait until the time shown |
|
|
707
707
|
| `Images aren't available right now` | the image service is off; describe the picture in text |
|
|
708
708
|
| `untrusted project hook(s)` | the folder has hooks you have not approved; run `euron` there interactively once to review them |
|
|
709
|
-
| `
|
|
709
|
+
| `Connection dropped, resuming...` | the connection dropped mid-answer; Euron Code asks again by itself and nothing is applied twice. If it keeps dropping, your message is kept: send `/retry` |
|
|
710
710
|
| `Cannot reach Euron Code ... WinError 10054` (connection forcibly closed) | your network reset the connection (often a broken IPv6 route, a VPN, a proxy or an antivirus web shield). 1.1.1 and later retry and switch to IPv4 by themselves; you can force it with `EURON_IPV4=1`. If it still fails, allow euron.one in the VPN/antivirus and run `euron doctor` |
|
|
711
711
|
| `pip install -U euron-code` did not change the version | pip updated a different Python. `euron version` prints the exact upgrade command for the Python that runs `euron` |
|
|
712
712
|
| `Client_Requirement_Document.docx looks like a binary file` | fixed in 1.1.1: Word, Excel, PowerPoint and PDF files are read as text |
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "euron-code"
|
|
7
|
-
version = "1.5.
|
|
7
|
+
version = "1.5.7"
|
|
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"
|
|
@@ -35,8 +35,19 @@ from euron_code.tools.todo import render_todos
|
|
|
35
35
|
BUSY_BACKOFF = [3, 5, 10, 15, 20, 30, 40, 60, 60] # about 4 minutes in all before the turn pauses
|
|
36
36
|
RATE_LIMIT_FALLBACK = 20
|
|
37
37
|
MAX_RATE_LIMIT_RETRIES = 5
|
|
38
|
-
NETWORK_BACKOFF = [2, 4, 8]
|
|
39
|
-
MIDSTREAM_BACKOFF = [1,
|
|
38
|
+
NETWORK_BACKOFF = [2, 4, 8, 15, 30, 30] # about 90 s of reconnecting (Wi-Fi switch, VPN reconnect) before giving up
|
|
39
|
+
MIDSTREAM_BACKOFF = [1, 2, 4, 8, 15, 30] # automatic retries after a stream dropped part-way
|
|
40
|
+
# The queue is full or long (429 user_queue_full, 503 queue_timeout / queue_full / no_capacity): Euron Code waits its
|
|
41
|
+
# turn, up to about 10 minutes, instead of failing the request or a sub-agent's task (1.5.7)
|
|
42
|
+
QUEUE_BACKOFF = [2, 5, 10, 15, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
43
|
+
QUEUE_CODES = {"user_queue_full", "queue_timeout", "queue_full", "no_capacity"}
|
|
44
|
+
SUBAGENT_RESUMES = 2 # a sub-agent stopped by a busy server or a dropped connection continues this many times
|
|
45
|
+
MAX_TOOLS_PER_REQUEST = 128 # servers refuse more tool definitions than this in one request
|
|
46
|
+
#: tools that are never dropped when the list has to be cut to MAX_TOOLS_PER_REQUEST
|
|
47
|
+
CORE_TOOLS = ("read_file", "write_file", "edit_file", "multi_edit", "list_dir", "glob", "grep", "bash", "todo_write",
|
|
48
|
+
"task", "skill", "read_document", "find_symbol", "delete_file", "move_file", "start_background_process",
|
|
49
|
+
"read_process_output", "stop_process", "check_app", "web_fetch", "db_query", "port_page",
|
|
50
|
+
"create_mvc5_project")
|
|
40
51
|
SESSION_IN_USE_WAIT = 3 # a 409 right after a restart is usually this computer's own previous session
|
|
41
52
|
FIT_TARGET = 0.8 # never send a prompt above 80% of the window (estimate); shrink the history first
|
|
42
53
|
# Compaction (1.1.0). Thresholds are fractions of the CONVERSATION room (usable window minus the fixed floor:
|
|
@@ -803,7 +814,9 @@ class Agent:
|
|
|
803
814
|
return self.context_usage() * 100 // self.usable_window
|
|
804
815
|
|
|
805
816
|
def room_for_output(self) -> int:
|
|
806
|
-
|
|
817
|
+
# 5% safety on the estimate: prompt + max_tokens over the window is a 400 context_length_exceeded
|
|
818
|
+
# (the hosted 32K model, 1.5.7)
|
|
819
|
+
return self.window - int(self.context_usage() * 1.05) - FIT_MARGIN
|
|
807
820
|
|
|
808
821
|
@property
|
|
809
822
|
def effort(self) -> str:
|
|
@@ -840,7 +853,7 @@ class Agent:
|
|
|
840
853
|
payload = {
|
|
841
854
|
"model": self.model,
|
|
842
855
|
"messages": self.messages,
|
|
843
|
-
"tools": self.tool_schemas,
|
|
856
|
+
"tools": cap_tools(self.tool_schemas),
|
|
844
857
|
"tool_choice": getattr(self, "_tool_choice_once", None) or "auto",
|
|
845
858
|
"max_tokens": max_tokens,
|
|
846
859
|
"reasoning_effort": self._next_effort(),
|
|
@@ -855,6 +868,7 @@ class Agent:
|
|
|
855
868
|
dropped connections, a too-long context. Each waits (Esc stops it) and asks again; the turn is never
|
|
856
869
|
lost: if it still fails, the conversation is kept and /retry continues it."""
|
|
857
870
|
busy = 0
|
|
871
|
+
queued = 0
|
|
858
872
|
rate = 0
|
|
859
873
|
net = 0
|
|
860
874
|
compacted = 0
|
|
@@ -875,9 +889,9 @@ class Agent:
|
|
|
875
889
|
raise
|
|
876
890
|
wait = MIDSTREAM_BACKOFF[dropped]
|
|
877
891
|
dropped += 1
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
self._wait(wait,
|
|
892
|
+
# one short status line, no error: the answer is asked for again from the same point
|
|
893
|
+
self.ui.dim(f"Connection dropped, resuming... ({dropped}/{len(MIDSTREAM_BACKOFF)})")
|
|
894
|
+
self._wait(wait, "Connection dropped, resuming.")
|
|
881
895
|
except api.SessionInUseError:
|
|
882
896
|
if not self.uses_euron:
|
|
883
897
|
raise
|
|
@@ -899,6 +913,25 @@ class Agent:
|
|
|
899
913
|
self._wait(min(float(wait), 120.0), "Rate limit reached (requests per minute)." if self.uses_euron
|
|
900
914
|
else f"{who}: rate limit reached.")
|
|
901
915
|
except BusyError as e:
|
|
916
|
+
if str(e.code or "") in QUEUE_CODES:
|
|
917
|
+
# the queue is full or long: wait our turn (a sub-agent's task must not fail on this)
|
|
918
|
+
if queued >= len(QUEUE_BACKOFF):
|
|
919
|
+
raise EuronError(
|
|
920
|
+
f"The {who} has been very busy for about 10 minutes. Your message is kept: send /retry to "
|
|
921
|
+
"continue" + (", or switch model with /model." if self.uses_euron else "."),
|
|
922
|
+
status=e.status, code=e.code)
|
|
923
|
+
wait = float(QUEUE_BACKOFF[queued])
|
|
924
|
+
if e.code == "user_queue_full" and queued == 0:
|
|
925
|
+
wait = 1.0 # usually the gateway still releasing the previous slot right after [DONE]
|
|
926
|
+
if e.retry_after is not None:
|
|
927
|
+
wait = max(wait, min(float(e.retry_after), 60.0))
|
|
928
|
+
queued += 1
|
|
929
|
+
why = {"user_queue_full": "your previous request is still finishing",
|
|
930
|
+
"queue_timeout": "the queue is long", "queue_full": "the queue is full",
|
|
931
|
+
"no_capacity": "all servers are in use"}[str(e.code)]
|
|
932
|
+
self._wait(wait, f"The {who} is busy ({why}); waiting for a turn." if self.uses_euron
|
|
933
|
+
else f"{who} is busy; waiting for a turn.")
|
|
934
|
+
continue
|
|
902
935
|
if busy >= len(BUSY_BACKOFF):
|
|
903
936
|
msg = (f"The {who} is still busy after {busy} tries over a few minutes. Your message is kept: "
|
|
904
937
|
"send /retry to try again" if self.uses_euron else
|
|
@@ -924,21 +957,22 @@ class Agent:
|
|
|
924
957
|
raise
|
|
925
958
|
self.ui.warn("Images aren't available right now; describe it in text. Sent the message without them.")
|
|
926
959
|
except ContextTooLongError as e:
|
|
927
|
-
if not allow_compact or compacted >=
|
|
960
|
+
if not allow_compact or compacted >= 4:
|
|
928
961
|
raise
|
|
929
962
|
compacted += 1
|
|
930
963
|
self._calibrate_from(e)
|
|
931
|
-
self.ui.dim("The conversation is too long for the model; making room and asking again.")
|
|
932
964
|
if compacted == 1:
|
|
965
|
+
self.ui.dim("The conversation is too long for the model; summarising older messages and "
|
|
966
|
+
"asking again.")
|
|
933
967
|
self.compact(force=True)
|
|
934
|
-
|
|
968
|
+
# each try leaves more room: 65%, 50%, 35%, 30% of the window
|
|
969
|
+
self.fit_to_window(target=max(0.3, FIT_TARGET - 0.15 * compacted))
|
|
935
970
|
except NetworkError:
|
|
936
971
|
if net >= len(NETWORK_BACKOFF):
|
|
937
972
|
raise
|
|
938
973
|
wait = NETWORK_BACKOFF[net]
|
|
939
974
|
net += 1
|
|
940
|
-
self._wait(wait,
|
|
941
|
-
else f"Network problem talking to {who}.")
|
|
975
|
+
self._wait(wait, "Connection lost, reconnecting.")
|
|
942
976
|
|
|
943
977
|
def _calibrate_from(self, e: ContextTooLongError) -> None:
|
|
944
978
|
"""The server said how big the prompt really was: learn the ratio, and the true window."""
|
|
@@ -1131,8 +1165,8 @@ class Agent:
|
|
|
1131
1165
|
else:
|
|
1132
1166
|
self.ui.end_response()
|
|
1133
1167
|
err = MidStreamError(
|
|
1134
|
-
|
|
1135
|
-
"
|
|
1168
|
+
"The connection kept dropping while the answer was coming in. Nothing was applied, and "
|
|
1169
|
+
"your message is kept: send /retry to continue.", status=e.status, code=e.code)
|
|
1136
1170
|
err.retryable = dropped
|
|
1137
1171
|
raise err from None
|
|
1138
1172
|
else:
|
|
@@ -2555,15 +2589,26 @@ class Agent:
|
|
|
2555
2589
|
self._phase("compacting the conversation")
|
|
2556
2590
|
self.ui.waiting("Compacting conversation...")
|
|
2557
2591
|
summary = ""
|
|
2558
|
-
|
|
2592
|
+
i = 0
|
|
2593
|
+
shrinks = 0
|
|
2594
|
+
while i < len(payloads):
|
|
2595
|
+
payload = payloads[i]
|
|
2559
2596
|
last = i == len(payloads) - 1
|
|
2597
|
+
i += 1
|
|
2560
2598
|
try:
|
|
2561
2599
|
data = self._with_retries(lambda: self.llm.chat(payload), allow_compact=False)
|
|
2562
2600
|
except EuronError as e:
|
|
2563
2601
|
if not last and not isinstance(e, (api.AuthError, api.NotEntitledError, api.QuotaExceededError)):
|
|
2564
2602
|
continue # the prefix-cached form failed (too long, refused): the transcript form next
|
|
2603
|
+
if isinstance(e, ContextTooLongError) and shrinks < 2:
|
|
2604
|
+
# the transcript itself was too long for the model: summarise its later half (1.5.7)
|
|
2605
|
+
shrinks += 1
|
|
2606
|
+
self._calibrate_from(e)
|
|
2607
|
+
payloads.append(self._transcript_summary_payload(old, summary_cap, instructions,
|
|
2608
|
+
share=0.5 ** shrinks))
|
|
2609
|
+
continue
|
|
2565
2610
|
self.ui.end_response()
|
|
2566
|
-
self.ui.
|
|
2611
|
+
self.ui.dim("Shortened older messages instead of summarising them.")
|
|
2567
2612
|
context.elide_old_tool_outputs(self.messages, keep_last=2, min_chars=300)
|
|
2568
2613
|
self._persist_compaction()
|
|
2569
2614
|
self._summary_step, self._after_summary = self.steps, self.context_usage() # do not retry at once
|
|
@@ -2578,7 +2623,7 @@ class Agent:
|
|
|
2578
2623
|
summary = "" # it tried to keep working instead of summarising: ask the transcript way
|
|
2579
2624
|
self.ui.end_response()
|
|
2580
2625
|
if not summary:
|
|
2581
|
-
self.ui.
|
|
2626
|
+
self.ui.dim("The summary came back empty; keeping the conversation as it was.")
|
|
2582
2627
|
return False
|
|
2583
2628
|
head = "[Summary of the earlier part of this conversation]\n" + summary
|
|
2584
2629
|
changed = self._files_changed()
|
|
@@ -2650,9 +2695,9 @@ class Agent:
|
|
|
2650
2695
|
"tools": self.tool_schemas, "tool_choice": "none"}
|
|
2651
2696
|
|
|
2652
2697
|
def _transcript_summary_payload(self, old: List[Dict[str, Any]], cap: int,
|
|
2653
|
-
instructions: Optional[str]) -> Dict[str, Any]:
|
|
2698
|
+
instructions: Optional[str], share: float = 1.0) -> Dict[str, Any]:
|
|
2654
2699
|
transcript = context.render_transcript(old)
|
|
2655
|
-
max_in_chars = int((self.window - 3000) * context.CHARS_PER_TOKEN * 0.8)
|
|
2700
|
+
max_in_chars = int((self.window - 3000) * context.CHARS_PER_TOKEN * 0.8 * share / max(1.0, self.tokens.ratio))
|
|
2656
2701
|
if len(transcript) > max_in_chars:
|
|
2657
2702
|
transcript = transcript[-max_in_chars:]
|
|
2658
2703
|
ask = "Summarise this conversation so far.\n\n<transcript>\n" + transcript + "\n</transcript>"
|
|
@@ -2889,6 +2934,25 @@ class Agent:
|
|
|
2889
2934
|
except Exception:
|
|
2890
2935
|
pass
|
|
2891
2936
|
res = sub.run_turn(prompt)
|
|
2937
|
+
resumes = 0
|
|
2938
|
+
while (res.error is not None and _transient(res.error) and resumes < SUBAGENT_RESUMES
|
|
2939
|
+
and not self.cancel.is_set()):
|
|
2940
|
+
# a busy server or a dropped connection after all its own retries: wait a little, then the
|
|
2941
|
+
# sub-agent continues from where it stopped (nothing it did is repeated)
|
|
2942
|
+
resumes += 1
|
|
2943
|
+
self.ui.dim(f"Sub-agent paused (server busy or connection lost); continuing ({resumes}).")
|
|
2944
|
+
try:
|
|
2945
|
+
sub._wait(15.0 * resumes, "Waiting before the sub-agent continues.")
|
|
2946
|
+
except Interrupted:
|
|
2947
|
+
break
|
|
2948
|
+
task_id = self.client.task_id
|
|
2949
|
+
try:
|
|
2950
|
+
again = sub.retry_last()
|
|
2951
|
+
finally:
|
|
2952
|
+
self.client.task_id = task_id # the same request for the gateway's usage, not a new one
|
|
2953
|
+
if again is None:
|
|
2954
|
+
break
|
|
2955
|
+
res = again
|
|
2892
2956
|
finally:
|
|
2893
2957
|
if mode == "write":
|
|
2894
2958
|
with self._lock:
|
|
@@ -2908,7 +2972,12 @@ class Agent:
|
|
|
2908
2972
|
self.ledger["edits"] += [(self.steps, rel) for _, rel in sub.ledger["edits"]]
|
|
2909
2973
|
self.ledger["commands"] += [(self.steps, c, code) for _, c, code in sub.ledger["commands"]]
|
|
2910
2974
|
if res.error is not None:
|
|
2911
|
-
|
|
2975
|
+
if not _transient(res.error):
|
|
2976
|
+
raise ToolError(f"Sub-agent failed: {res.error.message}")
|
|
2977
|
+
# not an error for the user: the model is told to carry on with this part itself
|
|
2978
|
+
done = (res.text or "").strip()
|
|
2979
|
+
return ((done + "\n\n" if done else "") + "[The sub-agent could not finish: the model stayed busy or the "
|
|
2980
|
+
"connection kept dropping. Continue this part yourself.]")
|
|
2912
2981
|
if res.stop_reason == "interrupted":
|
|
2913
2982
|
raise KeyboardInterrupt()
|
|
2914
2983
|
text = res.text.strip() or "(the sub-agent returned no answer)"
|
|
@@ -2990,6 +3059,36 @@ def _friendly_os_error(tool: str, e: BaseException) -> str:
|
|
|
2990
3059
|
return f"Error: {tool} failed: {type(e).__name__}: {e}"
|
|
2991
3060
|
|
|
2992
3061
|
|
|
3062
|
+
def _transient(e: BaseException) -> bool:
|
|
3063
|
+
"""A failure that waiting fixes (busy server, rate limit, dropped connection), not one the user must act on."""
|
|
3064
|
+
return isinstance(e, (BusyError, NetworkError, MidStreamError, RateLimitedError)) or \
|
|
3065
|
+
str(getattr(e, "code", "") or "") in QUEUE_CODES
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
def cap_tools(schemas: List[Dict[str, Any]], limit: int = MAX_TOOLS_PER_REQUEST) -> List[Dict[str, Any]]:
|
|
3069
|
+
"""At most `limit` tool definitions (a server refuses more: "At most 128 tools per request."). The core tools
|
|
3070
|
+
are always kept; of the rest, the first ones in the list (the built-in order) stay. The model is not told."""
|
|
3071
|
+
if len(schemas) <= limit:
|
|
3072
|
+
return schemas
|
|
3073
|
+
|
|
3074
|
+
def name(x: Dict[str, Any]) -> str:
|
|
3075
|
+
return str((x.get("function") or {}).get("name") or x.get("name") or "")
|
|
3076
|
+
|
|
3077
|
+
seen, keep = set(), []
|
|
3078
|
+
for x in schemas: # duplicates first: the same name twice is never useful
|
|
3079
|
+
n = name(x)
|
|
3080
|
+
if n and n in seen:
|
|
3081
|
+
continue
|
|
3082
|
+
seen.add(n)
|
|
3083
|
+
keep.append(x)
|
|
3084
|
+
if len(keep) <= limit:
|
|
3085
|
+
return keep
|
|
3086
|
+
core = [x for x in keep if name(x) in CORE_TOOLS][:limit]
|
|
3087
|
+
rest = [x for x in keep if name(x) not in CORE_TOOLS][:max(0, limit - len(core))]
|
|
3088
|
+
chosen = {id(x) for x in core + rest}
|
|
3089
|
+
return [x for x in keep if id(x) in chosen]
|
|
3090
|
+
|
|
3091
|
+
|
|
2993
3092
|
def _has_tool_calls(data: Dict[str, Any]) -> bool:
|
|
2994
3093
|
try:
|
|
2995
3094
|
return bool(data["choices"][0]["message"].get("tool_calls"))
|
|
@@ -314,6 +314,7 @@ def device_id() -> Optional[str]:
|
|
|
314
314
|
# in this process uses IPv4, and so do later runs (remembered in ~/.euron/network.json). EURON_IPV4=1 forces it.
|
|
315
315
|
_FORCE_IPV4: Optional[bool] = None
|
|
316
316
|
NET_RETRY_WAITS = (0.6, 1.5, 3.0)
|
|
317
|
+
REQUEST_SLOTS = 2 # model requests one account may have at the gateway at once (one running, one queued)
|
|
317
318
|
NETWORK_HINT = (" Check your internet connection. If a VPN, proxy or antivirus web shield is on, allow euron.one "
|
|
318
319
|
"or turn it off for a moment, then run `euron doctor`.")
|
|
319
320
|
|
|
@@ -354,6 +355,30 @@ def is_dropped_connection(e: BaseException) -> bool:
|
|
|
354
355
|
httpx.ProxyError))
|
|
355
356
|
|
|
356
357
|
|
|
358
|
+
def describe_network_problem(e: BaseException) -> str:
|
|
359
|
+
"""What went wrong with the connection, in plain words (never the raw socket / httpx text, which said things
|
|
360
|
+
like "[Errno 11001] getaddrinfo failed" or "peer closed connection without sending complete message body")."""
|
|
361
|
+
low = f"{type(e).__name__} {e}".lower()
|
|
362
|
+
if isinstance(e, httpx.TimeoutException) or "timed out" in low or "timeout" in low:
|
|
363
|
+
return "the connection timed out"
|
|
364
|
+
if any(k in low for k in ("getaddrinfo", "name or service not known", "nodename nor servname",
|
|
365
|
+
"temporary failure in name resolution", "no address associated", "11001", "11004")):
|
|
366
|
+
return "this computer could not look up the server's address (no internet connection, or a DNS problem)"
|
|
367
|
+
if any(k in low for k in ("certificate", "ssl", "tls")):
|
|
368
|
+
return ("a secure connection could not be set up (a proxy, VPN or antivirus may be inspecting HTTPS, or the "
|
|
369
|
+
"computer's clock is wrong)")
|
|
370
|
+
if any(k in low for k in ("refused", "10061")):
|
|
371
|
+
return "the connection was refused"
|
|
372
|
+
if any(k in low for k in ("10054", "reset", "peer closed", "incomplete chunked", "remoteprotocolerror",
|
|
373
|
+
"connection aborted", "10053", "broken pipe", "server disconnected")):
|
|
374
|
+
return "the network dropped the connection"
|
|
375
|
+
if any(k in low for k in ("network is unreachable", "10051", "10065", "no route")):
|
|
376
|
+
return "the network is unreachable (no internet connection?)"
|
|
377
|
+
if "proxy" in low:
|
|
378
|
+
return "the proxy refused the connection"
|
|
379
|
+
return "the connection failed"
|
|
380
|
+
|
|
381
|
+
|
|
357
382
|
def user_agent() -> str:
|
|
358
383
|
return f"euron-code/{__version__} ({platform.system()}; Python {platform.python_version()})"
|
|
359
384
|
|
|
@@ -373,6 +398,10 @@ class Client:
|
|
|
373
398
|
self._transport = transport
|
|
374
399
|
self._is_clone = False
|
|
375
400
|
self._lock = threading.Lock() # one model request at a time
|
|
401
|
+
# The gateway runs one request per account and queues one more; a third is refused (429
|
|
402
|
+
# user_queue_full). The main agent and its parallel sub-agents (clones) share these slots, so
|
|
403
|
+
# Euron Code itself never sends that third request (1.5.7).
|
|
404
|
+
self._slots = threading.BoundedSemaphore(REQUEST_SLOTS)
|
|
376
405
|
self._ipv4 = False
|
|
377
406
|
self._http = self._make_http()
|
|
378
407
|
|
|
@@ -405,6 +434,7 @@ class Client:
|
|
|
405
434
|
c = Client(api_key=self.api_key, base_url=self.base_url, transport=getattr(self, "_transport", None))
|
|
406
435
|
c.session_id, c.task_id = self.session_id, self.task_id
|
|
407
436
|
c._is_clone = True
|
|
437
|
+
c._slots = self._slots
|
|
408
438
|
return c
|
|
409
439
|
|
|
410
440
|
def release_session(self) -> None:
|
|
@@ -452,14 +482,15 @@ class Client:
|
|
|
452
482
|
try:
|
|
453
483
|
return self._http.request(method, self.base_url + path, headers=headers, **kw)
|
|
454
484
|
except httpx.TimeoutException as e:
|
|
455
|
-
raise NetworkError(
|
|
485
|
+
raise NetworkError("Euron Code's server did not answer in time." + NETWORK_HINT) from None
|
|
456
486
|
except httpx.HTTPError as e:
|
|
457
487
|
if not is_dropped_connection(e):
|
|
458
|
-
raise NetworkError(f"Cannot reach Euron Code
|
|
488
|
+
raise NetworkError(f"Cannot reach Euron Code: {describe_network_problem(e)}."
|
|
489
|
+
+ NETWORK_HINT) from None
|
|
459
490
|
last = e
|
|
460
491
|
self._after_drop()
|
|
461
|
-
raise NetworkError(f"Cannot reach Euron Code
|
|
462
|
-
"times)." + NETWORK_HINT)
|
|
492
|
+
raise NetworkError(f"Cannot reach Euron Code: {describe_network_problem(last or Exception())} (tried "
|
|
493
|
+
f"{len(NET_RETRY_WAITS) + 1} times)." + NETWORK_HINT)
|
|
463
494
|
|
|
464
495
|
def _json(self, method: str, path: str, **kw: Any) -> Any:
|
|
465
496
|
resp = self._request(method, path, **kw)
|
|
@@ -596,7 +627,7 @@ class Client:
|
|
|
596
627
|
|
|
597
628
|
def chat(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
598
629
|
"""Non-streaming completion (used for compaction summaries)."""
|
|
599
|
-
with self._lock:
|
|
630
|
+
with self._lock, self._slots:
|
|
600
631
|
body = textsafe.clean_obj(dict(payload, messages=wire_messages(payload.get("messages") or [])))
|
|
601
632
|
body["stream"] = False
|
|
602
633
|
data = self._json("POST", "/v1/chat/completions", json=body, headers=self._chat_headers())
|
|
@@ -612,6 +643,13 @@ class Client:
|
|
|
612
643
|
"""
|
|
613
644
|
if not self._lock.acquire(blocking=False):
|
|
614
645
|
raise EuronError("Internal error: a model request is already running.")
|
|
646
|
+
# wait for a free slot (other sub-agents' requests are running / queued); Esc still works
|
|
647
|
+
while not self._slots.acquire(timeout=0.1):
|
|
648
|
+
if cancel is not None and cancel.is_set():
|
|
649
|
+
self._lock.release()
|
|
650
|
+
raise Interrupted()
|
|
651
|
+
if on_wait:
|
|
652
|
+
on_wait(None)
|
|
615
653
|
q: "queue.Queue[Tuple[str, Any]]" = queue.Queue()
|
|
616
654
|
holder: Dict[str, Any] = {}
|
|
617
655
|
body = textsafe.clean_obj(dict(payload, messages=wire_messages(payload.get("messages") or [])))
|
|
@@ -631,7 +669,8 @@ class Client:
|
|
|
631
669
|
if isinstance(e, httpx.TimeoutException):
|
|
632
670
|
q.put(("error", NetworkError("The connection to Euron Code timed out.")))
|
|
633
671
|
else:
|
|
634
|
-
q.put(("error", NetworkError(
|
|
672
|
+
q.put(("error", NetworkError("Connection to Euron Code lost: "
|
|
673
|
+
f"{describe_network_problem(e)}." + NETWORK_HINT)))
|
|
635
674
|
return
|
|
636
675
|
self._after_drop()
|
|
637
676
|
time.sleep(NET_RETRY_WAITS[attempt])
|
|
@@ -656,6 +695,7 @@ class Client:
|
|
|
656
695
|
q.put(("error", _error_from_response(resp)))
|
|
657
696
|
return
|
|
658
697
|
self.takeover_once = False # this session holds the account now
|
|
698
|
+
finished = False # a finish_reason or [DONE] arrived: the answer is complete
|
|
659
699
|
for line in resp.iter_lines():
|
|
660
700
|
if cancel is not None and cancel.is_set():
|
|
661
701
|
return
|
|
@@ -677,7 +717,18 @@ class Client:
|
|
|
677
717
|
q.put(("error", error_from_body(int(obj["error"].get("status") or 500)
|
|
678
718
|
if isinstance(obj["error"], dict) else 500, obj)))
|
|
679
719
|
return
|
|
720
|
+
if isinstance(obj, dict) and any(isinstance(c, dict) and c.get("finish_reason")
|
|
721
|
+
for c in obj.get("choices") or []):
|
|
722
|
+
finished = True
|
|
680
723
|
q.put(("chunk", obj))
|
|
724
|
+
if cancel is not None and cancel.is_set():
|
|
725
|
+
return
|
|
726
|
+
if not finished:
|
|
727
|
+
# the stream ended without [DONE] or a finish_reason: the gateway or a proxy cut it (idle
|
|
728
|
+
# timeout, deploy). A cut answer is never treated as whole: the agent asks again (1.5.7)
|
|
729
|
+
q.put(("error", BusyError("The answer stopped before it finished.", status=502,
|
|
730
|
+
code="upstream_stream_cut")))
|
|
731
|
+
return
|
|
681
732
|
q.put(("done", None))
|
|
682
733
|
|
|
683
734
|
t = threading.Thread(target=worker, name="euron-stream", daemon=True)
|
|
@@ -709,6 +760,7 @@ class Client:
|
|
|
709
760
|
except Exception:
|
|
710
761
|
pass
|
|
711
762
|
t.join(timeout=2.0)
|
|
763
|
+
self._slots.release()
|
|
712
764
|
self._lock.release()
|
|
713
765
|
|
|
714
766
|
|