investigation-cost-guardrail — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited investigation-cost-guardrail (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill acts as a cost guardrail for DevOps Agent investigations. Before pulling any data, it:
You MUST determine:
DevOps Agent monitors resources across ALL regions in an account, and a single investigation can span multiple regions. You MUST derive each region from concrete evidence — never assume or default to us-east-1:
arn:aws:logs:eu-west-1:... → eu-west-1)You MUST build a list of all involved regions. For each region, Step 2 queries its log groups and its own Pricing API rate separately (rates differ by region).
You MUST identify the Agent Space region (where DevOps Agent is deployed) to detect cross-region transfer in Step 3.
The Agent Space region is provided in the system context:
arn:aws:aidevops:<REGION>:<ACCOUNT>:agentspace/<ID>us-east-1)If it is not available, ask the user:
"I need to know which region your DevOps Agent is deployed in to calculate cross-region data transfer costs. Which region is your Agent Space in?"
Common mistake: assuming workload region = Agent Space region. Always verify both independently.
You MUST NOT:
When inputs are missing (region, log group, or time window), do NOT stop at open-ended questions. Still produce the Step 4 visual plan with worst-case or fallback estimates (flagged ⚠️) and an explicit decision, then list what the user should provide. A missing time window always results in 🚫 CANCEL.
On failure: show the worst-case plan and CANCEL decision, then ask the user to clarify what service, resource, region, or time window is affected.
You MUST query real data. Do NOT estimate without API calls.
CRITICAL: You MUST use the AWS Pricing API to get the correct per-unit rate for the workload region. Do NOT hardcode $0.005/GB — rates vary by region. See references/pricing-reference.md for exact API calls and region prefix mapping. If the Pricing API fails, fall back to the floor estimates in that file and flag with ⚠️.
CRITICAL: If a time window is provided (even a broad one like "last 60 days"), you MUST use Path A. Path B is ONLY for when no time window is provided at all.
#### Path A: Time window provided (any duration)
You MUST query the IncomingBytes CloudWatch metric for the exact time window:
aws cloudwatch get-metric-statistics \
--namespace "AWS/Logs" \
--metric-name "IncomingBytes" \
--dimensions Name=LogGroupName,Value="<LOG_GROUP_NAME>" \
--start-time "<START>" \
--end-time "<END>" \
--period <WINDOW_SECONDS> \
--statistics Sum \
--region <workload_region>Calculate: scan_gb = Sum / 1e9 → cost = scan_gb × regional_rate (use 1e9 = GB, matching AWS billing — NOT 1024³, which is GiB and under-counts ~7%)
#### Path B: No time window provided
You MUST query describe-log-groups to get total storedBytes (worst case):
aws logs describe-log-groups \
--log-group-name-prefix "<PREFIX>" \
--region <workload_region>Calculate: scan_gb = storedBytes / 1e9 → cost = scan_gb × regional_rate (1e9 = GB, matching AWS billing)
You MUST count the number of metrics and periods the investigation would request:
metrics_cost = (num_metrics × num_periods) / 1000 × regional_rateFor example: 4 metrics × 60 periods = 240 metric requests → $0.0024
If the investigation would scan X-Ray traces, you MUST estimate:
xray_cost = estimated_traces / 1,000,000 × regional_rateIf X-Ray is not configured or not relevant, show $0.00 in the visual plan.
#### X-Ray trace count estimation
To estimate trace count for a time window:
aws xray get-trace-summaries \
--start-time <START> \
--end-time <END> \
--region <workload_region>Preferred (precise): paginate get-trace-summaries over the FULL window (follow NextToken) and sum TracesProcessedCount. This is the exact count of traces the investigation would scan — no extrapolation needed. Note: get-trace-summaries is itself a billable trace-fetch call, so this estimation has a small X-Ray cost of its own.
Fallback (only for very large windows, less precise): query a representative sample window and extrapolate total_traces = (sample_count / sample_minutes) × total_minutes. Trace volume is bursty, so flag this with ⚠️: "Trace count extrapolated from sample — actual may vary." Prefer the longest sample you can afford (not 5 min) to reduce error.
If X-Ray returns 0 traces, the service may not have tracing enabled — show $0.00 and note "X-Ray not configured or no traces in window".
CloudTrail LookupEvents — FREE. The standard cloudtrail:LookupEvents API (last 90 days of management events) has no cost. Investigations use only this — show it in the visual plan as $0.00 — free and do NOT estimate it.
#### CloudTrail limitations (platform may block LookupEvents)
⚠️ Known issue: the agent platform may block cloudtrail:LookupEvents. If this happens:
⚠️ CloudTrail LookupEvents — BLOCKED BY PLATFORM
→ Cannot estimate CloudTrail activity
→ "What changed?" analysis will be unavailable"I won't be able to check what infrastructure changes occurred because CloudTrail access is blocked. The investigation will proceed without change analysis."
LookupEvents is free anyway ($0.00), so a block has no cost impact.If the investigation would use Contributor Insights rules:
contributor_insights_cost = num_rules × (matching_events / 1000) × regional_rateIf the investigation would use Live Tail to stream logs in real time:
live_tail_cost = session_minutes × regional_rateThe following APIs have no cost but you MUST still show them in the visual plan for transparency:
CloudWatch Logs FilterLogEvents — freeCloudTrail LookupEvents — freeEC2/ECS/RDS Describe* calls — freeCloudWatch GetMetricStatistics — negligible ($0.01 per 1,000 requests)If any CLI command fails, fall back to 5 GB per log group as a conservative estimate. You MUST flag this in the visual plan with ⚠️:
⚠️ /aws/ecs/prod-api — ESTIMATED (no permission)
→ Assumed: 5 GB │ Cost: $0.0250 (may be higher)DevOps Agent's Agent Space is in one region, but the resources it investigates are often in other regions. Cross-region cost applies ONLY to the result bytes returned across regions — NOT the scanned volume. The returned size depends on the query type, so estimate returned_data_gb accordingly:
for each workload_region ≠ agent_space_region:
if aggregation/stats query (counts, group-by, summaries):
returned_data_gb ≈ small (results are tiny — use ~1% of scan_gb, or a few MB cap)
elif raw-event / trace fetch (returns matching log lines or traces):
returned_data_gb ≈ up to 100% of the matched bytes (use matched/returned bytes if known)
else (query type unknown):
returned_data_gb ≈ scan_gb × 0.15 # rough UPPER-BOUND heuristic — flag with ⚠️
data_transfer_cost += returned_data_gb × $0.02/GBPrefer the actual returned-result size when the query type is known (aggregations return almost nothing; raw fetches can return a large share). The 0.15 factor is only a fallback when the query shape is unknown — label it ⚠️ as an upper-bound estimate, not a precise figure.
If a region matches the Agent Space region: no transfer cost for that region. If all resources are in the Agent Space region: total data transfer cost = $0.00.
You MUST present the visual plan to the user before the decision gate.
You MUST always render this plan and an explicit decision, even when required inputs are missing or AWS credentials are unavailable. If you cannot query real data (no credentials, permission denied, or the region/log group is unknown), still produce the plan using worst-case storedBytes or the 5 GB-per-log-group fallback, flag those lines with ⚠️, and state the decision. Do NOT replace the plan with open-ended clarifying questions: show the plan and the decision first, then list what is missing. When no time window is provided, the decision is always 🚫 CANCEL (show the worst-case plan and say "CANCELLED — no time window").
You MUST show:
See references/example-output.md for format examples.
You MUST apply these rules strictly:
| Condition | Decision | Action |
|---|---|---|
| No time window provided | 🚫 CANCEL | Show worst-case cost, ask for time window |
| Time window + cost < threshold (default $10) | ✅ PROCEED | Begin investigation |
| Time window + cost ≥ threshold | 🚫 CANCEL | Show cost, ask for operator approval or a narrower scope |
On CANCEL, you MUST:
On PROCEED, you MUST:
You MUST provide specific, actionable suggestions:
| User can provide | How it reduces cost | Estimated savings |
|---|---|---|
| Exact timestamp (± 5 min) | Scans 10 min instead of all stored data | ~90%+ |
| Specific log group name | 1 group instead of N | Up to 90% |
| Known error message | Free FilterLogEvents instead of Logs Insights | 100% of Logs Insights cost |
| "Skip X-Ray" / "Skip CloudTrail" | Eliminates those cost components | Variable |
| "Same region only" | No cross-region transfer | Eliminates DT cost |
The skill uses a threshold to decide proceed/cancel. Default: $10.00 — the agent proceeds automatically when the estimate is under the threshold and cancels (requesting approval) when it is exceeded.
The user can set a custom threshold for the session by saying:
Remember it for the session:
| Threshold | Behavior |
|---|---|
| $0.00 | Always show plan, always require approval before any paid query (most conservative) |
| $10.00 (default) | Auto-proceed if under $10, cancel and request approval if exceeded |
| Custom | Auto-proceed if under, cancel if over |
To reset: "Reset cost threshold to default".
The operator can also set a persistent default in the Agent Space configuration instruction (e.g., "use a cost threshold of $5 for all investigations"), which overrides the built-in $10 default. A threshold the user states in the current conversation takes precedence for that session.
You MUST NOT cancel or flag when:
You MUST cancel when:
"Cannot determine" is valid when:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.