diff --git a/api/libs/agents/src/agents/modes/analysis.rs b/api/libs/agents/src/agents/modes/analysis.rs index 1fdd28484..8479e321d 100644 --- a/api/libs/agents/src/agents/modes/analysis.rs +++ b/api/libs/agents/src/agents/modes/analysis.rs @@ -205,7 +205,9 @@ You can create, update, or modify the following assets, which are automatically - **Review and Update**: After creation, metrics can be reviewed and updated individually or in bulk as needed. - **Use in Dashboards**: Metrics can be saved to dashboards for further use. - **Percentage Formatting**: When defining a metric with a percentage column (style: `percent`) where the SQL returns the value as a decimal (e.g., 0.75), remember to set the `multiplier` in `columnLabelFormats` to 100 to display it correctly as 75%. If the value is already represented as a percentage (e.g., 75), the multiplier should be 1 (or omitted as it defaults to 1). - - **Date Grouping**: For metrics visualizing date columns on the X-axis (e.g., line or combo charts), remember to set the `xAxisTimeInterval` field within the `xAxisConfig` section of `chartConfig` to control how dates are grouped (e.g., `day`, `week`, `month`). This is crucial for meaningful time-series visualizations. + - **Date Axis Handling**: When visualizing date/time data on the X-axis (e.g., line/combo charts), you MUST configure the `xAxisConfig` section in the `chartConfig`. Specifically: + - Set the `xAxisTimeInterval` field to define how the dates should be grouped (`day`, `week`, `month`, `quarter`, `year`). This is essential for correct time-series aggregation and display. + - Use the `dateFormat` property within the relevant `columnLabelFormats` entry to format the date labels according to the `xAxisTimeInterval`. Recommended formats: Year ('YYYY'), Quarter ('[Q]Q YYYY'), Month ('MMM YYYY' or 'MMMM'), Week/Day ('MMM D, YYYY' or 'MMM D'). - **Dashboards**: Collections of metrics displaying live data, refreshed on each page load. Dashboards offer a dynamic, real-time view without descriptions or commentary. @@ -252,6 +254,7 @@ To conclude your worklow, you use the `finish_and_respond` tool to send a final - Use explicit ordering for custom buckets or categories. - Avoid division by zero errors by using NULLIF() or CASE statements (e.g., `SELECT amount / NULLIF(quantity, 0)` or `CASE WHEN quantity = 0 THEN NULL ELSE amount / quantity END`). - Consider potential data duplication and apply deduplication techniques (e.g., `DISTINCT`, `GROUP BY`) where necessary. + - **Fill Missing Values**: For metrics, especially in time series, fill potentially missing values (NULLs) using `COALESCE(, 0)` to default them to zero, ensuring continuous data unless the user specifically requests otherwise. --- You are an agent - please keep going until the user's query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. diff --git a/api/libs/agents/src/tools/categories/file_tools/common.rs b/api/libs/agents/src/tools/categories/file_tools/common.rs index 9c26b1db6..9c9210ec6 100644 --- a/api/libs/agents/src/tools/categories/file_tools/common.rs +++ b/api/libs/agents/src/tools/categories/file_tools/common.rs @@ -291,7 +291,7 @@ definitions: type: boolean # Axis Configurations xAxisConfig: - description: Optional X-axis configuration. Primarily used to set the `xAxisTimeInterval` for date axes (day, week, month, etc.). Other properties control label visibility, title, rotation, and zoom. + description: REQUIRED for charts with a date/time column on the X-axis. MUST contain `xAxisTimeInterval` to specify the grouping (day, week, month, quarter, year). Other properties control label visibility, title, rotation, and zoom. $ref: '#/definitions/x_axis_config' yAxisConfig: description: Optional Y-axis configuration. Primarily used to set the `yAxisShowAxisLabel` and `yAxisShowAxisTitle` properties. Other properties control label visibility, title, rotation, and zoom. @@ -313,7 +313,7 @@ definitions: xAxisTimeInterval: type: string enum: [day, week, month, quarter, year, 'null'] - description: Time interval for X-axis (combo/line charts). Default: null. + description: REQUIRED time interval for grouping date/time values on the X-axis (e.g., for line/combo charts). MUST be set if the X-axis represents time. Default: null. xAxisShowAxisLabel: type: boolean description: Show X-axis labels. Default: true. @@ -436,7 +436,13 @@ definitions: description: Currency code for currency formatting (e.g., USD, EUR) dateFormat: type: string - description: Format string for date display (must be compatible with Day.js format strings). + description: | + Format string for date display (must be compatible with Day.js format strings). + RULE: Choose format based on xAxisTimeInterval: + - year: 'YYYY' (e.g., 2025) + - quarter: '[Q]Q YYYY' (e.g., Q1 2025) + - month: 'MMM YYYY' (e.g., Jan 2025) or 'MMMM' (e.g., January) if context is clear. + - week/day: 'MMM D, YYYY' (e.g., Jan 25, 2025) or 'MMM D' (e.g., Jan 25) if context is clear. useRelativeTime: type: boolean description: Whether to display dates as relative time (e.g., 2 days ago)