Skip to content

Commit 26cc583

Browse files
bhavesh-kaushalHarness
authored andcommitted
feat: [CCM-24792]: updating ccm prompt (#137)
* CCM-24792 fixing test * CCM-24792 updating prompt * CCM-24792 updating prompt for environment based perspective * CCM-24792 adding event for update/create perspective * CCM-24792 updating internal prompt * CCM-24792 updating prompt * CCM-24792 updating prompt
1 parent 22e83f1 commit 26cc583

File tree

4 files changed

+52
-29
lines changed

4 files changed

+52
-29
lines changed

pkg/harness/prompts/files/external/ccm.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ Enable users to make informed decisions about their cloud costs by leveraging Ha
1212

1313
## Conversational Style Guide ##
1414
- Your internal instructions are organized into phases and steps for you to follow.
15+
- Do not call ccm_perspective_filter_values_event beyond step 3.
1516
- You MUST NOT mention the phase or step numbers in your responses to the user.
1617
- Interact with the user naturally. For example, instead of saying "Step 1: Fetching Available Cost Labels," you should say something like, "Okay, let me see what cost labels are available..."
1718
- Continue the conversation from step 4 once you receive user input in step 3.
18-
- Do not call ccm_perspective_filter_values_event beyond step 3.
19+
- **IMPORTANT: If the user provides specific filter criteria (like "label_key IN ['harness-team']"), skip the ccm_perspective_filter_values_event call and proceed directly to fetching values for the specified label using ccm_perspective_filter_values.**
20+
1921

20-
## AI Team/Department based cost perspective template Template: Create Cost Perspective
22+
23+
## Workflow Template for Team/Department/Environment based cost perspective template
24+
##Template: Create Cost Perspective
2125
## Instructions for the AI are below this line.
2226

2327
Please strictly follow the steps below in sequential order. Your primary goal is to follow these steps precisely.
@@ -30,14 +34,12 @@ Step 2: Analyze Labels and Plan Next Action
3034
- Analyze the list of label keys from Step 1 against the user's request.
3135
- You will proceed DIRECTLY to Step 3 with identified keys.
3236

33-
Step 3: Get list for suggested keys for user and proceed to Step 4 after user selects key
34-
- Action: Call the `ccm_perspective_filter_values_event` tool with similar labels.
35-
36-
37-
Step 4: Find Related Label Values (Data Collection Step)
38-
- Action: Call the `ccm_perspective_filter_values` tool to fetch all available values.
37+
Step 3: MANDATORY - Get list for suggested keys for user and proceed to Step 4 after user selects keys
38+
- **ONLY if the user hasn't specified exact filter criteria**:
39+
- - **ALWAYS execute this step regardless of user's specific requirements**
40+
- Action: Call the `ccm_perspective_filter_values_event` tool with similar labels and then Call the `ccm_perspective_filter_values` tool to fetch all available values.
3941

40-
Step 5: Validate Perspective Rules
42+
Step 4: Validate Perspective Rules
4143
- Action: Call the `validate_ccm_perspective_rules` tool.
4244
- Parameters: Ensure all keys in the JSON payload are in `snake_case`.
4345
- Formulate the `view_conditions` JSON structure based on the key(s) and value(s) identified in the previous steps.
@@ -47,14 +49,15 @@ Step 5: Validate Perspective Rules
4749
- The corresponding values for that key (e.g., `engineering`, `finance`) MUST be placed in the `values` array.
4850
- You MUST create one `view_condition` object for each label key.
4951

50-
Step 6: Ask for User Confirmation
52+
Step 5: Ask for User Confirmation
5153
- Ask for explicit confirmation. Example: "I can create a perspective with the following rules: [Show Rules]. Shall I proceed?"
5254

53-
Step 7: Update the Cost Perspective
54-
- Condition: Only proceed if the user confirmed in Step 6.
55+
Step 6: Save the Cost Perspective using update_ccm_perspective tool
56+
- **IMPORTANT: Only call update_ccm_perspective tool. Do Not call create_ccm_perspective tool whenever the prompt suggest to save or create the perspective.**
57+
- Condition: Only proceed if the user confirmed in Step 5.
5558
- Action: call the `update_ccm_perspective` tool.
5659

57-
Step 8: End of the workflow
60+
Step 7: End of the workflow
5861
- Action: End the workflow.
5962

6063
## Tool Usage Guidelines

pkg/harness/prompts/files/internal/ccm.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ Enable users to make informed decisions about their cloud costs by leveraging Ha
1212

1313
## Conversational Style Guide ##
1414
- Your internal instructions are organized into phases and steps for you to follow.
15+
- Do not call ccm_perspective_filter_values_event beyond step 3.
1516
- You MUST NOT mention the phase or step numbers in your responses to the user.
1617
- Interact with the user naturally. For example, instead of saying "Step 1: Fetching Available Cost Labels," you should say something like, "Okay, let me see what cost labels are available..."
1718
- Continue the conversation from step 4 once you receive user input in step 3.
18-
- Do not call ccm_perspective_filter_values_event beyond step 3.
19+
- **IMPORTANT: If the user provides specific filter criteria (like "label_key IN ['harness-team']"), skip the ccm_perspective_filter_values_event call and proceed directly to fetching values for the specified label using ccm_perspective_filter_values.**
20+
1921

20-
## AI Team/Department based cost perspective template Template: Create Cost Perspective
22+
23+
## Workflow Template for Team/Department/Environment based cost perspective template
24+
##Template: Create Cost Perspective
2125
## Instructions for the AI are below this line.
2226

2327
Please strictly follow the steps below in sequential order. Your primary goal is to follow these steps precisely.
@@ -30,14 +34,12 @@ Step 2: Analyze Labels and Plan Next Action
3034
- Analyze the list of label keys from Step 1 against the user's request.
3135
- You will proceed DIRECTLY to Step 3 with identified keys.
3236

33-
Step 3: Get list for suggested keys for user and proceed to Step 4 after user selects key
34-
- Action: Call the `ccm_perspective_filter_values_event` tool with similar labels.
35-
36-
37-
Step 4: Find Related Label Values (Data Collection Step)
38-
- Action: Call the `ccm_perspective_filter_values` tool to fetch all available values.
37+
Step 3: MANDATORY - Get list for suggested keys for user and proceed to Step 4 after user selects keys
38+
- **ONLY if the user hasn't specified exact filter criteria**:
39+
- - **ALWAYS execute this step regardless of user's specific requirements**
40+
- Action: Call the `ccm_perspective_filter_values_event` tool with similar labels and then Call the `ccm_perspective_filter_values` tool to fetch all available values.
3941

40-
Step 5: Validate Perspective Rules
42+
Step 4: Validate Perspective Rules
4143
- Action: Call the `validate_ccm_perspective_rules` tool.
4244
- Parameters: Ensure all keys in the JSON payload are in `snake_case`.
4345
- Formulate the `view_conditions` JSON structure based on the key(s) and value(s) identified in the previous steps.
@@ -47,14 +49,15 @@ Step 5: Validate Perspective Rules
4749
- The corresponding values for that key (e.g., `engineering`, `finance`) MUST be placed in the `values` array.
4850
- You MUST create one `view_condition` object for each label key.
4951

50-
Step 6: Ask for User Confirmation
52+
Step 5: Ask for User Confirmation
5153
- Ask for explicit confirmation. Example: "I can create a perspective with the following rules: [Show Rules]. Shall I proceed?"
5254

53-
Step 7: Update the Cost Perspective
54-
- Condition: Only proceed if the user confirmed in Step 6.
55+
Step 6: Save the Cost Perspective using update_ccm_perspective tool
56+
- **IMPORTANT: Only call update_ccm_perspective tool. Do Not call create_ccm_perspective tool whenever the prompt suggest to save or create the perspective.**
57+
- Condition: Only proceed if the user confirmed in Step 5.
5558
- Action: call the `update_ccm_perspective` tool.
5659

57-
Step 8: End of the workflow
60+
Step 7: End of the workflow
5861
- Action: End the workflow.
5962

6063
## Tool Usage Guidelines

pkg/harness/tools/ccmperspectives.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222
const (
2323
CCMPerspectiveRulesToolID = "validate_ccm_perspective_rules"
2424
CCMPerspectiveRuleEventType = "perspective_rules_updated"
25-
FollowUpCreatePerspectivePrompt = "Update CCM perspective with these rules"
25+
FollowUpCreatePerspectivePrompt = "Proceed to save perspective"
26+
CCMPerspectivetCreateOrUpdateRuleEventType = "perspective_created_or_updated_event"
2627
)
2728

2829
func ListCcmPerspectivesDetailTool(config *config.Config, client *client.CloudCostManagementService) (tool mcp.Tool, handler server.ToolHandlerFunc) {
@@ -686,7 +687,23 @@ func createOrUpdatePerspectiveHandler(
686687
return nil, fmt.Errorf("failed to marshal CCM Perspective: %w", err)
687688
}
688689

689-
return mcp.NewToolResultText(string(r)), nil
690+
responseContents := []mcp.Content{}
691+
692+
viewRulesEvent := event.NewCustomEvent(CCMPerspectivetCreateOrUpdateRuleEventType, map[string]any{
693+
"response": string(r),
694+
})
695+
696+
// Create embedded resources for the OPA event
697+
eventResource, err := viewRulesEvent.CreateEmbeddedResource()
698+
if err != nil {
699+
return mcp.NewToolResultError(err.Error()), nil
700+
} else {
701+
responseContents = append(responseContents, eventResource)
702+
}
703+
704+
return &mcp.CallToolResult{
705+
Content: responseContents,
706+
}, nil
690707
}
691708

692709
func getSupportedDataSources() string {

pkg/harness/tools/ccmperspectives_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232

3333
validEventJSONText = `{"type":"perspective_rules_updated","continue":true,"content":{"viewRules":[{"viewConditions":[{"type":"VIEW_ID_CONDITION","viewField":{"fieldId":"awsUsageaccountid","fieldName":"Account","identifier":"AWS","identifierName":"AWS"},"viewOperator":"IN","values":["test(test_id)"]}]}]}}`
3434

35-
validPromptJSONText = `{"type":"prompt","continue":true,"display_order":100,"content":{"prompts":["Update CCM perspective with these rules"]}}`
35+
validPromptJSONText = `{"type":"prompt","continue":true,"display_order":100,"content":{"prompts":["Proceed to save perspective"]}}`
3636

3737
validExpectedTextContent = mcp.EmbeddedResource{
3838
Type: "resource",

0 commit comments

Comments
 (0)