Prefer batch CLI in playbooks, cap tool persistence, and steer getManagedNe failures.

Default scheduled CLI steps to ne_ids/ume_ne_ids batch, compact oversized tool chat_message/tool_log after turns, and on getManagedNe miss guide agents to listManagedNe/UME paths instead of blind retries.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-11 00:46:46 +08:00
parent ae70d4b89a
commit e2fc72607e
16 changed files with 373 additions and 61 deletions

View file

@ -83,8 +83,38 @@ class RecipeHelpersTests(unittest.TestCase):
cong = resolve_ops_recipe_template("congestion")
assert cong is not None
self.assertEqual((cong.get("source") or {}).get("template_id"), "bandwidth_congestion_daily")
cong_blob = " ".join(str(s) for s in (cong.get("steps") or []) + (cong.get("constraints") or []))
self.assertIn("ume_ne_ids", cong_blob)
self.assertIn("batch", cong_blob.lower())
license_tmpl = resolve_ops_recipe_template("license_check")
assert license_tmpl is not None
lic_blob = " ".join(str(s) for s in (license_tmpl.get("steps") or []))
self.assertIn("ne_ids", lic_blob)
self.assertIn("never one-NE", lic_blob)
self.assertIsNone(resolve_ops_recipe_template("nope"))
def test_compile_injects_batch_cli_constraint(self) -> None:
recipe = {
"goal": "CLI check top hosts",
"steps": [
"Pull congestion alarms",
"Run execManagedNe show interface on top hosts",
],
"success_criteria": ["Group gets summary"],
}
instr = compile_playbook_instruction(recipe=recipe, lang="en")
self.assertIn("ne_ids", instr)
self.assertIn("ume_ne_ids", instr)
self.assertIn("batch", instr.lower())
# Alarm-only playbook should not get CLI batch constraint.
alarm_only = {
"goal": "Alarm tally",
"steps": ["aggregateUmeAlarms", "Summarize by_severity"],
"success_criteria": ["Done"],
}
alarm_instr = compile_playbook_instruction(recipe=alarm_only, lang="en")
self.assertNotIn("Multi-NE CLI default", alarm_instr)
def test_turn_instruction_modes(self) -> None:
reminder = build_scheduled_turn_instruction(prompt_text="喝水", mode="scheduled", lang="zh")
self.assertIn("提醒意图", reminder)