Skip to content

Commit 31b42e3

Browse files
committed
feat:支持获取当前步骤工具名称以简化事件流程处理
1 parent ecba649 commit 31b42e3

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

agents/matmaster_agent/state.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
UPLOAD_FILE = 'upload_file'
1111
MULTI_PLANS = 'multi_plans'
1212
PLAN_CONFIRM = 'plan_confirm'
13+
1314
CURRENT_STEP = 'current_step'
1415
CURRENT_STEP_STATUS = 'status'
16+
CURRENT_STEP_TOOL_NAME = 'tool_name'
17+
1518
HISTORY_STEPS = 'history_steps'
1619
FINISHED_STATE = 'finished_state'
1720

agents/matmaster_agent/sub_agents/built_in_agent/llm_tool_agent/agent.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
DisallowTransferAndContentLimitLlmAgent,
1010
)
1111
from agents.matmaster_agent.flow_agents.model import PlanStepStatusEnum
12+
from agents.matmaster_agent.flow_agents.step_utils import get_current_step
1213
from agents.matmaster_agent.llm_config import LLMConfig
13-
from agents.matmaster_agent.locales import i18n
14+
from agents.matmaster_agent.state import (
15+
CURRENT_STEP,
16+
CURRENT_STEP_STATUS,
17+
CURRENT_STEP_TOOL_NAME,
18+
)
1419
from agents.matmaster_agent.sub_agents.built_in_agent.llm_tool_agent.constant import (
1520
TOOL_AGENT_NAME,
1621
)
@@ -33,19 +38,13 @@ async def _run_events(self, ctx: InvocationContext) -> AsyncGenerator[Event, Non
3338
async for event in super()._run_events(ctx):
3439
yield event
3540

36-
update_plan = copy.deepcopy(ctx.session.state['plan'])
37-
update_plan['steps'][ctx.session.state['plan_index']][
38-
'status'
39-
] = PlanStepStatusEnum.SUCCESS
40-
yield update_state_event(ctx, state_delta={'plan': update_plan})
41-
42-
current_step = ctx.session.state['plan']['steps'][
43-
ctx.session.state['plan_index']
44-
]
45-
current_step_tool_name = current_step['tool_name']
41+
post_execution_step = copy.deepcopy(get_current_step(ctx))
42+
post_execution_step[CURRENT_STEP_STATUS] = PlanStepStatusEnum.SUCCESS
43+
yield update_state_event(ctx, state_delta={CURRENT_STEP: post_execution_step})
44+
current_step_tool_name = post_execution_step[CURRENT_STEP_TOOL_NAME]
4645
step_title = ctx.session.state.get('step_title', {}).get(
4746
'title',
48-
f"{i18n.t(ctx.session.state['separate_card_info'])} {ctx.session.state['plan_index'] + 1}: {current_step_tool_name}",
47+
current_step_tool_name,
4948
)
5049
for matmaster_flow_event in context_function_event(
5150
ctx,

0 commit comments

Comments
 (0)