Skip to content

Commit 581ae3e

Browse files
committed
refactor:调整步骤状态更新逻辑以使用get_current_step函数以简化代码
1 parent 3ec6cab commit 581ae3e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

agents/matmaster_agent/utils/event_utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@
2727
ContentLimitLlmAgent,
2828
)
2929
from agents.matmaster_agent.flow_agents.model import PlanStepStatusEnum
30+
from agents.matmaster_agent.flow_agents.step_utils import get_current_step
3031
from agents.matmaster_agent.flow_agents.style import separate_card
3132
from agents.matmaster_agent.llm_config import DEFAULT_MODEL, MatMasterLlmConfig
3233
from agents.matmaster_agent.locales import i18n
3334
from agents.matmaster_agent.model import RenderTypeEnum
3435
from agents.matmaster_agent.prompt import GLOBAL_INSTRUCTION
3536
from agents.matmaster_agent.services.session_files import insert_session_files
36-
from agents.matmaster_agent.state import CURRENT_STEP, ERROR_DETAIL, PLAN, UPLOAD_FILE
37+
from agents.matmaster_agent.state import (
38+
CURRENT_STEP,
39+
CURRENT_STEP_STATUS,
40+
ERROR_DETAIL,
41+
PLAN,
42+
UPLOAD_FILE,
43+
)
3744
from agents.matmaster_agent.style import (
3845
no_found_structure_card,
3946
photon_consume_free_card,
@@ -474,11 +481,9 @@ def handle_tool_error(ctx, author, error_message, error_type):
474481
)
475482

476483
# 更新 plan 状态为失败
477-
update_plan = copy.deepcopy(ctx.session.state['plan'])
478-
update_plan['steps'][ctx.session.state['plan_index']][
479-
'status'
480-
] = PlanStepStatusEnum.FAILED
481-
yield update_state_event(ctx, state_delta={'plan': update_plan})
484+
post_execution_step = copy.deepcopy(get_current_step(ctx))
485+
post_execution_step[CURRENT_STEP_STATUS] = PlanStepStatusEnum.FAILED
486+
yield update_state_event(ctx, state_delta={CURRENT_STEP: post_execution_step})
482487

483488
# 抛出相应的异常
484489
raise RuntimeError(f'Tool Execution Error: {error_type}')

0 commit comments

Comments
 (0)