assistant 2.2.0b1__tar.gz → 2.2.2b1__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.
- {assistant-2.2.0b1/assistant.egg-info → assistant-2.2.2b1}/PKG-INFO +58 -7
- {assistant-2.2.0b1 → assistant-2.2.2b1}/README.md +56 -6
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/__init__.py +6 -1
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/agent.py +161 -30
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/builtin_cmds.py +585 -79
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/config.py +46 -0
- assistant-2.2.2b1/assistant/display.py +134 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/listen/interface.py +6 -7
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/main.py +65 -163
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/memory.py +87 -3
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/__init__.py +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/google.py +2 -1
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/llama_cpp.py +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/nim.py +2 -1
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/ollama.py +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/openai.py +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/providers/openrouter.py +8 -3
- assistant-2.2.2b1/assistant/nlp/providers/vllm.py +38 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/shell.py +656 -129
- assistant-2.2.2b1/assistant/ptk_shell/toolbox.py +132 -0
- assistant-2.2.2b1/assistant/search_objects.py +230 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/setup_wizard.py +108 -15
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/tools.py +259 -33
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/traces/cmd.py +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/traces/store.py +127 -40
- {assistant-2.2.0b1 → assistant-2.2.2b1/assistant.egg-info}/PKG-INFO +58 -7
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant.egg-info/SOURCES.txt +9 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant.egg-info/requires.txt +1 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/setup.cfg +0 -1
- {assistant-2.2.0b1 → assistant-2.2.2b1}/setup.py +1 -0
- assistant-2.2.2b1/tests/test_builtin_cmds.py +398 -0
- assistant-2.2.2b1/tests/test_builtin_echo.py +559 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_compaction.py +114 -0
- assistant-2.2.2b1/tests/test_display.py +236 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_interrupt.py +17 -25
- assistant-2.2.2b1/tests/test_join_live.py +88 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_listen_interrupt.py +8 -8
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_memory.py +20 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_model_compare.py +1 -1
- assistant-2.2.2b1/tests/test_reasoning_effort.py +280 -0
- assistant-2.2.2b1/tests/test_search_objects.py +139 -0
- assistant-2.2.2b1/tests/test_setup_wizard.py +68 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_startup_performance.py +8 -5
- assistant-2.2.2b1/tests/test_thinking_loop.py +128 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_tool_handling.py +47 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_tools.py +131 -8
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_traces_agent.py +15 -7
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_tts_streaming.py +203 -35
- {assistant-2.2.0b1 → assistant-2.2.2b1}/xontrib/assistant.py +4 -3
- assistant-2.2.0b1/assistant/nlp/providers/vllm.py +0 -22
- assistant-2.2.0b1/tests/test_builtin_cmds.py +0 -220
- assistant-2.2.0b1/tests/test_setup_wizard.py +0 -22
- {assistant-2.2.0b1 → assistant-2.2.2b1}/LICENSE +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/MANIFEST.in +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/__main__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/as_client.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/as_service.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/codecache.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/compress.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/conditions.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/entry_points/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/entry_points/run_assistant.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/envindex.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/execer.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/history.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/listen/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/listen/__main__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/listen/main.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/clear.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/exit.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/http_client.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/interface.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/message.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/think.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/nlp/xonsh.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/parser.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/projectfile.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/bindings.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/completer.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/dialogs.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/floats.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/layout.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/operators.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/strformat_utils.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/styles.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/ptk_shell/windows.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/say/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/say/interface.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/time.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/tools_worker.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/traces/__init__.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/traces/export.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/traces/schema.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/utils.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/version.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant/vocabulary.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant.egg-info/dependency_links.txt +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant.egg-info/entry_points.txt +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/assistant.egg-info/top_level.txt +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/pyproject.toml +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_bindings.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_compress.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_config.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_envindex.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_envindex_suggestions.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_git_hook.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_history_bridge.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_http_client.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_init.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_interrupt_real.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_memory_sqlite.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_projectfile.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_tmux_interactive.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_traces_cmd.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_traces_export.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_traces_schema.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_traces_store.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_utils.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/tests/test_xontrib.py +0 -0
- {assistant-2.2.0b1 → assistant-2.2.2b1}/xontrib/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: assistant
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2b1
|
|
4
4
|
Summary: Your very own Assistant. Because you deserve it.
|
|
5
5
|
Home-page: https://gitlab.com/waser-technologies/technologies/assistant
|
|
6
6
|
Author: Danny Waser
|
|
@@ -29,6 +29,7 @@ Requires-Dist: xonsh
|
|
|
29
29
|
Requires-Dist: prompt_toolkit>3.0.36
|
|
30
30
|
Requires-Dist: questionary
|
|
31
31
|
Requires-Dist: colorama
|
|
32
|
+
Requires-Dist: click
|
|
32
33
|
Requires-Dist: rich
|
|
33
34
|
Requires-Dist: halo
|
|
34
35
|
Requires-Dist: requests
|
|
@@ -126,6 +127,8 @@ pacman -S python-assistant
|
|
|
126
127
|
|
|
127
128
|
</details>
|
|
128
129
|
|
|
130
|
+
Read [Use Assistant as Your Default Shell](#use-assistant-as-your-default-shell) for more information.
|
|
131
|
+
|
|
129
132
|
### 2. Run the Configuration Wizard
|
|
130
133
|
|
|
131
134
|
On the first launch the wizard starts automatically. You can also re-run it at any time:
|
|
@@ -153,7 +156,7 @@ The configuration is saved to `~/.assistant/config.toml`.
|
|
|
153
156
|
assistant
|
|
154
157
|
```
|
|
155
158
|
|
|
156
|
-
That's it
|
|
159
|
+
That's it: you're in. Type commands, ask questions, or mix both.
|
|
157
160
|
|
|
158
161
|
---
|
|
159
162
|
|
|
@@ -434,16 +437,64 @@ Toggle shortcuts (Ctrl+O, Ctrl+Q) update the config automatically when pressed,
|
|
|
434
437
|
|
|
435
438
|
## Use Assistant as Your Default Shell
|
|
436
439
|
|
|
437
|
-
|
|
440
|
+
Assistant is a full Xonsh shell, so it reads the same RC files (`~/.config/xonsh/rc.xsh` or `~/.config/xonsh/rc.d/`) which means your existing config carries over as-is.
|
|
441
|
+
|
|
442
|
+
Read more about Xonsh [Installation Guide](https://xon.sh/install.html) and its [Run Control Files](https://xon.sh/xonshrc.html).
|
|
443
|
+
|
|
444
|
+
### Install Assistant in a Stable, Isolated Environment
|
|
445
|
+
|
|
446
|
+
(so a system Python upgrade can't break your shell)
|
|
447
|
+
|
|
448
|
+
**Example with `uv`**
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
env_root=~/.venvs
|
|
452
|
+
env_path=${env_root}/assistant
|
|
453
|
+
python_path=${env_path}/bin/python
|
|
454
|
+
mkdir -p $env_root
|
|
455
|
+
uv venv $env_path --python 3.13
|
|
456
|
+
uv pip install --python ${python_path} assistant
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
From there to update Assistant, simply run:
|
|
460
|
+
```bash
|
|
461
|
+
uv pip install --python ${python_path} -U assistant
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Create a Dedicated Terminal Profile
|
|
465
|
+
|
|
466
|
+
Since Assistant is a natural language shell and Xonsh is not ready to be fully POSIX compliant,
|
|
467
|
+
it is highly recommended that you create a dedicated profile for Assistant beside Xonsh and your other shells,
|
|
468
|
+
directly inside your terminal application,
|
|
469
|
+
where you can set Assistant as your default shell, instead of registering it for the system.
|
|
470
|
+
|
|
471
|
+
The path to Assistant is defined as shown in this example.
|
|
472
|
+
```bash
|
|
473
|
+
assistant_bin=${env_path}/bin/assistant
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
You can also create a symbolic link to Assistant in `~/.local/bin` (or any other location in `$PATH`) so that Assistant is easily accessible.
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
ln -s $assistant_bin ~/.local/bin
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Or you could add `${env_path}/bin` to your `$PATH`.
|
|
438
483
|
|
|
439
|
-
|
|
484
|
+
### Register Assistant as a Shell for the System
|
|
485
|
+
> [!WARNING]
|
|
486
|
+
> If you read the Xonsh installation guide correctly, you understand that **you shouldn't try this method** unless:
|
|
487
|
+
> 1. you know what you are doing and want to test deeper interaction with the POSIX compliance of the system
|
|
488
|
+
> 2. you are ready to assume the consequences of potentially triggering multiple inference calls every time the system executes a command that exits with a non-zero code.
|
|
489
|
+
>
|
|
490
|
+
> Do the following at your own risk.
|
|
440
491
|
|
|
441
492
|
```bash
|
|
442
|
-
sudo sh -c
|
|
443
|
-
chsh -s $
|
|
493
|
+
sudo sh -c "echo ${assistant_bin} >> /etc/shells"
|
|
494
|
+
chsh -s $assistant_bin
|
|
444
495
|
```
|
|
445
496
|
|
|
446
|
-
Log out and
|
|
497
|
+
Log out and back in, Assistant is now your default shell.
|
|
447
498
|
|
|
448
499
|
---
|
|
449
500
|
|
|
@@ -75,6 +75,8 @@ pacman -S python-assistant
|
|
|
75
75
|
|
|
76
76
|
</details>
|
|
77
77
|
|
|
78
|
+
Read [Use Assistant as Your Default Shell](#use-assistant-as-your-default-shell) for more information.
|
|
79
|
+
|
|
78
80
|
### 2. Run the Configuration Wizard
|
|
79
81
|
|
|
80
82
|
On the first launch the wizard starts automatically. You can also re-run it at any time:
|
|
@@ -102,7 +104,7 @@ The configuration is saved to `~/.assistant/config.toml`.
|
|
|
102
104
|
assistant
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
That's it
|
|
107
|
+
That's it: you're in. Type commands, ask questions, or mix both.
|
|
106
108
|
|
|
107
109
|
---
|
|
108
110
|
|
|
@@ -383,16 +385,64 @@ Toggle shortcuts (Ctrl+O, Ctrl+Q) update the config automatically when pressed,
|
|
|
383
385
|
|
|
384
386
|
## Use Assistant as Your Default Shell
|
|
385
387
|
|
|
386
|
-
|
|
388
|
+
Assistant is a full Xonsh shell, so it reads the same RC files (`~/.config/xonsh/rc.xsh` or `~/.config/xonsh/rc.d/`) which means your existing config carries over as-is.
|
|
389
|
+
|
|
390
|
+
Read more about Xonsh [Installation Guide](https://xon.sh/install.html) and its [Run Control Files](https://xon.sh/xonshrc.html).
|
|
391
|
+
|
|
392
|
+
### Install Assistant in a Stable, Isolated Environment
|
|
393
|
+
|
|
394
|
+
(so a system Python upgrade can't break your shell)
|
|
395
|
+
|
|
396
|
+
**Example with `uv`**
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
env_root=~/.venvs
|
|
400
|
+
env_path=${env_root}/assistant
|
|
401
|
+
python_path=${env_path}/bin/python
|
|
402
|
+
mkdir -p $env_root
|
|
403
|
+
uv venv $env_path --python 3.13
|
|
404
|
+
uv pip install --python ${python_path} assistant
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
From there to update Assistant, simply run:
|
|
408
|
+
```bash
|
|
409
|
+
uv pip install --python ${python_path} -U assistant
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Create a Dedicated Terminal Profile
|
|
413
|
+
|
|
414
|
+
Since Assistant is a natural language shell and Xonsh is not ready to be fully POSIX compliant,
|
|
415
|
+
it is highly recommended that you create a dedicated profile for Assistant beside Xonsh and your other shells,
|
|
416
|
+
directly inside your terminal application,
|
|
417
|
+
where you can set Assistant as your default shell, instead of registering it for the system.
|
|
418
|
+
|
|
419
|
+
The path to Assistant is defined as shown in this example.
|
|
420
|
+
```bash
|
|
421
|
+
assistant_bin=${env_path}/bin/assistant
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
You can also create a symbolic link to Assistant in `~/.local/bin` (or any other location in `$PATH`) so that Assistant is easily accessible.
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
ln -s $assistant_bin ~/.local/bin
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Or you could add `${env_path}/bin` to your `$PATH`.
|
|
387
431
|
|
|
388
|
-
|
|
432
|
+
### Register Assistant as a Shell for the System
|
|
433
|
+
> [!WARNING]
|
|
434
|
+
> If you read the Xonsh installation guide correctly, you understand that **you shouldn't try this method** unless:
|
|
435
|
+
> 1. you know what you are doing and want to test deeper interaction with the POSIX compliance of the system
|
|
436
|
+
> 2. you are ready to assume the consequences of potentially triggering multiple inference calls every time the system executes a command that exits with a non-zero code.
|
|
437
|
+
>
|
|
438
|
+
> Do the following at your own risk.
|
|
389
439
|
|
|
390
440
|
```bash
|
|
391
|
-
sudo sh -c
|
|
392
|
-
chsh -s $
|
|
441
|
+
sudo sh -c "echo ${assistant_bin} >> /etc/shells"
|
|
442
|
+
chsh -s $assistant_bin
|
|
393
443
|
```
|
|
394
444
|
|
|
395
|
-
Log out and
|
|
445
|
+
Log out and back in, Assistant is now your default shell.
|
|
396
446
|
|
|
397
447
|
---
|
|
398
448
|
|
|
@@ -5,7 +5,7 @@ import warnings
|
|
|
5
5
|
warnings.filterwarnings("ignore", category=DeprecationWarning, module="webrtcvad")
|
|
6
6
|
warnings.filterwarnings("ignore", category=UserWarning, module="webrtcvad")
|
|
7
7
|
|
|
8
|
-
__version__ = "2.2.
|
|
8
|
+
__version__ = "2.2.2b1"
|
|
9
9
|
|
|
10
10
|
USERNAME = os.environ.get("USER", "root")
|
|
11
11
|
HOME = os.environ.get("HOME", f"/home/{USERNAME}" if USERNAME != "root" else "/root")
|
|
@@ -62,6 +62,7 @@ DEFAULT_CONFIG = {
|
|
|
62
62
|
"provider": "ollama",
|
|
63
63
|
"context_length": 256000,
|
|
64
64
|
"think": False,
|
|
65
|
+
"reasoning_effort": None,
|
|
65
66
|
"temperature": 0.1,
|
|
66
67
|
"max_token": 1,
|
|
67
68
|
},
|
|
@@ -131,7 +132,9 @@ DEFAULT_CONFIG = {
|
|
|
131
132
|
"max_turns": 50,
|
|
132
133
|
"temperature": 0.1,
|
|
133
134
|
"max_command_output_length": 10000,
|
|
135
|
+
"max_tool_output_lines": 50,
|
|
134
136
|
"command_timeout": 180,
|
|
137
|
+
"tool_timeouts": {"xonsh": 180, "web_search": 15, "read_webpage": 20},
|
|
135
138
|
},
|
|
136
139
|
"memory": {
|
|
137
140
|
"enabled": False,
|
|
@@ -161,6 +164,8 @@ DEFAULT_CONFIG = {
|
|
|
161
164
|
# end of the system prompt, after the "Relevant commands" block.
|
|
162
165
|
"suggestions_enabled": True,
|
|
163
166
|
"suggestions_budget": 800,
|
|
167
|
+
"thinking_loop_enabled": True,
|
|
168
|
+
"thinking_loop_max_turns": 5,
|
|
164
169
|
},
|
|
165
170
|
"voice": {
|
|
166
171
|
"tts_enabled": True,
|
|
@@ -11,7 +11,7 @@ import types
|
|
|
11
11
|
from typing import Any, Callable, Dict, List, Optional
|
|
12
12
|
|
|
13
13
|
from assistant.config import DEFAULT_CONFIG_PATH, get_config
|
|
14
|
-
from assistant.
|
|
14
|
+
from assistant.nlp.interface import get_random_thinking_sentence
|
|
15
15
|
from assistant.memory import memory
|
|
16
16
|
from assistant.nlp.providers import get_provider
|
|
17
17
|
from assistant.nlp.xonsh import XONSH_INTRO
|
|
@@ -19,6 +19,19 @@ from assistant.tools import TOOL_REGISTRY
|
|
|
19
19
|
from assistant.traces.store import store as trace_store
|
|
20
20
|
from assistant.utils import count_message_tokens, count_messages_tokens
|
|
21
21
|
|
|
22
|
+
# Appended to a search tool's output so the model knows the structured result
|
|
23
|
+
# object landed in the session (see _process_tool_calls).
|
|
24
|
+
CONVERSATION_SEARCH_HINT = (
|
|
25
|
+
"\n\nResults assigned to __conversation__ in the session environment. "
|
|
26
|
+
"You can interact with them using the xonsh tool. Use `__conversation__?` "
|
|
27
|
+
"to get more information about them."
|
|
28
|
+
)
|
|
29
|
+
MEMORY_SEARCH_HINT = (
|
|
30
|
+
"\n\nResults assigned to __memory__ in the session environment. "
|
|
31
|
+
"You can interact with them using the xonsh tool. Use `__memory__?` "
|
|
32
|
+
"to get more information about them."
|
|
33
|
+
)
|
|
34
|
+
|
|
22
35
|
|
|
23
36
|
# Handoff exception to break the tool loop and switch agents
|
|
24
37
|
class AgentHandoff(Exception):
|
|
@@ -43,8 +56,12 @@ class Agent:
|
|
|
43
56
|
model_cfg = cfg.get_model_config(model_id)
|
|
44
57
|
self.model_name = model_cfg.get("id", "qwen3.5:latest")
|
|
45
58
|
self.context_length = model_cfg.get("context_length", 256000)
|
|
59
|
+
# NOTE: config key "max_token" is shared between the completer (wants 1 = single word)
|
|
60
|
+
# and the main agent (wants a full output budget). The clamp below enforces a minimum
|
|
61
|
+
# of 4096 tokens for the agent, so the completer's max_token=1 is safely overridden.
|
|
62
|
+
self.max_tokens = max(4096, int(model_cfg.get("max_token", 4096)))
|
|
46
63
|
self.think = model_cfg.get("think", False)
|
|
47
|
-
|
|
64
|
+
self.reasoning_effort = model_cfg.get("reasoning_effort", None)
|
|
48
65
|
# Resolve Provider
|
|
49
66
|
provider_id = model_cfg.get("provider", "ollama")
|
|
50
67
|
provider_cfg = cfg.get_provider_config(provider_id)
|
|
@@ -144,6 +161,10 @@ class Orchestrator:
|
|
|
144
161
|
self._summ_model_id = None # Resolved dedicated model id
|
|
145
162
|
self._active_agent = None # Agent of the current chat turn
|
|
146
163
|
|
|
164
|
+
# Thinking-loop detection (Phase 8): consecutive thinking turns + one-shot nudge flag.
|
|
165
|
+
self._consecutive_thinking_turns = 0
|
|
166
|
+
self._thinking_warned = False
|
|
167
|
+
|
|
147
168
|
self._ensure_config()
|
|
148
169
|
|
|
149
170
|
# Session setup: trace recording (Phase 1). Controlled by config
|
|
@@ -254,7 +275,15 @@ class Orchestrator:
|
|
|
254
275
|
try:
|
|
255
276
|
from xonsh.built_ins import XSH
|
|
256
277
|
|
|
257
|
-
|
|
278
|
+
# Stale search results across a reset would mislead the next
|
|
279
|
+
# session — drop them (they start with __ and would otherwise
|
|
280
|
+
# survive the vital filter).
|
|
281
|
+
stale_search = ("__conversation__", "__memory__")
|
|
282
|
+
vital = {
|
|
283
|
+
k: v
|
|
284
|
+
for k, v in XSH.ctx.items()
|
|
285
|
+
if k.startswith("__") and k not in stale_search
|
|
286
|
+
}
|
|
258
287
|
XSH.ctx.clear()
|
|
259
288
|
XSH.ctx.update(vital)
|
|
260
289
|
except Exception:
|
|
@@ -661,6 +690,10 @@ class Orchestrator:
|
|
|
661
690
|
total_turns = 0
|
|
662
691
|
max_turns = self._cfg.max_turns or 50
|
|
663
692
|
|
|
693
|
+
# Reset thinking-loop detection state for this chat() call.
|
|
694
|
+
self._consecutive_thinking_turns = 0
|
|
695
|
+
self._thinking_warned = False
|
|
696
|
+
|
|
664
697
|
# Sync the static sys prompt once per session if possible
|
|
665
698
|
# Cache for system prompt tokens to avoid re-calculating identical blocks
|
|
666
699
|
while total_turns < max_turns:
|
|
@@ -767,13 +800,18 @@ class Orchestrator:
|
|
|
767
800
|
None if self._is_intro else (agent.tools if agent.tools else None)
|
|
768
801
|
)
|
|
769
802
|
use_think = False if self._is_intro else agent.think
|
|
803
|
+
use_reasoning_effort = (
|
|
804
|
+
None if self._is_intro else agent.reasoning_effort
|
|
805
|
+
)
|
|
770
806
|
|
|
771
807
|
kwargs = agent.provider.build_chat_kwargs(
|
|
772
808
|
model=agent.model_name,
|
|
773
809
|
messages=api_messages,
|
|
774
810
|
temperature=self._cfg.temperature,
|
|
775
811
|
think=use_think,
|
|
812
|
+
reasoning_effort=use_reasoning_effort,
|
|
776
813
|
tools=use_tools,
|
|
814
|
+
max_tokens=agent.max_tokens,
|
|
777
815
|
)
|
|
778
816
|
if _is_debug:
|
|
779
817
|
sys.stderr.write(f"[DEBUG] Calling API ({agent.model_name})...\n")
|
|
@@ -782,7 +820,7 @@ class Orchestrator:
|
|
|
782
820
|
self._emit(
|
|
783
821
|
{
|
|
784
822
|
"type": "status",
|
|
785
|
-
"text": f"{agent.name}: {get_random_thinking_sentence()
|
|
823
|
+
"text": f"{agent.name}: {get_random_thinking_sentence()}...",
|
|
786
824
|
}
|
|
787
825
|
)
|
|
788
826
|
if _is_debug:
|
|
@@ -823,6 +861,10 @@ class Orchestrator:
|
|
|
823
861
|
return ctx + [{"role": "assistant", "content": ""}]
|
|
824
862
|
raise e
|
|
825
863
|
|
|
864
|
+
# Thinking-loop detection (Phase 8): nudge the model after N consecutive
|
|
865
|
+
# thinking turns so it stops reasoning and answers directly.
|
|
866
|
+
self._detect_thinking_loop(think_text, context_messages)
|
|
867
|
+
|
|
826
868
|
assistant_msg = {"role": "assistant", "content": visible}
|
|
827
869
|
# Count tokens after adding reasoning - reasoning is preserved for trace
|
|
828
870
|
# fidelity (kept in the message), so it counts toward the token budget.
|
|
@@ -1137,6 +1179,42 @@ class Orchestrator:
|
|
|
1137
1179
|
|
|
1138
1180
|
return visible, think_text, tool_calls, is_streamed, response_meta
|
|
1139
1181
|
|
|
1182
|
+
def _detect_thinking_loop(self, think_text, context_messages):
|
|
1183
|
+
"""Detect a thinking loop and nudge the model to answer directly.
|
|
1184
|
+
|
|
1185
|
+
After ``thinking_loop_max_turns`` consecutive turns where the model
|
|
1186
|
+
produced only reasoning (no visible content, no tool calls), inject a
|
|
1187
|
+
one-shot user-role nudge into ``context_messages`` and emit a status
|
|
1188
|
+
event. The nudge fires once per ``chat()`` call (``_thinking_warned``);
|
|
1189
|
+
any turn with visible content or tool calls resets the counter.
|
|
1190
|
+
|
|
1191
|
+
Args:
|
|
1192
|
+
think_text: The reasoning text from this turn (empty if none).
|
|
1193
|
+
context_messages: The mutable message list to append the nudge to.
|
|
1194
|
+
"""
|
|
1195
|
+
if think_text:
|
|
1196
|
+
self._consecutive_thinking_turns += 1
|
|
1197
|
+
loop_max = self._cfg.thinking_loop_max_turns
|
|
1198
|
+
if (
|
|
1199
|
+
self._cfg.thinking_loop_enabled
|
|
1200
|
+
and loop_max > 0
|
|
1201
|
+
and self._consecutive_thinking_turns >= loop_max
|
|
1202
|
+
and not self._thinking_warned
|
|
1203
|
+
):
|
|
1204
|
+
self._thinking_warned = True
|
|
1205
|
+
context_messages.append(
|
|
1206
|
+
{"role": "user", "content": "Please stop reasoning and answer directly."}
|
|
1207
|
+
)
|
|
1208
|
+
self._emit(
|
|
1209
|
+
{
|
|
1210
|
+
"type": "status",
|
|
1211
|
+
"text": "⚠️ detected thinking loop — nudging model to answer directly",
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
else:
|
|
1215
|
+
self._consecutive_thinking_turns = 0
|
|
1216
|
+
self._thinking_warned = False
|
|
1217
|
+
|
|
1140
1218
|
def _get_summ_agent(self):
|
|
1141
1219
|
"""Resolve the LLM used by density-layer compaction (couches 1-3).
|
|
1142
1220
|
|
|
@@ -1189,7 +1267,10 @@ class Orchestrator:
|
|
|
1189
1267
|
# Use config limit or a generous 64k default.
|
|
1190
1268
|
# We no longer hard-cap at 32k to allow modern large-context models.
|
|
1191
1269
|
effective_limit = int(agent.context_length or 64000)
|
|
1192
|
-
|
|
1270
|
+
# Reserve a minimum output budget so the model always has room to respond.
|
|
1271
|
+
# The input must never consume more than (context_length - output_reserve).
|
|
1272
|
+
output_reserve = max(4096, int(agent.max_tokens or 4096))
|
|
1273
|
+
context_limit = min(int(effective_limit * threshold), effective_limit - output_reserve)
|
|
1193
1274
|
|
|
1194
1275
|
current_tokens = count_messages_tokens(run_messages)
|
|
1195
1276
|
if current_tokens > context_limit:
|
|
@@ -1212,6 +1293,14 @@ class Orchestrator:
|
|
|
1212
1293
|
run_messages.clear()
|
|
1213
1294
|
run_messages.extend(system_msgs)
|
|
1214
1295
|
run_messages.extend([m for m in context_messages if m["role"] != "system"])
|
|
1296
|
+
# Hard safety net: if compaction still left us over the limit,
|
|
1297
|
+
# drop oldest non-system messages until we fit.
|
|
1298
|
+
while count_messages_tokens(run_messages) > context_limit:
|
|
1299
|
+
non_system = [i for i, m in enumerate(run_messages) if m.get("role") != "system"]
|
|
1300
|
+
if not non_system:
|
|
1301
|
+
break
|
|
1302
|
+
oldest_idx = non_system[0]
|
|
1303
|
+
run_messages.pop(oldest_idx)
|
|
1215
1304
|
# Couche 3 rolling summary: injected as a trailing system block (the
|
|
1216
1305
|
# lead system prompt is never mutated, keeping the KV-cache warm). It
|
|
1217
1306
|
# lives outside the compaction branch so a summary produced earlier is
|
|
@@ -1331,35 +1420,25 @@ class Orchestrator:
|
|
|
1331
1420
|
if "sigint_pipe_w" in _params:
|
|
1332
1421
|
extra_kwargs["sigint_pipe_w"] = sigint_pipe_w
|
|
1333
1422
|
|
|
1423
|
+
_t0 = time.monotonic()
|
|
1334
1424
|
res = fn(args, **extra_kwargs)
|
|
1425
|
+
_wall = time.monotonic() - _t0
|
|
1335
1426
|
except KeyboardInterrupt as ke:
|
|
1336
1427
|
# Re-raise KeyboardInterrupt so parent loop can handle cleanup
|
|
1337
1428
|
raise ke
|
|
1338
1429
|
|
|
1339
1430
|
# Check for abort after tool execution
|
|
1340
1431
|
if self._abort_event.is_set():
|
|
1341
|
-
self._abort_event.clear()
|
|
1342
1432
|
return None
|
|
1343
1433
|
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
tool_msg = {
|
|
1354
|
-
"role": "tool",
|
|
1355
|
-
"tool_call_id": t.id,
|
|
1356
|
-
"name": fn_name,
|
|
1357
|
-
"content": res["content"] or "",
|
|
1358
|
-
}
|
|
1359
|
-
# Soft bound (rtk-like): if the output exceeds the context budget,
|
|
1360
|
-
# compress it for the model context (deterministic, command-aware).
|
|
1361
|
-
# The full output is kept on _full_output for trace storage.
|
|
1362
|
-
content = tool_msg["content"]
|
|
1434
|
+
# Structured display payload (e.g. search_conversation rows)
|
|
1435
|
+
# rides the event for the shell; it never enters tool_msg, so
|
|
1436
|
+
# the LLM context stays the flat ``content`` string.
|
|
1437
|
+
# Compute the output ONCE, shared by the model context and the
|
|
1438
|
+
# user display (issue #10: they must always be the same).
|
|
1439
|
+
content = res["content"] or ""
|
|
1440
|
+
display_output = content
|
|
1441
|
+
compressed = False
|
|
1363
1442
|
if content:
|
|
1364
1443
|
bound = getattr(self._cfg, "max_tool_output_in_context", None)
|
|
1365
1444
|
if not bound:
|
|
@@ -1372,13 +1451,52 @@ class Orchestrator:
|
|
|
1372
1451
|
if bound and len(content) > bound:
|
|
1373
1452
|
from assistant.compress import compress_tool_output
|
|
1374
1453
|
|
|
1375
|
-
|
|
1376
|
-
tool_msg["content"] = compress_tool_output(
|
|
1454
|
+
display_output = compress_tool_output(
|
|
1377
1455
|
content,
|
|
1378
1456
|
command=cmd_display if fn_name == "xonsh" else fn_name,
|
|
1379
1457
|
limit=bound,
|
|
1380
1458
|
)
|
|
1381
|
-
|
|
1459
|
+
compressed = True
|
|
1460
|
+
|
|
1461
|
+
# Search tools inject a structured result object into the
|
|
1462
|
+
# session (__conversation__ / __memory__); surface that to the
|
|
1463
|
+
# model so it can refine/display them via the xonsh tool. The
|
|
1464
|
+
# hint rides both the display output and (when compressed) the
|
|
1465
|
+
# restored full output.
|
|
1466
|
+
result_kind = res.get("result_kind")
|
|
1467
|
+
if result_kind == "conversation":
|
|
1468
|
+
hint = CONVERSATION_SEARCH_HINT
|
|
1469
|
+
elif result_kind == "memory":
|
|
1470
|
+
hint = MEMORY_SEARCH_HINT
|
|
1471
|
+
else:
|
|
1472
|
+
hint = ""
|
|
1473
|
+
if hint:
|
|
1474
|
+
display_output += hint
|
|
1475
|
+
|
|
1476
|
+
event = {
|
|
1477
|
+
"type": "tool_output",
|
|
1478
|
+
"command": cmd_display,
|
|
1479
|
+
"tool": fn_name,
|
|
1480
|
+
"output": display_output,
|
|
1481
|
+
"is_error": res["is_error"],
|
|
1482
|
+
"wall": round(_wall, 3),
|
|
1483
|
+
"artifact": len(display_output or ""),
|
|
1484
|
+
}
|
|
1485
|
+
if res.get("results") is not None:
|
|
1486
|
+
event["results"] = res["results"]
|
|
1487
|
+
if res.get("result_kind"):
|
|
1488
|
+
event["result_kind"] = res["result_kind"]
|
|
1489
|
+
self._emit(event)
|
|
1490
|
+
|
|
1491
|
+
tool_msg = {
|
|
1492
|
+
"role": "tool",
|
|
1493
|
+
"tool_call_id": t.id,
|
|
1494
|
+
"name": fn_name,
|
|
1495
|
+
"content": display_output,
|
|
1496
|
+
}
|
|
1497
|
+
if compressed:
|
|
1498
|
+
tool_msg["_full_output"] = content + hint
|
|
1499
|
+
tool_msg["_compressed"] = True
|
|
1382
1500
|
# Optimization: populate cache immediately
|
|
1383
1501
|
tool_msg["_tokens"] = count_message_tokens(tool_msg)
|
|
1384
1502
|
context_messages.append(tool_msg)
|
|
@@ -1394,12 +1512,25 @@ class Orchestrator:
|
|
|
1394
1512
|
return handoff_target
|
|
1395
1513
|
|
|
1396
1514
|
def _get_tool_display_name(self, name, args):
|
|
1515
|
+
"""Return the user-facing display text for a tool call.
|
|
1516
|
+
|
|
1517
|
+
Always shows the tool's primary argument value (when given) so the
|
|
1518
|
+
input box never repeats the ``tool_name(...)`` wrapper the title
|
|
1519
|
+
already provides. Falls back to the bare tool name when no argument
|
|
1520
|
+
is meaningful.
|
|
1521
|
+
"""
|
|
1397
1522
|
if name == "xonsh":
|
|
1398
1523
|
return args.get("code", "")
|
|
1399
1524
|
if name == "web_search":
|
|
1400
|
-
return
|
|
1525
|
+
return args.get("query", "") or name
|
|
1401
1526
|
if name == "memory_search":
|
|
1402
|
-
return
|
|
1527
|
+
return args.get("query", "") or name
|
|
1528
|
+
if name == "memory_add":
|
|
1529
|
+
return args.get("text", "") or name
|
|
1530
|
+
if name == "cmd_search":
|
|
1531
|
+
return args.get("query", "") or name
|
|
1532
|
+
if name == "search_conversation":
|
|
1533
|
+
return args.get("query", "") or name
|
|
1403
1534
|
return name
|
|
1404
1535
|
|
|
1405
1536
|
def _handle_handoff_return(self, agent_name, response, context_messages, agent_id):
|