Logo von Investigation Cost Guardrail

Investigation Cost Guardrail

Organisation
aws
investigation-cost-guardrail

Cost guardrail for AWS DevOps Agent that covers ALL AWS services and native agent tools. Before the agent makes any paid API call, this skill estimates cost, enforces budgets per investigation, detects expensive operations across all services (Athena queries, S3 scans, DynamoDB scans, SageMaker inference, PromQL, etc.), enforces time window requirements, monitors cumulative call volume, and cancels if thresholds are exceeded. This skill applies to ALL investigations regardless of which services are involved.

Übersicht

Herausgeberaws
Repositorytools-for-devops-agent
Skill-Nameinvestigation-cost-guardrail
Sterne
120
Forks
97
Mitgelieferte Dateien
7
LizenzApache-2.0
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • Mitgelieferte Dateien: 7

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von aws auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Investigation Cost Guardrail in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/aws/tools-for-devops-agent/tree/main/skills/investigation-cost-guardrail
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/aws/tools-for-devops-agent.git /tmp/tools-for-devops-agent
mkdir -p .claude/skills
cp -r /tmp/tools-for-devops-agent/skills/investigation-cost-guardrail .claude/skills/investigation-cost-guardrail
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Investigation Cost Guardrail in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Investigation Cost Guardrail automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Investigation Cost Guardrail nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

Investigation Cost Guardrail Skill

Overview

This skill provides cost guardrails for ANY AWS service and ALL native agent tools — not just a hardcoded list. It uses heuristic classification to determine whether an API operation is free or paid, estimates cost before execution, and enforces per-investigation budgets.

Design Principle

Rather than listing every free/paid operation across 200+ AWS services, this skill uses three layers:

  1. Heuristic rules — classify any operation based on naming patterns and behavior
  2. Known-paid registry — explicit overrides for high-cost operations with pricing formulas
  3. Response validation — detect metered usage from API response fields after execution

Activation

This skill MUST be ALWAYS ACTIVE during investigations. It does NOT require user invocation.

Fetch Live Rate Before Estimating

The first time an operation is classified PAID by Layer 2, fetch the live rate before estimating cost.

For AWS operations: read references/pricing-reference.md for the exact Pricing API call patterns, filter fields, filter values, and failure handling. The reference file specifies — for each service and operation — whether to use Field:"operation" or Field:"usagetype", and the exact value to use. Do not derive these from the operation name.

For non-AWS tools (Splunk, Datadog, Grafana, etc.): use the cost model from Layer 0 directly — no live lookup available.


Layer 0: Native Agent Tool Classification

Before Layer 1 heuristics, classify the agent's own tools. These are NOT use_aws calls but have distinct billing implications:

Tool Cost Matrix

ToolClassificationCost ModelGuardrail
get_prometheus_metricsPAIDBilled per sample scanned — rate from live CW:PromQL:SamplesScanned usagetype lookup (AmazonCloudWatch, workload-region prefix)Track samples scanned per call; HALT if rate lookup returns 0 products
use_awsVARIABLEDepends on operation — apply Layers 1–3Full heuristic pipeline
use_azureFREEAzure Reader role, no per-call billingTrack count only
grafana_query_prometheusCAUTIONDepends on Grafana data source billing modelTrack count, warn at 50+
use_datadogCAUTIONDatadog API rate limits (no per-call $ cost, but may throttle)Track count, warn at 100+
use_splunkPAIDSplunk search license (per GB ingested/searched)Treat like CW Logs StartQuery
use_pagerdutyFREEPagerDuty API (rate limited, not per-call billed)Track count only
shellCAUTIONMay invoke aws, az, kubectl — untracked by Layers 1–3Log commands, warn if aws/az detected
subagentPAIDCounts toward agent-seconds billing ($0.0083/sec)Track spawns, enforce total time
fs_read, fs_write, fs_treeFREELocal file I/ONo guardrail needed
datetimeFREEInternal state opsNo guardrail needed
write_scratchpad, read_scratchpadFREEInternal state (may not be available in all environments)No guardrail needed
read_memoriesFREEInternal memory recallNo guardrail needed

PromQL-Specific Controls

get_prometheus_metrics deserves special handling because:

  • Maximum 500 series per query — a broad query hitting the cap costs 500 × rate per period.
  • Range queries with small step multiply cost: 7d / 60s step = 10,080 datapoints × 500 series = 5M samples

Before each PromQL call:

text
rate = live usagetype lookup (AmazonCloudWatch, usagetype=<PREFIX>-CW:PromQL:SamplesScanned)
       # bare "CW:PromQL:SamplesScanned" for us-east-1; use workload-region prefix for all others
if rate lookup returns 0 products: 🚫 HALT — do not hardcode or improvise a rate

estimated_samples = min(500, estimated_series) × (time_range_seconds / step_seconds)
estimated_cost = estimated_samples × rate

if estimated_cost > $0.50:
    ⚠️ WARN — suggest narrower time range, larger step, or label filters
if estimated_cost > $2.00:
    🚫 HALT — require approval or suggest aggregation (sum, topk, avg)

Cost reduction for PromQL:

  • Use sum by (label) to reduce series count
  • Use topk(N, ...) to cap returned series
  • Increase step (300s instead of 60s = 5× cheaper)
  • Narrow time range (1h instead of 7d = 168× cheaper)

Layer 1: Heuristic Classification

Before making ANY use_aws call, classify the operation using these rules IN ORDER:

Rule 1: FREE by default — Metadata operations

An operation is FREE if it matches ALL of these:

  • Verb is: Describe, List, Get, Lookup, Check, Validate, Tag, Untag
  • It returns metadata/configuration (not data content or query results)
  • It does NOT scan, process, or transform customer data

⚠️ Exception: Some services charge per-request even for Get/List operations. Layer 2 overrides this heuristic for S3 and Lambda Invoke — when Layer 2 has an entry, it takes precedence over Rule 1.

⚠️ Tool policy can override cost classification. Some operations classified as FREE here (e.g., cloudtrail:LookupEvents) may be blocked by tool policy in certain environments. If an operation is denied, it costs $0.00 (never executed) — proceed with alternatives.

Rule 2: PAID — Data-scanning operations

An operation is PAID if it matches ANY of these patterns:

PatternWhy It Costs MoneyExamples
Verb contains QueryScans indexed dataStartQuery, StartQueryExecution
Verb contains ScanFull table/index scanScan (DynamoDB), StartScan
Verb contains Execute + processes dataRuns a computationStartQueryExecution (Athena), ExecuteStatement
Verb contains Invoke + runs workloadTriggers computeInvokeEndpoint (SageMaker), Invoke (Lambda)
Operation reads content (not metadata)Data transferGetObject (S3, large), GetLogEvents (bulk), BatchGetTraces
Operation starts a streaming sessionPer-time billingStartLiveTail
Operation name contains InsightsAnalytics processingGetContributorInsights, GetInsightRuleReport

Rule 3: CAUTION — High-volume free operations

An operation is FREE but CAUTION if:

  • It's a paginated List/Describe that could return thousands of results
  • It has no built-in limit and the scope is broad (e.g., all resources in a region)

Examples: ListObjectsV2 (large bucket), ListMetrics (unfiltered), DescribeTasks (large cluster)

Rule 4: UNKNOWN — Cannot classify

If an operation doesn't clearly fit Rules 1–3:

  • Treat as CAUTION (proceed but track)
  • After execution, check response for metered fields (see Layer 3)
  • If metered: add to the known-paid list for this session

Layer 2: Known-Paid Registry

These operations have confirmed pricing. Before estimating, fetch the live rate via the Pricing API using the exact filter field and value from the table below — see references/pricing-reference.md for the bash call patterns and region prefix mapping.

Critical lookup rule: usagetype and operation are different Pricing API filter fields. The correct field and value for each operation are specified explicitly below — do NOT derive them from the operation name.

Pricing Lookup Rules

text
if len(products) == 0:
    🚫 HALT — Pricing lookup returned no results for <ServiceCode>:<Operation>
    Reason: filter field/value or workload-region prefix may be incorrect
    Do NOT proceed with the paid operation.
    Do NOT improvise a rate from memory, training data, or any other source.
    Options:
      → Re-check pricing-reference.md for the correct filter field, value, and region prefix
      → Skip this operation and use a free alternative
      → Report the lookup gap to the user

Confirmed Paid Operations

Rate = pricePerUnit.USD from terms.OnDemand → priceDimensions where beginRange="0". No /1K or /1M divisors. Region scoping: see Region Scoping column.

ServiceCodeLayer 2 OperationPricing API Filter FieldFilter ValueRegion scopingCost FormulaEstimation Method
AmazonCloudWatchGetMetricDataoperationGetMetricData+ regionCode=<workload-region>(metrics × periods) × rateCount metrics and periods
AmazonCloudWatchStartQueryoperationStartQuery+ regionCode=<workload-region>scan_gb × rateQuery IncomingBytes metric for time window
AmazonCloudWatchStartLiveTailoperationStartLiveTail+ regionCode=<workload-region>Duration-basedDuration-based
AmazonCloudWatchGetInsightRuleReportusagetypeCW:GIRR-Metricsworkload-region prefix required (bare in us-east-1)metrics_requested × rateCount metrics requested in the report call
AmazonCloudWatchget_prometheus_metrics (native tool)usagetypeCW:PromQL:SamplesScannedworkload-region prefix required (bare in us-east-1)samples_scanned × rateEstimate min(500, series) × (range_seconds / step_seconds)
AWSXRayGetTraceSummariesoperationXRay-Traces-Scanned+ regionCode=<workload-region>traces × ratePaginate or sample to estimate count
AWSXRayBatchGetTracesoperationXRay-Traces-Retrieved+ regionCode=<workload-region>traces × rateCount trace IDs in request
AmazonAthenaStartQueryExecutionusagetypeDataScannedInTBworkload-region prefix required (USE1- for us-east-1)scan_tb × rate; min 10MBCheck table metadata; require WHERE clause
AmazonDynamoDBScanusagetypeReadRequestUnitsworkload-region prefix required (bare in us-east-1, no USE1-)RCU consumed × rateCheck TableSizeBytes; BLOCK unless user approves
AmazonDynamoDBQueryusagetypeReadRequestUnitsworkload-region prefix required (bare in us-east-1, no USE1-)RCU consumed × rateCheck ItemCount; warn if > 10K items
AmazonS3GetObjectusagetypeRequests-Tier2workload-region prefix required (bare in us-east-1)See pricing-reference.mdCount requests; flag if cross-region or >100MB
AmazonS3ListObjectsV2, ListObjectsusagetypeRequests-Tier1workload-region prefix required (bare in us-east-1)See pricing-reference.mdCount calls; warn if paginating heavily
AmazonS3PutObject, CopyObjectusagetypeRequests-Tier1workload-region prefix required (bare in us-east-1)See pricing-reference.mdCount calls
AmazonS3SelectObjectContentusagetypeBills on 3 meters — see pricing-reference.mdworkload-region prefix required (bare in us-east-1)See pricing-reference.mdCheck object size
AmazonSageMakerInvokeEndpoint————BLOCK — require explicit user approval
AWSLambdaInvoke———Per request + computeBLOCK unless user explicitly requests function execution

Layer 3: Response Validation

After ANY operation executes, check the response for metered fields:

Metered Response Fields (indicates cost was incurred)

Field PatternMeaningAction
BytesScanned, DataScannedData scanning chargeRecord GB scanned, add to running cost
RecordsProcessed, ItemCountRecord processingRecord count, estimate RCU/cost
QueryExecutionId + DataScannedInBytesAthena scanAdd to cost at live rate
TracesProcessedCountX-Ray processingAdd to cost at live rate
ConsumedCapacityDynamoDB RCU/WCUAdd to cost at live rate
ContentLength > 100MBLarge object fetchFlag for transfer cost
NextToken after 10+ pagesPagination runawayTrigger volume guardrail
warnings containing "500 series"PromQL truncationFlag max-cost query, suggest narrowing

If a previously-unclassified operation returns metered fields:

  1. Log it as a paid operation for this session
  2. Add the cost to the running total
  3. Warn the user: ⚠️ Discovered paid operation: <servicecode>:<operation> cost $X.XX

Budget Enforcement

Per-Investigation Budget

The agent MUST mentally track a running cost estimate throughout the investigation. Since write_scratchpad/read_scratchpad are not available in all environments, budget enforcement is behavioral — the agent maintains the accumulator in its context window.

At investigation start:

text
Budget: $10.00
Running cost: $0.00
Call counts: {}

Before each PAID operation:

text
estimated_cost = estimate(operation)
if running_cost + estimated_cost > budget:
    🚫 HALT — show budget display
else:
    proceed
    # After execution:
    running_cost += actual_cost (from response fields or estimation)
    call_counts[servicecode] += 1

Volume guardrails:

text
if call_counts[any_servicecode] > 200: ⚠️ WARN
if call_counts[any_servicecode] > 500: 🚫 HALT
if sum(all_call_counts) > 1000: 🚫 HALT

ℹ️ If write_scratchpad becomes available in your environment, use it for persistent state across subagent boundaries. Check with: search_user_tools("scratchpad"). If found, store {budget, running_cost, call_counts} as JSON.

Budget Display (on halt)

text
📋 INVESTIGATION BUDGET STATUS
════════════════════════════════════════════════════════════
Budget:      $10.00
Spent:       $X.XX (Y paid operations)
Free calls:  Z operations (no cost)
PromQL:      X,XXX samples scanned ($X.XX)
Next op:     <servicecode>:<operation> — estimated $X.XX
Projected:   $X.XX (exceeds budget by $X.XX)

🚫 HALTED — would exceed $10.00 budget.
💡 Options:
  → Approve additional $X.XX to continue
  → Narrow the time window to reduce scan volume
  → Skip this operation and continue with free alternatives
  → End investigation with findings so far

Time Window Enforcement

For ANY operation classified as PAID that scans data over a time range:

ScenarioAction
User provided time window✅ Use it — estimate cost for that window
No time window, operation scans data🚫 CANCEL — show worst-case cost, ask for window
No time window, operation is bounded (single resource lookup)✅ Proceed — no scan involved

Key distinction: "Get me the config of Lambda X" (bounded, free) vs. "Search logs for errors" (unbounded scan, needs window).

PromQL-specific: Range queries without explicit start/end default to "now" which is safe. But broad label selectors ({} with just metric name) can hit 500 series cap — always prefer specific labels.


Cross-Region Detection

For EVERY paid operation:

text
if target_region ≠ agent_space_region:
    fetch transfer_rate = transfer_rate_cache[target_region]
                       ?? live lookup (see references/pricing-reference.md)
    # If the live lookup returns 0 products: 🚫 HALT — do NOT improvise a rate
    estimated_return_size = estimate_return_bytes(operation_type)
    transfer_cost = estimated_return_size × transfer_rate
    total_estimate += transfer_cost
    flag: "⚠️ Cross-region transfer: <target> → <agent_space>"

Return size heuristics:

  • Aggregation queries (stats, count, group-by): ~KB (negligible)
  • PromQL with aggregation (sum, topk): ~KB (negligible)
  • PromQL range query (500 series × 10K points): ~50MB (flag ⚠️)
  • Raw log/trace fetches: up to 100% of matched bytes
  • Describe/List results: ~KB (negligible)
  • Unknown: use 15% of scan volume as upper bound, flag ⚠️

Cost Reduction Suggestions

When halting or warning, ALWAYS suggest free or cheaper alternatives:

Generic Alternatives (apply to any service)

PatternFree/Cheaper Alternative
Broad time window scanNarrow to ±30 min around the incident
Multiple resource queryTarget specific resource ID
Full scan (DynamoDB, Athena)Add filter/WHERE/key condition
Analytics query for known stringUse free filter API (FilterLogEvents) — note: LookupEvents may be tool-policy-blocked in some environments
Cross-region operationSuggest user run from workload region
Large object fetchUse SelectObjectContent with SQL filter
Pagination explosionAdd limit, filter, or narrower scope
Broad PromQL (no label filters)Add specific label matchers or use aggregation
PromQL small step (60s over 7d)Increase to 300s+ or reduce time range

Service-Specific Alternatives

Instead of...Use...Savings
logs:StartQuerylogs:FilterLogEvents (if searching for known string)100%
cloudwatch:GetMetricData (many)cloudwatch:GetMetricStatistics (single)~100%
get_prometheus_metrics (broad)Add sum by (label) or topk(5, ...)90%+
dynamodb:Scandynamodb:Query with key condition~100%
athena:StartQueryExecution (full)Add partition filter in WHERE90%+
xray:GetTraceSummaries (broad)Narrow time + add filter expression90%+
s3:GetObject (large)s3:SelectObjectContent with SQLVariable

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Investigation Cost Guardrail?

Cost guardrail for AWS DevOps Agent that covers ALL AWS services and native agent tools. Before the agent makes any paid API call, this skill estimates cost, enforces budgets per investigation, detects expensive operations across all services (Athena queries, S3 scans, DynamoDB scans, SageMaker inference, PromQL, etc.), enforces time window requirements, monitors cumulative call volume, and cancels if thresholds are exceeded. This skill applies to ALL investigations regardless of which services are involved.

Warum Investigation Cost Guardrail in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Investigation Cost Guardrail besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Investigation Cost Guardrail in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/aws/tools-for-devops-agent/tree/main/skills/investigation-cost-guardrail ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Investigation Cost Guardrail nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Investigation Cost Guardrail verwenden?

So viele Sie möchten. In TypingMind können Sie Investigation Cost Guardrail mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Investigation Cost Guardrail kostenlos?

Ja. Der Skill wird von aws auf GitHub unter der Lizenz Apache-2.0 veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇