Prefer hetero targets batch for multi-NE CLI instead of one-NE loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-12 21:27:30 +08:00
parent 42092423fb
commit 25d09d78ce
8 changed files with 63 additions and 20 deletions

View file

@ -19,10 +19,32 @@ def test_is_batch_exec_args() -> None:
assert is_batch_exec_args({"ne_ids": ["a", "b"], "commands": ["show version"]})
assert is_batch_exec_args({"ume_ne_ids": ["u1"]})
assert is_batch_exec_args({"targets": [{"ne_id": "x"}]})
assert is_batch_exec_args(
{
"targets": [
{"ume_ne_id": "hw1", "commands": ["display optical-module brief"]},
{"ume_ne_id": "cs1", "commands": ["show interface transceiver"]},
]
}
)
assert not is_batch_exec_args({"ne_id": "x", "commands": ["show version"]})
assert not is_batch_exec_args({"ne_ids": []})
def test_budget_block_payload_mentions_hetero_targets() -> None:
from runtime.chat.exec_managed_ne_guard import budget_block_payload
payload = budget_block_payload(
reason="call_budget",
lang="en",
single_used=6,
single_budget=6,
)
assert "targets=" in str(payload.get("hint") or "")
assert isinstance(payload.get("example_hetero_targets"), dict)
assert payload["example_hetero_targets"]["targets"]
def test_normalize_exec_managed_ne_args_defaults_and_clamps() -> None:
assert normalize_exec_managed_ne_args({})["read_timeout_sec"] == 60
assert normalize_exec_managed_ne_args({"read_timeout_sec": 5})["read_timeout_sec"] == 10