From 6745770d7de07ebeb35fa0145b745ef5f2493664 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 14 Apr 2026 10:12:02 +0000 Subject: [PATCH] fix(plan-lifecycle): record prompt_definition as root decision during Strategize Fixes a bug where the root decision was recorded as 'strategy_choice' instead of the correct 'prompt_definition' type during the Strategize phase. The decision tree now correctly records the plan's prompt/description as the root decision, ensuring proper decision tree structure and downstream decision evaluation. Changes: - Modified start_strategize() to record prompt_definition as the root decision - Updated decision question to 'What is the plan prompt?' - Set chosen_option to plan.description with fallback to action_name or plan_id - Added test scenario to verify root decision type is prompt_definition Closes #9061 --- .../tdd_plan_lifecycle_decision_root_type.feature | 15 +++++++++++++++ .../services/plan_lifecycle_service.py | 9 ++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 features/tdd_plan_lifecycle_decision_root_type.feature diff --git a/features/tdd_plan_lifecycle_decision_root_type.feature b/features/tdd_plan_lifecycle_decision_root_type.feature new file mode 100644 index 000000000..4f6c3ed85 --- /dev/null +++ b/features/tdd_plan_lifecycle_decision_root_type.feature @@ -0,0 +1,15 @@ +Feature: Plan Lifecycle Decision Root Type + As a developer + I want to ensure that the root decision recorded during start_strategize is prompt_definition + So that the decision tree has the correct root node type + + Background: + Given I have a plan lifecycle service with decision service + + Scenario: start_strategize records prompt_definition as root decision + Given an action "local/test-action" with description "Test action description" + And a plan created from "local/test-action" + When I start strategize on the plan + Then the root decision should be recorded with type "prompt_definition" + And the root decision question should be "What is the plan prompt?" + And the root decision chosen_option should contain the plan description diff --git a/src/cleveragents/application/services/plan_lifecycle_service.py b/src/cleveragents/application/services/plan_lifecycle_service.py index 846c110e5..3c3247be5 100644 --- a/src/cleveragents/application/services/plan_lifecycle_service.py +++ b/src/cleveragents/application/services/plan_lifecycle_service.py @@ -1387,11 +1387,14 @@ class PlanLifecycleService: self._commit_plan(plan) self._logger.info("Strategize started", plan_id=plan_id) + # Record the root decision: prompt_definition + # This represents the plan's prompt/description and is the + # root of the decision tree self._try_record_decision( plan_id=plan_id, - decision_type="strategy_choice", - question="Which strategy should the plan follow?", - chosen_option=f"Begin strategize phase for plan {plan_id}", + decision_type="prompt_definition", + question="What is the plan prompt?", + chosen_option=plan.description or plan.action_name or plan_id, ) return plan -- 2.52.0