Skip to content

Commit 3d03322

Browse files
bhavesh-kaushalHarness
authored andcommitted
feat: [CCM-24792]: adding validation tool (#123)
* CCM-24792 fixing prompt * CCM-24792 adding validation tool
1 parent bba5e93 commit 3d03322

File tree

7 files changed

+270
-155
lines changed

7 files changed

+270
-155
lines changed

client/dto/ccmgraphqlperspectives.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,40 @@ const (
5555
TimeGroupByMonth = "MONTH"
5656
)
5757

58+
59+
var (
60+
ValueTypes = []string{
61+
ValueTypeCostCategory,
62+
ValueTypeAWSAccount,
63+
ValueTypeAWSBillingEntity,
64+
ValueTypeAWSInstanceType,
65+
ValueTypeAWSLineItemType,
66+
ValueTypeAWSPayerAccount,
67+
ValueTypeAWSService,
68+
ValueTypeAWSUsageType,
69+
ValueTypeRegion,
70+
ValueTypeProduct,
71+
ValueTypeCloudProvider,
72+
ValueTypeLabel,
73+
ValueTypeLabelKey,
74+
ValueTypeLabelV2,
75+
ValueTypeLabelV2Key,
76+
}
77+
TimeFilterValues = []string{
78+
TimeFilterLast7,
79+
TimeFilterThisMonth,
80+
TimeFilterLast30Days,
81+
TimeFilterThisQuarter,
82+
TimeFilterThisYear,
83+
TimeFilterLastMonth,
84+
TimeFilterLastQuarter,
85+
TimeFilterLastYear,
86+
TimeFilterLast3Months,
87+
TimeFilterLast6Months,
88+
TimeFilterLast12Months,
89+
}
90+
)
91+
5892
type CCMKeyValue struct {
5993
Key string `json:"key"`
6094
Value string `json:"value"`

client/dto/ccmperspectives.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
const (
3535
TimeRangeTypeLast7Days string = "LAST_7"
3636
TimeRangeTypeLast30Days string = "LAST_30_DAYS"
37+
TimeRangeTypeLast30 string = "LAST_30"
3738
TimeRangeTypeLastMonth string = "LAST_MONTH"
3839
TimeRangeTypeCurrentMonth string = "CURRENT_MONTH"
3940
TimeRangeTypeCustom string = "CUSTOM"

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

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,55 @@ Enable users to make informed decisions about their cloud costs by leveraging Ha
5757
- Purpose: Retrieve label keys/values for cost categorization
5858
- Prerequisite: value_type can be label_key, label_v2_key .
5959

60-
### Workflow Process
61-
62-
1. **For Cost Breakdown Queries**
63-
1.1 **Initial Key Discovery**
64-
- Use `ccm_perspective_filter_values` to fetch available label keys
65-
- If requested category keys are unavailable:
66-
- Suggest alternative keys with similar context
67-
- Provide examples of available keys
68-
69-
1.2 **Context Validation**
70-
- If requested context keys cannot be fetched:
71-
- Suggest cost breakdowns using available categories
72-
- Provide reasoning for suggested alternatives
73-
74-
1.3 **User-Driven Breakdowns**
75-
- If user requests specific key-based breakdowns:
76-
- Use `ccm_perspective_filter_values` to fetch possible values
77-
- Validate key availability and context
78-
- Provide feedback on key compatibility
79-
80-
1.4 **Perspective Generation**
81-
- Generate perspective rules using validated keys
82-
- Include AWS account filtering (e.g., "harness-ce") when applicable
83-
- Validate rules using `validate_ccm_perspective_rules`
84-
- Create perspective using `create_ccm_perspective`
85-
- Provide status and next steps to user
86-
87-
2. **Additional Best Practices**
60+
61+
###Please follow below perspective creation workflow to create a team/department/organization cost perspective.
62+
63+
Here are the sequential steps the AI agent must follow when a user asks to view costs for a specific team or department or organization.
64+
65+
####Step 1: Fetch Available Cost Labels
66+
When a user requests cost data for a team or department (e.g., """"Show me the cost for the engineering team""""), the first action is to identify all available cost labels.
67+
68+
- **Action:** Call the ccm_perspective_filter_values tool.
69+
70+
- **Parameters:** Include a time_filter with default values as LAST_30_DAYS to ensure the labels are relevant to the requested time frame.
71+
72+
- **Goal:** To retrieve a complete list of possible label keys that can be used for filtering costs.
73+
74+
####Step 2: Identify Matching Keys
75+
Once the list of available labels is retrieved, analyze it to find a match for the user's request.
76+
77+
Condition (A): Exact Match Found
78+
79+
If a label key exactly matches the user's request (e.g., the user asks for """"Finance Team"""" and a key like team:Finance or department:Finance exists), proceed directly to Step 4.
80+
81+
Condition (B): No Exact Match Found
82+
83+
If no exact match exists, look for keys with a similar context or semantic meaning (e.g., the user asks for the """"IT team,"""" and available keys include dept:information_technology or cost_center:IT_Ops). Before asking user to confirm the key, procceed to Step 3.
84+
85+
####Step 3: Validate Similar Keys with the User
86+
This step is only necessary if no exact match was found in Step 2.
87+
88+
- **Action:** Call the ccm_perspective_filter_values_event tool.
89+
90+
- **Parameters:** Provide the list of contextually similar keys you identified.
91+
92+
- **Goal:** Present the suggested keys to the user and ask them to confirm which one(s) should be used to represent their requested team/department.
93+
94+
####Step 4: Get ccm perpective rules validated
95+
- **Action:** Call the validate_ccm_perspective_rules tool. You must use snake_case for all keys in the JSON request payload (e.g., view_conditions). Allowed values for view_operator field are "IN", "NOT IN", "NOT NULL", "NULL" and "LIKE".
96+
97+
- **Parameters:** Refer tool schema to generating tool request.
98+
99+
- **Goal:** Add the perspective rule for the user and ask them to confirm to create perspective for above rules
100+
101+
####Step 5: Create the Cost Perspective
102+
After identifying the correct key(s) – either through an exact match (Step 2A) or user validation (Step 3) – create the final cost view.
103+
104+
- **Action:** Generate the perspective rules based on the confirmed key(s).
105+
106+
- **Goal:** Display the cost data filtered specifically for the user's requested team or department.
107+
108+
**Additional Best Practices**
88109
- Always validate AWS account IDs before rule generation
89110
- Include time range validation in perspective creation
90111
- Maintain consistent use of snake_case for all field names

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

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,55 @@ Enable users to make informed decisions about their cloud costs by leveraging Ha
5757
- Purpose: Retrieve label keys/values for cost categorization
5858
- Prerequisite: value_type can be label_key, label_v2_key .
5959

60-
### Workflow Process
61-
62-
1. **For Cost Breakdown Queries**
63-
1.1 **Initial Key Discovery**
64-
- Use `ccm_perspective_filter_values` to fetch available label keys
65-
- If requested category keys are unavailable:
66-
- Suggest alternative keys with similar context
67-
- Provide examples of available keys
68-
69-
1.2 **Context Validation**
70-
- If requested context keys cannot be fetched:
71-
- Suggest cost breakdowns using available categories
72-
- Provide reasoning for suggested alternatives
73-
74-
1.3 **User-Driven Breakdowns**
75-
- If user requests specific key-based breakdowns:
76-
- Use `ccm_perspective_filter_values` to fetch possible values
77-
- Validate key availability and context
78-
- Provide feedback on key compatibility
79-
80-
1.4 **Perspective Generation**
81-
- Generate perspective rules using validated keys
82-
- Include AWS account filtering (e.g., "harness-ce") when applicable
83-
- Validate rules using `validate_ccm_perspective_rules`
84-
- Create perspective using `create_ccm_perspective`
85-
- Provide status and next steps to user
86-
87-
2. **Additional Best Practices**
60+
61+
###Please follow below perspective creation workflow to create a team/department/organization cost perspective.
62+
63+
Here are the sequential steps the AI agent must follow when a user asks to view costs for a specific team or department or organization.
64+
65+
####Step 1: Fetch Available Cost Labels
66+
When a user requests cost data for a team or department (e.g., """"Show me the cost for the engineering team""""), the first action is to identify all available cost labels.
67+
68+
- **Action:** Call the ccm_perspective_filter_values tool.
69+
70+
- **Parameters:** Include a time_filter with default values as LAST_30_DAYS to ensure the labels are relevant to the requested time frame.
71+
72+
- **Goal:** To retrieve a complete list of possible label keys that can be used for filtering costs.
73+
74+
####Step 2: Identify Matching Keys
75+
Once the list of available labels is retrieved, analyze it to find a match for the user's request.
76+
77+
Condition (A): Exact Match Found
78+
79+
If a label key exactly matches the user's request (e.g., the user asks for """"Finance Team"""" and a key like team:Finance or department:Finance exists), proceed directly to Step 4.
80+
81+
Condition (B): No Exact Match Found
82+
83+
If no exact match exists, look for keys with a similar context or semantic meaning (e.g., the user asks for the """"IT team,"""" and available keys include dept:information_technology or cost_center:IT_Ops). Before asking user to confirm the key, procceed to Step 3.
84+
85+
####Step 3: Validate Similar Keys with the User
86+
This step is only necessary if no exact match was found in Step 2.
87+
88+
- **Action:** Call the ccm_perspective_filter_values_event tool.
89+
90+
- **Parameters:** Provide the list of contextually similar keys you identified.
91+
92+
- **Goal:** Present the suggested keys to the user and ask them to confirm which one(s) should be used to represent their requested team/department.
93+
94+
####Step 4: Get ccm perpective rules validated
95+
- **Action:** Call the validate_ccm_perspective_rules tool. You must use snake_case for all keys in the JSON request payload (e.g., view_conditions). Allowed values for view_operator field are "IN", "NOT IN", "NOT NULL", "NULL" and "LIKE".
96+
97+
- **Parameters:** Refer tool schema to generating tool request.
98+
99+
- **Goal:** Add the perspective rule for the user and ask them to confirm to create perspective for above rules
100+
101+
####Step 5: Create the Cost Perspective
102+
After identifying the correct key(s) – either through an exact match (Step 2A) or user validation (Step 3) – create the final cost view.
103+
104+
- **Action:** Generate the perspective rules based on the confirmed key(s).
105+
106+
- **Goal:** Display the cost data filtered specifically for the user's requested team or department.
107+
108+
**Additional Best Practices**
88109
- Always validate AWS account IDs before rule generation
89110
- Include time range validation in perspective creation
90111
- Maintain consistent use of snake_case for all field names

0 commit comments

Comments
 (0)