|
27 | 27 | ContentLimitLlmAgent, |
28 | 28 | ) |
29 | 29 | from agents.matmaster_agent.flow_agents.model import PlanStepStatusEnum |
| 30 | +from agents.matmaster_agent.flow_agents.step_utils import get_current_step |
30 | 31 | from agents.matmaster_agent.flow_agents.style import separate_card |
31 | 32 | from agents.matmaster_agent.llm_config import DEFAULT_MODEL, MatMasterLlmConfig |
32 | 33 | from agents.matmaster_agent.locales import i18n |
33 | 34 | from agents.matmaster_agent.model import RenderTypeEnum |
34 | 35 | from agents.matmaster_agent.prompt import GLOBAL_INSTRUCTION |
35 | 36 | 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 | +) |
37 | 44 | from agents.matmaster_agent.style import ( |
38 | 45 | no_found_structure_card, |
39 | 46 | photon_consume_free_card, |
@@ -474,11 +481,9 @@ def handle_tool_error(ctx, author, error_message, error_type): |
474 | 481 | ) |
475 | 482 |
|
476 | 483 | # 更新 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}) |
482 | 487 |
|
483 | 488 | # 抛出相应的异常 |
484 | 489 | raise RuntimeError(f'Tool Execution Error: {error_type}') |
|
0 commit comments