refactor: remove legacy assistant compatibility

This commit is contained in:
Xin Wang
2026-08-18 10:07:18 +08:00
parent abfcd4cd19
commit d003ee77a5
40 changed files with 505 additions and 729 deletions
+10 -19
View File
@@ -1,9 +1,4 @@
"""Runtime behavior shared by HTTP, MCP, and client tools.
The stored definitions are intentionally plain dictionaries. Keeping policy
normalization here gives old definitions stable defaults without spreading
fallback rules across PromptBrain, WorkflowBrain, and the pipeline.
"""
"""Runtime behavior shared by HTTP, MCP, and client tools."""
from __future__ import annotations
@@ -33,18 +28,14 @@ class ToolRuntimePolicy:
def policy_for_tool(tool: RuntimeTool) -> ToolRuntimePolicy:
"""Read policy with backwards-compatible defaults per tool kind."""
config = (tool.definition or {}).get("config") or {}
default_mode = "async" if tool.type == "client" else "immediate"
mode = str(config.get("execution_mode") or default_mode)
if mode not in {"immediate", "async"}:
mode = default_mode
response_wait_mode = str(config.get("response_wait_mode") or "timeout")
if response_wait_mode not in {"timeout", "session"}:
response_wait_mode = "timeout"
"""Read the validated policy stored on a current tool resource."""
config = tool.definition["config"]
is_client = tool.type == "client"
return ToolRuntimePolicy(
allow_interruptions=bool(config.get("allow_interruptions", True)),
execution_mode=mode,
wait_for_response=bool(config.get("wait_for_response", True)),
response_wait_mode=response_wait_mode,
allow_interruptions=bool(config["allow_interruptions"]),
execution_mode=str(config["execution_mode"]),
wait_for_response=(bool(config["wait_for_response"]) if is_client else True),
response_wait_mode=(
str(config["response_wait_mode"]) if is_client else "timeout"
),
)