Cap run_command spam and force a usable finalize after tool-round limits.

Budget shell calls like CLI, and when rounds are exhausted inject a no-more-tools system nudge plus any user_facing_hint constraints into the final synthesis pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 23:26:54 +08:00
parent 28a5f2586c
commit 9d447b1c51
5 changed files with 186 additions and 27 deletions

View file

@ -42,6 +42,21 @@ def test_enrich_mcp_scope_sql() -> None:
assert "ume_alarm_xlsx_report" in out["fallback_tools"]
def test_build_finalize_system_suffix() -> None:
from runtime.tools.tool_error_hints import build_finalize_system_suffix
en = build_finalize_system_suffix(
lang="en",
hit_tool_round_limit=True,
user_facing_hints=["SQL query is not enabled for this bot token."],
)
assert "Tool-round limit" in en
assert "SQL query is not enabled" in en
assert "do NOT call" in en
zh = build_finalize_system_suffix(lang="zh", hit_tool_round_limit=True)
assert "工具轮次" in zh
def test_enrich_exec_auth() -> None:
from runtime.tools.tool_error_hints import enrich_exec_managed_ne_error