Skip to content

Commit 514f6be

Browse files
agentscope-ai-javazhansheng.lzsluk384090-cloud
committed
acli: fix Windows TUI (run_command, wheel scroll) + bench-driven fixes (#188)
* release: v1.27.4 — sync acli v0.6.3 Sync agenticCLI v0.6.3 into dashscope/acli: - stagnation tracker with read-only hard cap for oneshot runs - auto_approve config + ACLI_AUTO_APPROVE env override - oneshot mode flag wired into the CLI runner * feat(acli): sync agenticCLI — budget-aware nudge + retry hardening - convergence nudge becomes budget-aware for autonomous runs - HardenedProvider: capped exponential backoff (3 retries, 4s base, 16s cap) to survive transient model-API failures in long runs * fix(acli): render markdown tables in TUI + restore input draft around confirm prompts * feat(acli): confirm_mode=dangerous — only risky (DANGEROUS) ops prompt for confirmation - New config option confirm_mode: "dangerous" (default) | "all" - CONFIRM-level tools (run_command, write_file, ...) auto-pass in dangerous mode - Read-only commands (grep/ls/cat/...) already skip prompts via is_safe_readonly - Policy deny rules still take precedence over auto-pass - DANGEROUS tools (delete_file, delete_directory) always prompt * feat(acli): sync agenticCLI — post-change verification rule + plan wiring Mirrors upstream 4562c7d and picks up the 0.6.4 version bump (SDK version stays 1.27.4, which is still unreleased on this branch). Coding tasks were ending without a single test run because the prompt asked for it: rule 3 said to edit code "without stating a plan first", the Concise bullet banned "test this / verify" as filler, and another bullet forbade reporting what had just been done. - rule 18: run the tests covering the change, or add a focused test when nothing covers it, and report command + pass/fail - rule 4: multi-step work uses create_plan/complete_step, already registered and echoed as "## Current plan" but never mentioned before Tree verified byte-identical to upstream src/acli after the import rewrite; black passed and every dashscope.acli module imports. * feat(acli): sync agenticCLI — oneshot flag overrides + combined sdk-client header Mirrors agenticCLI 999db69 and 72ecc69: - `-c` returned from main() before the --protocol/--max-turns overrides were applied, so oneshot always ran with the config default of 50 turns. Every terminal-bench run that asked for 150 was really capped at 50. - TongyiProvider now sends acli/<version>[/<module>] in a single x-dashscope-sdk-client header instead of splitting the version into x-dashscope-sdk-version. * feat(acli): sync agenticCLI — default model qwen3.8-max Mirrors bc7caee: qwen3.8-max becomes the factory default in Config, TongyiProvider, run_interactive/embedded.run and the Alibaba/Bailian setup preset. Also re-vendors examples from agenticCLI-examples (67f2249) so basic-chat and dashscope-sdk-expert stop overriding that default with qwen3.7-max / qwen3.7-plus. * fix(acli): sync agenticCLI — run_command on Windows inside the TUI sys.stdout.encoding was read while decoding subprocess output, but the TUI replaces sys.stdout with textual's capture object, which has no .encoding, so every command failed with AttributeError. The encoding is now resolved at import. Also passes the command to PowerShell as its own argv element (no cmd.exe re-quoting), prefers pwsh, and adds -NoProfile. * fix(acli): sync agenticCLI — capture the mouse in the TUI on Windows With capture off the terminal never learns the app wants mouse events, so Windows Terminal and conhost translate the wheel into arrow keys or scroll their own buffer: the input box moved through its history, or the whole screen dragged, while the output area never scrolled. * test(acli): add unit tests for reflection.py Cover the four core components: - is_readonly_tool_call: 67 cases (known tools, shell commands, pipes, redirects, container subcmds, env prefix, edge cases) - ReflectionTracker: 11 cases (threshold, reset, hints, lessons) - StagnationTracker: 10 cases (streak, hard cap, mixed sequences) - convergence_hint: 12 cases (soft/hard boundaries, custom ratios, remaining calculation, disable conditions) --------- Co-authored-by: zhansheng.lzs <zhansheng.lzs@alibaba-inc.com> Co-authored-by: luk384090-cloud <lu384090@gmail.com>
1 parent e1fc686 commit 514f6be

23 files changed

Lines changed: 1209 additions & 113 deletions

File tree

‎dashscope/acli/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import uuid
55

6-
__version__ = "0.6.2"
6+
__version__ = "0.6.4"
77

88
# Per-process identifier sent as x-dashscope-sdk-session-id so the
99
# backend can group multi-turn requests from one CLI run.

‎dashscope/acli/agent.py‎

Lines changed: 206 additions & 43 deletions
Large diffs are not rendered by default.

‎dashscope/acli/cli/__init__.py‎

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,33 @@
8686
_scheduler = None
8787

8888

89+
def _apply_cli_overrides(
90+
config: Config,
91+
protocol_override: str | None,
92+
max_turns_override: str | None,
93+
) -> None:
94+
"""Apply --protocol/--max-turns to a loaded config; exit on bad input."""
95+
if protocol_override:
96+
if protocol_override.lower() in ("openai", "anthropic"):
97+
config.protocol = protocol_override.lower()
98+
else:
99+
print(
100+
f"Error: unknown protocol '{protocol_override}' "
101+
f"(choices: openai, anthropic)",
102+
)
103+
sys.exit(1)
104+
105+
if max_turns_override is not None:
106+
try:
107+
config.max_turns = int(max_turns_override)
108+
except ValueError:
109+
print(
110+
f"Error: --max-turns must be an integer, got "
111+
f"'{max_turns_override}'",
112+
)
113+
sys.exit(1)
114+
115+
89116
def main():
90117
# Parse --cli / --tui / --dry-run flags (can appear anywhere in argv)
91118
use_cli = "--cli" in sys.argv
@@ -146,7 +173,7 @@ def main():
146173
)
147174
print(
148175
" --max-turns <n> Override max conversation "
149-
"turns (default 1000)",
176+
"turns (default from config: 50)",
150177
)
151178
print(
152179
" --dry-run Preview current config (loaded "
@@ -175,6 +202,13 @@ def main():
175202
print('Usage: acli -c "your request"')
176203
sys.exit(1)
177204
config = Config.load()
205+
# This branch returns before main()'s override tail, so the
206+
# flags must be applied here or oneshot silently ignores them.
207+
_apply_cli_overrides(
208+
config,
209+
protocol_override,
210+
max_turns_override,
211+
)
178212
asyncio.run(_run_oneshot(config, prompt))
179213
return
180214
elif arg in ("example", "examples"):
@@ -186,27 +220,7 @@ def main():
186220
_mcp_server_main()
187221
return
188222
config = Config.load()
189-
# Apply --protocol override
190-
if protocol_override:
191-
if protocol_override.lower() in ("openai", "anthropic"):
192-
config.protocol = protocol_override.lower()
193-
else:
194-
print(
195-
f"Error: unknown protocol '{protocol_override}' "
196-
f"(choices: openai, anthropic)",
197-
)
198-
sys.exit(1)
199-
200-
# Apply --max-turns override
201-
if max_turns_override is not None:
202-
try:
203-
config.max_turns = int(max_turns_override)
204-
except ValueError:
205-
print(
206-
f"Error: --max-turns must be an integer, got "
207-
f"'{max_turns_override}'",
208-
)
209-
sys.exit(1)
223+
_apply_cli_overrides(config, protocol_override, max_turns_override)
210224

211225
# Handle --dry-run: preview configuration without starting the agent
212226
if use_dry_run:

‎dashscope/acli/cli/handlers_setup.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _setup_finalize(config: Config, agent) -> None:
192192

193193
def _apply_preset_bailian(config: Config) -> None:
194194
config.provider = "tongyi"
195-
config.model = "qwen3.7-plus"
195+
config.model = "qwen3.8-max"
196196
config.enabled_capabilities = [
197197
"bailian.mcp",
198198
"bailian.cli",
@@ -284,7 +284,7 @@ async def _handle_setup(config: Config, agent) -> None:
284284
console.print("\nSelect a configuration mode:")
285285
console.print(
286286
" [cyan][1][/cyan] [bold]Alibaba/Bailian[/bold] (default) — "
287-
"tongyi/qwen3.7-plus + bailian.mcp/cli",
287+
"tongyi/qwen3.8-max + bailian.mcp/cli",
288288
)
289289
console.print(
290290
" [cyan][2][/cyan] China general — "

‎dashscope/acli/cli/repl.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ async def _run_loop(config: Config):
102102
sync_extensions_into_catalog(_ext)
103103
# _load_plugins() — deprecated; plugins load via the hooks mechanism
104104
provider = get_provider_chain(config)
105-
executor = Executor(auto_approve=config.auto_approve)
105+
executor = Executor(
106+
auto_approve=config.auto_approve,
107+
confirm_mode=config.confirm_mode,
108+
)
106109

107110
# Initialize memory
108111
# Memory client managed by handlers_profile
@@ -248,7 +251,7 @@ async def _run_loop(config: Config):
248251
if not WORKSPACE_CONFIG_FILE.exists():
249252
has_api_key = bool(config.api_key)
250253
using_defaults = (
251-
config.provider == "tongyi" and config.model == "qwen3.7-plus"
254+
config.provider == "tongyi" and config.model == "qwen3.8-max"
252255
)
253256
if not has_api_key or using_defaults:
254257
await _handle_setup(config, agent)

‎dashscope/acli/cli/runners.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ async def _run_oneshot(config: Config, prompt: str):
6767
sys.exit(1)
6868

6969
provider = get_provider_chain(config)
70-
executor = Executor()
70+
executor = Executor(
71+
auto_approve=config.auto_approve,
72+
confirm_mode=config.confirm_mode,
73+
)
7174
agent = Agent(
7275
provider=provider,
7376
executor=executor,
7477
max_turns=config.max_turns,
7578
provider_name=config.provider,
7679
model_name=config.model,
80+
oneshot=True,
7781
)
7882

7983
# Pin parent agent ref for local.subagent / local.delegate BEFORE platform
@@ -278,7 +282,10 @@ def _run_tui_mode(config: Config):
278282
# CLI mode uses the full provider chain so temporary failures can fall back
279283
# to configured alternatives instead of dying immediately.
280284
provider = get_provider_chain(config)
281-
executor = Executor(auto_approve=config.auto_approve)
285+
executor = Executor(
286+
auto_approve=config.auto_approve,
287+
confirm_mode=config.confirm_mode,
288+
)
282289

283290
from dashscope.acli.agents.delegate import (
284291
set_config as set_delegate_config,

‎dashscope/acli/config.py‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
PROVIDER_MODELS = {
2525
"tongyi": [
26+
"qwen3.8-max",
2627
"qwen3.7-max",
2728
"qwen3.7-plus",
2829
"qwen3.5-plus",
@@ -226,7 +227,7 @@ def from_dict(cls, d: dict) -> DelegationConfig:
226227
@dataclass
227228
class Config:
228229
provider: str = "tongyi"
229-
model: str = "qwen3.7-plus"
230+
model: str = "qwen3.8-max"
230231
# Dual-LLM: when thinking_model is set, Plan/Thinking loop phases route to
231232
# the thinking model; Execute uses the execution model (provider/model
232233
# above).
@@ -241,6 +242,10 @@ class Config:
241242
openai_api_key: str = ""
242243
base_url: str = ""
243244
auto_approve: bool = False
245+
# Which tool executions prompt for confirmation:
246+
# "all" - CONFIRM and DANGEROUS both prompt (classic)
247+
# "dangerous" - only DANGEROUS prompts; CONFIRM auto-passes
248+
confirm_mode: str = "dangerous"
244249
max_turns: int = 50
245250
timeout: int = 30
246251
mcp_servers: list[MCPServerConfig] = field(default_factory=list)
@@ -277,9 +282,11 @@ class Config:
277282
protocol: str = "openai" # "openai" | "anthropic"
278283
tui: bool = True
279284
# False = let the terminal handle the mouse (native selection).
280-
# Default off on Windows: Textual's mouse-capture path is crash-prone
281-
# in PowerShell/conhost; native terminal mouse still allows selection.
282-
tui_mouse: bool = field(default_factory=lambda: os.name != "nt")
285+
# Capture is on everywhere, including Windows: without it the wheel goes
286+
# to the console host, which scrolls the whole alternate screen — the
287+
# input box moves with the output and repaints slowly. Set false only if
288+
# your terminal mishandles Textual's mouse reporting.
289+
tui_mouse: bool = True
283290
privacy_mode: bool = (
284291
False # When True, all data stays local, no cloud capabilities
285292
)
@@ -314,7 +321,7 @@ def api_key(self, value: str) -> None:
314321
def load(
315322
cls,
316323
default_provider: str = "tongyi",
317-
default_model: str = "qwen3.7-plus",
324+
default_model: str = "qwen3.8-max",
318325
) -> Config:
319326
config = cls()
320327
# Caller's defaults become the initial values; config files and env
@@ -542,6 +549,20 @@ def _load_workspace_from(self, path: Path):
542549
self.max_turns = int(data["max_turns"])
543550
except (ValueError, TypeError):
544551
pass
552+
if "auto_approve" in data:
553+
val = str(data["auto_approve"]).lower()
554+
self.auto_approve = val in ("true", "1", "yes")
555+
if "confirm_mode" in data:
556+
val = str(data["confirm_mode"]).lower()
557+
if val in ("all", "dangerous"):
558+
self.confirm_mode = val
559+
# Env override for headless/benchmark use
560+
if os.environ.get("ACLI_AUTO_APPROVE", "").lower() in (
561+
"1",
562+
"true",
563+
"yes",
564+
):
565+
self.auto_approve = True
545566
if "session_persist" in data:
546567
val = str(data["session_persist"]).lower()
547568
self.session_persist = val not in ("false", "0", "no")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
user_name = "dashscope"
22
provider = "tongyi"
3-
model = "qwen3.7-max"
3+
model = "qwen3.8-max"
44
memory_user_id = "acli-basic"

‎dashscope/acli/examples/basic-chat/.acli/custom-extensions.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
name = "tongyi"
2020
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
2121
api_key_env = "DASHSCOPE_API_KEY"
22-
default_model = "qwen3.7-max"
22+
default_model = "qwen3.8-max"
2323
models = [
24+
"qwen3.8-max",
2425
"qwen3.7-max",
2526
"qwen3.7-plus",
2627
"qwen-turbo",

‎dashscope/acli/examples/basic-chat/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ Declares which LLM providers acli can use. A minimal config needs just one `[[pr
5151
name = "tongyi"
5252
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
5353
api_key_env = "DASHSCOPE_API_KEY" # ← stores only the env var name; the shell provides sk-xxx
54-
default_model = "qwen3.7-max"
55-
models = ["qwen3.7-max", "qwen3.7-plus", "qwen-turbo", "qwen-vl-max"]
54+
default_model = "qwen3.8-max"
55+
models = ["qwen3.8-max", "qwen3.7-max", "qwen3.7-plus", "qwen-turbo", "qwen-vl-max"]
5656
vision_models = ["qwen-vl-max"] # ← tells acli these models accept image input
5757
protocol = "openai" # ← openai / anthropic / dashscope
5858
```
@@ -95,7 +95,7 @@ How to invoke:
9595
```toml
9696
user_name = "dashscope"
9797
provider = "tongyi"
98-
model = "qwen3.7-max"
98+
model = "qwen3.8-max"
9999
memory_user_id = "acli-basic"
100100
```
101101

0 commit comments

Comments
 (0)