Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(plan): update the typing of `plan_change_hook` argument to support awaitables (#940)
lixiaofei123a2bf80ec96e2
diff --git a/examples/evaluation/ace_bench/main.py b/examples/evaluation/ace_bench/main.pyindex 2c86166d4..70ed7309a 100644--- a/examples/evaluation/ace_bench/main.py+++ b/examples/evaluation/ace_bench/main.py@@ -70,7 +70,9 @@ async def react_agent_solution(# Obtain tool_use blocks as trajectorytraj = []for msg in memory_msgs:- traj.extend(msg.get_content_blocks("tool_use"))+ for block in msg.get_content_blocks():+ if block["type"] in ["tool_use", "tool_result"]:+ traj.append(block)# Obtain the final state of the phone and travel systemphone: ACEPhone = ace_task.metadata["phone"]diff --git a/src/agentscope/plan/_plan_notebook.py b/src/agentscope/plan/_plan_notebook.pyindex b24706c91..3d8e8c61d 100644--- a/src/agentscope/plan/_plan_notebook.py+++ b/src/agentscope/plan/_plan_notebook.py@@ -2,7 +2,7 @@"""The plan notebook class, used to manage the plan, providing hints andtool functions to the agent."""from collections import OrderedDict-from typing import Callable, Literal, Coroutine, Any+from typing import Callable, Literal, Coroutine, Any, Awaitablefrom ._in_memory_storage import InMemoryPlanStoragefrom ._plan_model import SubTask, Plan@@ -173,7 +173,11 @@ class PlanNotebook(StateModule):"""The plan notebook to manage the plan, providing hints and plan relatedtool functions to the agent."""- _plan_change_hooks: dict[str, Callable[["PlanNotebook", Plan], None]]+ _plan_change_hooks: dict[+ str,+ Callable[["PlanNotebook", Plan], None]+ | Callable[["PlanNotebook", Plan], Awaitable[None]],+ ]"""The hooks that will be triggered when the plan is changed. For example,used to display the plan on the frontend."""@@ -856,7 +860,8 @@ class PlanNotebook(StateModule):def register_plan_change_hook(self,hook_name: str,- hook: Callable[["PlanNotebook", Plan], None],+ hook: Callable[["PlanNotebook", Plan], None]+ | Callable[["PlanNotebook", Plan], Awaitable[None]],) -> None:"""Register a plan hook that will be triggered when the plan ischanged.@@ -864,7 +869,8 @@ class PlanNotebook(StateModule):Args:hook_name (`str`):The name of the hook, should be unique.- hook (`Callable[[Plan], None]`):+ hook (`Callable[["PlanNotebook", Plan], None] | \+ Callable[["PlanNotebook", Plan], Awaitable[None]]):The hook function, which takes the current plan as input andreturns nothing."""