Verwenden Sie Kiro CLI mit einer Automated Reasoning-Richtlinie - Amazon Bedrock

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

Verwenden Sie Kiro CLI mit einer Automated Reasoning-Richtlinie

Sie können Kiro CLI verwenden, um Fragen zu Ihren Automated Reasoning-Richtlinien zu stellen, das Verhalten der verschiedenen Regeln zu verstehen und Änderungen zu beantragen, um fehlgeschlagene Tests oder Unklarheiten in der Richtlinie selbst zu beheben. Kiro CLI ist besonders nützlich für den unter beschriebenen iterativen Optimierungsablauf, Beheben Sie Fehler und verfeinern Sie Ihre Richtlinie für automatisiertes Denken da es Ihre Richtliniendefinition laden, Testergebnisse analysieren und Anmerkungen in natürlicher Sprache anwenden kann.

Voraussetzungen

Um Kiro CLI mit Ihren Automated Reasoning-Richtlinien zu verwenden, müssen Sie zunächst die folgenden Schritte ausführen:

  • Installieren Sie die neueste Version von Kiro CLI.

  • Installieren Sie die neueste Version der AWS CLI.

  • Erstellen Sie mithilfe eines Dokuments über die Konsole oder eine Richtlinie für automatisiertes Denken. APIs Verwenden Sie für einen schnellen Einstieg die integrierte Beispielrichtlinie für Hausaufgaben in der Konsole. Weitere Informationen finden Sie unter Erstellen der Automated-Reasoning-Richtlinie.

  • Machen Sie sich mit den Konzepten von Automated Reasoning Checks vertraut, insbesondere mit Richtlinien, Regeln, Variablen und Ergebnissen. Weitere Informationen finden Sie unter Automatisiertes Denken überprüft Konzepte.

  • Kopieren Sie den Inhalt der kontextbezogenen Eingabeaufforderung in Kontext-Aufforderung zur automatischen Argumentationsrichtlinie und speichern Sie ihn in einer Markdown-Datei in Ihrem Projektordner. Diese Aufforderung hilft Kiro CLI, die Automated Reasoning-Richtlinienkontrollebene zu verwenden und die API korrekt zu testen.

Anmerkung

Für die folgenden Beispiele für Eingabeaufforderungen verwenden wir die Beispielrichtlinie für Hausaufgaben. Die Eingabeaufforderungen sollten genauso gut mit anderen Richtlinien funktionieren. Ändern Sie einfach das hervorgehobene Thema.

Anmerkung

Automatisierte Argumentationsrichtlinien können komplex sein und erfordern, dass Kiro CLI komplexe logische Konstrukte durchdenkt. Für eine optimale Leistung empfehlen wir die Verwendung größerer Formate LLMs wie Anthropic Sonnet 4.5. Verwenden Sie den /model Befehl, um das Modell in Kiro CLI zu ändern.

Erste Schritte

Sie benötigen den ARN der von Ihnen erstellten Automated Reasoning-Richtlinie, um den Workflow mit Kiro CLI zu starten.

  1. Öffnen Sie in der Konsole Ihre Richtlinie für automatisiertes Denken und öffnen Sie auf der Seite mit der Richtlinienübersicht den Tab Richtliniendetails.

  2. Suchen Sie auf der Registerkarte Richtliniendetails den Richtlinien-ARN und kopieren Sie ihn in Ihre Zwischenablage.

  3. Starten Sie über das Terminal eine Kiro CLI-Sitzung mit dem folgenden Befehl:

    kiro-cli
  4. Bitten Sie Kiro bei Ihrer ersten Aufforderung, nach der Markdown-Datei mit Anweisungen zu suchen, die Sie als Teil der Voraussetzungen von dieser Seite kopiert haben. Beispiel:

    We will be using Automated Reasoning checks control plane APIs. I have saved an instructions file called your_file_name.md in this folder. Read this file as it will give you the context you need to work with the APIs.
  5. Nachdem Kiro CLI die automatischen Argumentationsüberprüfungen geladen und verstanden hat APIs, bitten Sie es, die neueste Version Ihrer Richtlinie zu laden und mit der Erkundung zu beginnen. Verwenden Sie eine Variante der folgenden Eingabeaufforderung mit dem von Ihnen kopierten ARN:

    Load the policy assets for the latest build of the policy with ARN YOUR_POLICY_ARN. Make sure you understand the policy with all its rules and variables. Give a high-level description of the policy and the type of content it is capable of validating.

An dieser Stelle sollte Kiro CLI Ihnen eine kurze Beschreibung der Regeln und Variablen der Richtlinie geben. Kiro CLI sollte auch den Bericht zur Richtlinienqualität laden und Probleme wie ungenutzte Typen und Variablen zusammenfassen.

Lösung politischer Probleme

Sie können Kiro CLI verwenden, um die im Richtlinienbericht gemeldeten Richtlinienprobleme zu lösen. Bitten Sie Kiro zunächst, Ihnen eine Zusammenfassung des Qualitätsberichts zu geben:

Can you give me a summary of the quality report for this policy?

Der Qualitätsbericht enthält eine Liste der ungenutzten Variablen, widersprüchlichen Regeln und unzusammenhängenden Regeln sowie anderer potenzieller Probleme mit der Richtlinie. Weitere Informationen zur Interpretation des Qualitätsberichts finden Sie unter. Verwenden Sie den Qualitätsbericht

Widersprüchliche Regeln führen dazu, dass Ihre Richtlinie auf alle Überprüfungsanfragen reagiert. IMPOSSIBLE Weitere Informationen zu widersprüchlichen Regeln und deren Behebung finden Sie unter. Konflikte in der Richtlinie Sie können Kiro CLI bitten, den Konflikt zu erklären und eine Lösung vorzuschlagen:

Can you look at the conflicting rules, explain how they are used in the policy, why they conflict, and suggest a change such as deleting one of the rules or merging the logic from the two into a single rule?

Unbenutzte Variablen können dazu führen, dass Validierungsergebnisse TRANSLATION_AMBIGUOUS Ergebnisse zurückgeben. Weitere Hinweise dazu, warum ungenutzte Variablen Probleme verursachen, finden Sie unterUnbenutzte Variablen. Sie können Kiro CLI bitten, Ihnen bei diesem Problem zu helfen:

I see the quality report lists some unused variables, can you get rid of them?

In ähnlicher Weise können mehrdeutige Variablen, die sich semantisch ähneln, dazu führen, dass Validierungsergebnisse Ergebnisse zurückgebenTRANSLATION_AMBIGUOUS. Weitere Informationen zu überlappenden Variablen und deren Behebung finden Sie unter Überlappende Variablen und. Überlappende Variablendefinitionen Sie können Kiro CLI bitten, Ihnen bei diesem Problem zu helfen:

Automated Reasoning checks translate input natural language into logical statements that use the schema of variables from the policy. Variables that are semantically similar - ambiguous - can cause issues with inconsistent translations. Can you take a look at the schema of variables and help me identify variables that have potentially overlapping meanings? If you find any, suggest changes like removing one of them or merging them. Variable changes are also likely to require corresponding rule changes.
Anmerkung

Nach der Bearbeitung einiger Änderungen bittet Kiro CLI um Bestätigung, damit sie übernommen werden können. Zu diesem Zeitpunkt können Sie die Benutzeroberfläche der Bedrock Console verwenden, um die vorgeschlagenen Änderungen auf einem Vergleichsbildschirm zu überprüfen. Wenn Sie die Konsole verwenden, um die Änderungen zu überprüfen und zu genehmigen, vergessen Sie nicht, Kiro CLI anzuweisen, die neueste Version der Richtliniendefinition neu zu laden.

Interaktion mit einer Richtlinie

Sie können Kiro CLI verwenden, um Ihre Richtlinie zu erkunden. Sie könnten Kiro CLI beispielsweise bitten, die Richtlinienregeln für einen bestimmten Bereich zusammenzufassen. Anhand der Beispielrichtlinie für Hausaufgaben könnten Sie Kiro CLI bitten, Sie über die Regeln zu informieren, die speziell Mathe-Hausaufgaben einschränken:

Can you tell me about the rules that constrain math homework? Explain the rules themselves and how they fit in the broader policy.

Sie können die Kiro CLI auch verwenden, um der Richtlinie Funktionen hinzuzufügen. Richtlinien für automatisiertes Denken umgehen häufig einige wichtige Ausgabevariablen, die die Absicht des Benutzers erfassen. Beispielsweise verwendet die Beispielrichtlinie zur Einreichung von Hausaufgaben eine isSubmissionAcceptable Variable als Ergebnis ihrer Regeln. Sie können Kiro CLI verwenden, um die Richtlinie so zu ändern, dass andere mögliche Benutzerfragen erfasst werden. Beachten Sie beim Hinzufügen neuer Regeln insbesondere Verwenden Sie Implikationen (=>), um Regeln zu strukturieren die unter beschriebenen Best Practices. Bewährte Methoden für Richtlinien zur automatisierten Argumentation

Bearbeitung oder Überarbeitung Ihrer Richtlinie

Sie können Kiro CLI fragen, ob die Richtlinie bestimmte Fragen Ihrer Benutzer validieren kann. Zum Beispiel konzentriert sich die Hausaufgabenrichtlinie darauf, festzustellen, ob die Einreichung von Hausaufgaben zulässig ist. Sie können eine positive Antwort von Kiro CLI mit dieser Frage erwarten:

Can this policy validate answers about whether homework submissions are acceptable?

Wenn Sie in der Musterrichtlinie für Hausaufgaben nach einer Verzögerung bei der Einreichung von Hausaufgaben fragen, erklärt Kiro CLI, dass die Richtlinie diese Fragen nicht beantworten kann:

Can this policy validate answers about permissible delays in homework submissions?

Kiro CLI erklärt, was die Richtlinie kann und was nicht:

> Yes, but with limitations. The policy can validate whether a late submission is acceptable, but it cannot answer general questions about permissible delays.

What it CAN validate:
- Whether a specific late submission is acceptable given the circumstances
- Example: "Student submitted 2 days late with a doctor's note because they were sick before the deadline" → The policy will determine if this is acceptable (it would be)

What it CANNOT validate:
- General questions like "How many days late can a student submit homework?"
- Questions about delay policies without specific submission details
- Hypothetical scenarios without concrete variable values

The late submission logic:
The policy allows late submissions (submissionDate > 0) ONLY if:
1. The student has a valid doctor's note (hasDoctorNote = true), AND
2. The student was sick before the original deadline (wasSickPriorToDeadline = true)

Without both conditions met, any submission after the due date (submissionDate > 0) is automatically rejected.

So it's designed to validate specific submission instances against the rules, not to answer policy interpretation questions.
    

Wenn Sie etwas entdecken, das die Richtlinie nicht kann, können Sie Kiro CLI bitten, die Richtlinie zu aktualisieren, um diese Informationen zu erfassen, indem Sie die folgende Aufforderung verwenden:

I would like the policy to also validate answers about by how many days homework submissions can be delayed. Homework submissions accompanied by a doctor note can be up to 7 days late. Suggest the necessary variables and rules to capture these new questions.

Als Antwort auf diese Aufforderung schlägt Kiro CLI eine Reihe von Variablen und Regeln vor, die der Richtlinie hinzugefügt werden können, um die neue Art von Fragen zu validieren. Überprüfe die Vorschläge und wenn sie mit deiner Absicht übereinstimmen, kannst du Kiro CLI anweisen, die Anmerkung von Automated Reasoning Checks zu verwenden, APIs um die folgenden Änderungen an der Richtlinie vorzunehmen:

Looks good. Can you use the annotation APIs to submit these changes to the policy.

Sobald Kiro CLI bestätigt hat, dass die Anmerkungen bereit sind, können Sie Ihre Richtlinie in der Konsole öffnen, um die Anmerkungen zu überprüfen. Wenn die Anmerkungen korrekt sind, wählen Sie Apply Annotations.

Nachdem Sie die Anmerkungen übernommen haben, bitten Sie Kiro CLI, die neueste Version der Richtlinie neu zu laden, um sicherzustellen, dass Kiro CLI mit einer aktuellen Kopie funktioniert:

I applied the annotations. Reload the latest build of the policy.

Behebung fehlgeschlagener Tests

Eine gute Methode, um zu testen, ob Ihre Richtlinie für automatisiertes Denken die von Ihrer Anwendung generierte natürliche Sprache validieren kann, ist die Verwendung von Tests. Nachdem Sie Fragen und Antworten zu Tests mit den erwarteten Ergebnissen erstellt haben, können Sie Kiro CLI verwenden, um zu verstehen, warum ein Test nicht das erwartete Ergebnis zurückgegeben hat, und die Richtlinie anpassen. Weitere Informationen zum Erstellen und Ausführen von Tests finden Sie unter. Testen einer Automated-Reasoning-Richtlinie Einen systematischen Ansatz zur Diagnose von Testfehlern ohne Kiro CLI finden Sie unter. Beheben Sie Fehler und verfeinern Sie Ihre Richtlinie für automatisiertes Denken

  1. Bitten Sie Kiro CLI als ersten Schritt, den fehlgeschlagenen Test zu laden und zu erklären, warum er nicht das erwartete Ergebnis auf der Grundlage der Richtliniendefinition zurückgibt. Verwenden Sie die Konsole oder kopieren APIs Sie die Test-ID für Ihren fehlgeschlagenen Test. In der Konsole ist die Test-ID sowohl in der Tabelle mit den Tests als auch auf der Detailseite für jeden Test verfügbar.

    The test with ID YOUR_TEST_ID is not returning the expected result. Can you load the test definition and findings, look at the policy definition, and explain why this test is failing.
  2. Die Erklärung von Kiro CLI gibt Ihnen Hinweise darauf, ob die Richtlinie das Richtige tut (und Sie sollten das erwartete Ergebnis für den Test ändern) oder ob die Richtlinie falsch ist. Sie können Kiro CLI bitten, Änderungen an der Richtlinie vorzuschlagen, um sicherzustellen, dass der Test das erwartete Ergebnis liefert:

    Can you suggest changes to the policy to ensure this test returns the expected result? Explain why you are suggesting these changes. Only create rules in if/then format.
    Anmerkung

    Wenn Kiro CLI Regeländerungen vorschlägt, versucht Kiro CLI möglicherweise, sich zu stark an das spezifische Beispiel anzupassen und Regeln zu erstellen, die in anderen Anwendungsfällen nicht nützlich sind. Überprüfen Sie die Testausgabe und geben Sie Kiro CLI Anweisungen, damit es sich auf das richtige Problem konzentriert. Anleitungen zum Schreiben effektiver Regeln finden Sie unterBewährte Methoden für Richtlinien zur automatisierten Argumentation.

    Wenn Sie Kiro beispielsweise bitten, die Musterrichtlinie für Hausaufgaben so zu ändern, dass der SATISFIABLE Test zurückgegeben wirdVALID, schlägt Kiro möglicherweise vor, der Richtlinie Axiome hinzuzufügen, die dafür sorgen, dass der Test immer bestanden wird, z. B. die Erstellung einer Regel, die besagt. (false isHomeworkSubmissionAcceptable) Dadurch würde sichergestellt, dass der Wert immer falsch ist. Dies behebt zwar technisch den problematischen Test, wirkt sich jedoch nachteilig auf die allgemeine Richtlinienfunktionalität aus. Wenn Sie die vom SATISFIABLE Testergebnis zurückgegebenen Szenarien analysieren, können Sie feststellen, dass Kiro CLI bessere Hinweise gibt, entweder eine neue Regel zu erstellen, die nur die im Test angegebenen Einschränkungen abdeckt, oder die vorhandenen Regeln zu aktualisieren, um nur die Testeinschränkungen zu überprüfen:

  3. Wenn Sie mit den vorgeschlagenen Änderungen zufrieden sind, bitten Sie Kiro CLI, die Anmerkungen einzureichen und sie über die Benutzeroberfläche der Konsole zu überprüfen:

    Looks good. Can you start a build workflow to apply these changes to the policy.
  4. Nachdem Sie die Änderungen übernommen und mit dem nächsten fehlgeschlagenen Test fortgefahren sind, bitten Sie Kiro CLI, die neueste Version der Richtlinie neu zu laden:

    I applied the changes. Reload the latest build of the policy.

Nächste Schritte

Sobald Sie mit der Automated Reasoning-Richtlinie zufrieden sind, können Sie sie für die Verwendung in Amazon Bedrock Guardrails bereitstellen. Weitere Informationen finden Sie unter Implementieren der Automated-Reasoning-Richtlinie in die Anwendung.

Nach der Implementierung Ihrer Richtlinie finden Sie unter Anleitungen Integrieren Sie automatisierte Argumentationsprüfungen in Ihre Anwendung zur Verwendung von Automated Reasoning Checks zur Laufzeit, um LLM-Antworten zu validieren und auf das Feedback zu reagieren.

Kontext-Aufforderung zur automatischen Argumentationsrichtlinie

Kopieren Sie den folgenden Inhalt und speichern Sie ihn in einer Markdown-Datei in Ihrem Projektordner für Kiro CLI. Diese Aufforderung bietet Kiro CLI den Kontext, den es benötigt, um mit der Automated Reasoning-Richtlinie APIs korrekt zu arbeiten.

# Automated Reasoning Policy APIs and Workflows ## Table of Contents ### Core APIs - Policy Management - Policy Versions - Build Workflows - Test Management - Annotations & Scenarios ### Build Workflow Types - INGEST_CONTENT Workflow - REFINE_POLICY Workflow - IMPORT_POLICY Workflow - GENERATE_FIDELITY_REPORT Workflow ### Annotation Type Reference - Type Management Annotations - Variable Management Annotations - Rule Management Annotations - Natural Language Rule Creation - Feedback-Based Updates ### Common Workflows 1. Getting Started (New Policy) 2. Building Policy from Document 3. Policy Development Cycle 4. REFINE_POLICY Workflow (Annotation-Based) ### Testing Workflow 1. Primary Approach: Scenarios API (Recommended) 2. Secondary Approach: Test Cases (User Experience) 3. Test Result Analysis and Troubleshooting ### Build Workflow Monitoring - Check Build Status - List Build History - Best Practice: Clean Build Management - Troubleshooting Build Failures ### Build Workflow Assets - Asset Types - Understanding Conflicting Rules - Understanding Disjoint Rule Sets - Advanced Quality Report Analysis ### Additional Topics - Policy Version Export - Key Concepts - Important Format Requirements - Policy Modeling Best Practices - ARN Formats ## Core APIs ### Policy Management - `create-automated-reasoning-policy` - Create initial policy (returns policy ARN). Supports optional `--description`, `--kms-key-id` (for encryption with a customer managed AWS KMS key), `--tags` (up to 200 tags), and `--client-request-token` (idempotency token). - `get-automated-reasoning-policy` - Retrieve policy (DRAFT version by default with unversioned ARN). Returns `policyId`, `definitionHash`, and `kmsKeyArn` (if a KMS key was provided at creation). - `update-automated-reasoning-policy` - Update DRAFT policy with new definition. Accepts optional `--name` and `--description` updates alongside `--policy-definition` (required). - `delete-automated-reasoning-policy` - Delete policy. Supports optional `--force` flag: when true, deletes the policy and all its artifacts (versions, test cases, test results) without validation; when false (default), validates that all artifacts have been deleted first. - `list-automated-reasoning-policies` - List all policies. Supports optional `--policy-arn` filter to list only versions of a specific policy. ### Policy Versions - `create-automated-reasoning-policy-version` - Snapshot DRAFT into numbered version. Requires `--last-updated-definition-hash` (concurrency token from get/create/update response). Supports optional `--tags` (up to 200 tags) and `--client-request-token`. - `export-automated-reasoning-policy-version` - Export specific policy version definition including rules, variables, and types. ### Build Workflows - `start-automated-reasoning-policy-build-workflow` - Start build process. Valid `--build-workflow-type` values: `INGEST_CONTENT`, `REFINE_POLICY`, `IMPORT_POLICY`, `GENERATE_FIDELITY_REPORT`. Supports optional `--client-request-token` (idempotency token, passed as header). - `get-automated-reasoning-policy-build-workflow` - Get build workflow status. Status values: `SCHEDULED`, `CANCEL_REQUESTED`, `PREPROCESSING`, `BUILDING`, `TESTING`, `COMPLETED`, `FAILED`, `CANCELLED`. - `cancel-automated-reasoning-policy-build-workflow` - Cancel running build - `delete-automated-reasoning-policy-build-workflow` - Delete build workflow. Requires `--last-updated-at` (concurrency token timestamp). - `list-automated-reasoning-policy-build-workflows` - List build workflows - `get-automated-reasoning-policy-build-workflow-result-assets` - Get compiled policy assets. Requires `--asset-type`. Valid asset types: `BUILD_LOG`, `QUALITY_REPORT`, `POLICY_DEFINITION`, `GENERATED_TEST_CASES`, `POLICY_SCENARIOS`, `FIDELITY_REPORT`, `ASSET_MANIFEST`, `SOURCE_DOCUMENT`. Supports optional `--asset-id` (required when retrieving `SOURCE_DOCUMENT` assets if multiple source documents were used; obtain from the `ASSET_MANIFEST`). ### Test Management - `create-automated-reasoning-policy-test-case` - Create test case. Requires `--guard-content` and `--expected-aggregated-findings-result`. Supports optional `--query-content`, `--confidence-threshold` (Double, 0 to 1, minimum confidence level for logic validation), and `--client-request-token`. - `get-automated-reasoning-policy-test-case` - Get test case details (includes `confidenceThreshold` if set) - `update-automated-reasoning-policy-test-case` - Update test case. Requires `--guard-content`, `--expected-aggregated-findings-result`, and `--last-updated-at` (concurrency token). Supports optional `--query-content`, `--confidence-threshold`, and `--client-request-token`. - `delete-automated-reasoning-policy-test-case` - Delete test case. Requires `--last-updated-at` (concurrency token). - `list-automated-reasoning-policy-test-cases` - List test cases - `start-automated-reasoning-policy-test-workflow` - Run tests against a completed build. Requires `--build-workflow-id` (the build workflow must show COMPLETED status). Supports optional `--test-case-ids` (array of test case IDs to run; if not provided, all tests for the policy are run) and `--client-request-token`. - `get-automated-reasoning-policy-test-result` - Get test result for a specific test case. Requires `--build-workflow-id` and `--test-case-id`. - `list-automated-reasoning-policy-test-results` - List test results. Requires `--build-workflow-id`. ### Annotations & Scenarios - `get-automated-reasoning-policy-annotations` - Get policy annotations for a build workflow. Requires `--build-workflow-id`. Returns `annotations`, `annotationSetHash` (concurrency token), `buildWorkflowId`, `name`, `policyArn`, and `updatedAt`. - `update-automated-reasoning-policy-annotations` - Update annotations for a build workflow. Requires `--build-workflow-id`, `--annotations` (array of annotation objects, max 10), and `--last-updated-annotation-set-hash` (concurrency token from get-annotations response). Returns updated `annotationSetHash`. - `get-automated-reasoning-policy-next-scenario` - Get next test scenario **Important**: Do NOT use `get-automated-reasoning-policy-annotations` or `update-automated-reasoning-policy-annotations` for the `REFINE_POLICY` workflow. Annotations are passed directly in the `start-automated-reasoning-policy-build-workflow` call. ## Build Workflow Types 1. **INGEST_CONTENT** - Process documents to create/extract policy rules 2. **REFINE_POLICY** - Refine and improve existing policies using annotations 3. **IMPORT_POLICY** - Import policies from external sources 4. **GENERATE_FIDELITY_REPORT** - Generate a fidelity report for the policy ### INGEST_CONTENT Workflow - **Purpose**: Extract policy rules from documents (PDF/TXT) - **Input**: Documents + optional existing policy definition - **Use Cases**: Document-to-policy conversion, incremental policy building - **Content Structure**: `workflowContent.documents[]` **CRITICAL: Complete Policy Definition for Incremental Building** When adding documents to an existing policy, you must include the complete current policy definition: ```json // CORRECT - Incremental policy building { "policyDefinition": { "version": "1.0", "types": [/* ALL existing types */], "rules": [/* ALL existing rules */], "variables": [/* ALL existing variables */] }, "workflowContent": { "documents": [/* New documents to process */] } } ``` ### REFINE_POLICY Workflow - **Purpose**: Iteratively improve policies with targeted modifications - **Input**: Policy definition + annotations for specific changes - **Use Cases**: Kiro CLI suggestions, test-driven improvements, feedback-based refinement - **Content Structure**: `workflowContent.policyRepairAssets.annotations[]` **CRITICAL: Complete Policy Definition Required** ALL build workflows require the COMPLETE existing policy definition in the `policyDefinition` section, not just the changes you want to make. **REFINE_POLICY Annotation Types:** **Top-Level Annotations:** - **Type Management**: `addType`, `updateType`, `deleteType` - **Variable Management**: `addVariable`, `updateVariable`, `deleteVariable` - **Rule Management**: `addRule`, `updateRule`, `deleteRule` - **Natural Language Rules**: `addRuleFromNaturalLanguage` - **Feedback-Based Updates**: `updateFromRulesFeedback`, `updateFromScenarioFeedback` **Sub-Operations (only within `updateType`):** - `addTypeValue`, `updateTypeValue`, `deleteTypeValue` - Used to modify values within an existing custom type **important**: Only create rules in if/then format. ## Annotation Type Reference ### Type Management Annotations #### `addType` - Create New Custom Type ```json { "addType": { "name": "ApprovalStatus", "description": "Status values for approval requests", "values": [ { "value": "PENDING", "description": "Request is awaiting approval" }, { "value": "APPROVED", "description": "Request has been approved" }, { "value": "REJECTED", "description": "Request has been rejected" } ] } } ``` #### `updateType` - Modify Existing Custom Type ```json { "updateType": { "name": "ApprovalStatus", "newName": "RequestStatus", "description": "Updated status values for all request types", "values": [ { "addTypeValue": { "value": "ESCALATED", "description": "Request escalated to higher authority" } }, { "updateTypeValue": { "value": "PENDING", "newValue": "WAITING", "description": "Request is waiting for review" } }, { "deleteTypeValue": { "value": "REJECTED" } } ] } } ``` #### `deleteType` - Remove Custom Type ```json { "deleteType": { "name": "ObsoleteType" } } ``` ### Variable Management Annotations #### `addVariable` - Create New Variable ```json { "addVariable": { "name": "requestAmount", "type": "real", "description": "The monetary amount of the approval request in USD" } } ``` #### `updateVariable` - Modify Existing Variable ```json { "updateVariable": { "name": "requestAmount", "newName": "approvalAmount", "description": "The monetary amount requiring approval in USD (updated description)" } } ``` #### `deleteVariable` - Remove Variable ```json { "deleteVariable": { "name": "obsoleteVariable" } } ``` ### Rule Management Annotations #### `addRule` - Create New Rule (SMT-LIB) ```json { "addRule": { "expression": "(=> (and (= userRole MANAGER) (< requestAmount 10000)) (not approvalRequired))" } } ``` #### `updateRule` - Modify Existing Rule ```json { "updateRule": { "ruleId": "A1B2C3D4E5F6", "expression": "(=> (and (= userRole MANAGER) (< requestAmount 5000)) (not approvalRequired))" } } ``` #### `deleteRule` - Remove Rule ```json { "deleteRule": { "ruleId": "G7H8I9J0K1L2" } } ``` ### Natural Language Rule Creation #### `addRuleFromNaturalLanguage` - Convert Natural Language to Rule ```json { "addRuleFromNaturalLanguage": { "naturalLanguage": "Managers can approve expense requests up to $5,000 without additional authorization. Senior managers can approve up to $25,000." } } ``` ### Feedback-Based Updates #### `updateFromRulesFeedback` - Improve Rules Based on Performance ```json { "updateFromRulesFeedback": { "ruleIds": ["A1B2C3D4E5F6", "G7H8I9J0K1L2"], "feedback": "These rules are too restrictive for emergency scenarios. Add exception handling for urgent requests with proper escalation paths." } } ``` #### `updateFromScenarioFeedback` - Improve Based on Test Scenarios ```json { "updateFromScenarioFeedback": { "ruleIds": ["A1B2C3D4E5F6"], "scenarioExpression": "(and (= requestType EMERGENCY) (= userRole MANAGER) (> requestAmount 10000))", "feedback": "Emergency requests should have different approval thresholds. Current rule blocks legitimate emergency expenses." } } ``` **Important**: Do NOT use `get-automated-reasoning-policy-annotations` or `update-automated-reasoning-policy-annotations` for the `REFINE_POLICY` workflow. Annotations are passed directly in the `start-automated-reasoning-policy-build-workflow` call. ## Common Workflows ### 1. Getting Started (New Policy) **CRITICAL: Always Create Policy First** You must create a policy before starting any build workflows. ```bash # Step 1: Create initial policy (REQUIRED FIRST STEP) aws bedrock create-automated-reasoning-policy \ --region us-west-2 \ --name "YourPolicyName" # Step 2: Extract the policyArn from the response above, then start build workflow aws bedrock start-automated-reasoning-policy-build-workflow \ --region us-west-2 \ --policy-arn "arn:aws:bedrock:us-west-2:123456789012:automated-reasoning-policy/abcd1234efgh" \ --build-workflow-type INGEST_CONTENT \ --source-content <policy-definition> # Step 3: Get build results aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --region us-west-2 \ --policy-arn "arn:aws:bedrock:us-west-2:123456789012:automated-reasoning-policy/abcd1234efgh" \ --build-workflow-id <workflow-id> ``` ### 2. Building Policy from Document **RECOMMENDED: Using CLI Input JSON File** ```bash # Step 1: Encode PDF to base64 and create JSON file with base64 content PDF_BASE64=$(base64 -i your-policy.pdf | tr -d '\n') cat > ingest-policy.json << EOF { "policyArn": "arn:aws:bedrock:us-west-2:123456789012:automated-reasoning-policy/your-actual-policy-id", "buildWorkflowType": "INGEST_CONTENT", "sourceContent": { "policyDefinition": { "version": "1.0", "types": [], "rules": [], "variables": [] }, "workflowContent": { "documents": [ { "document": "$PDF_BASE64", "documentContentType": "pdf", "documentName": "Company Policy Document", "documentDescription": "Main policy document containing business rules and organizational guidelines." } ] } } } EOF # Step 2: Use the JSON file aws bedrock start-automated-reasoning-policy-build-workflow \ --region us-west-2 \ --cli-input-json file://ingest-policy.json ``` ### 3. Policy Development Cycle ```bash # 1. Import/process policy definition aws bedrock start-automated-reasoning-policy-build-workflow \ --build-workflow-type IMPORT_POLICY # 2. Update DRAFT with processed definition aws bedrock update-automated-reasoning-policy \ --policy-arn <unversioned-arn> \ --policy-definition <build-output> # 3. Create versioned snapshot of DRAFT (definitionHash from step 2 response) aws bedrock create-automated-reasoning-policy-version \ --policy-arn <unversioned-arn> \ --last-updated-definition-hash <definition-hash> ``` ## Testing Workflow ### Primary Approach: Scenarios API (Recommended) Use `get-automated-reasoning-policy-next-scenario` for comprehensive policy validation. The Scenarios API is superior for testing because it: - Tests formal logic directly - Validates policy rules work correctly - AI-generated scenarios - Comprehensive coverage of edge cases and rule interactions - Targets specific rules - Tests individual rules and combinations - Always works - No natural language translation issues - Intelligent test generation - AI understands policy logic deeply ```bash # Generate intelligent test scenarios automatically aws bedrock get-automated-reasoning-policy-next-scenario \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" ``` ### Secondary Approach: Test Cases (User Experience) Use manual test cases to validate natural language translation. ```bash # Create test cases for natural language validation aws bedrock create-automated-reasoning-policy-test-case \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --guard-content "It is 2:30 PM on a clear day" \ --query-content "What color should the sky be?" \ --expected-aggregated-findings-result "VALID" \ --confidence-threshold 0.8 ``` ### Test Result Analysis and Troubleshooting **Understanding Test Results:** **Scenarios API Results:** - `expectedResult: SATISFIABLE` - Policy logic works correctly - API errors or logic conflicts - Policy needs fixing with REFINE_POLICY **Common Test Case Failure Modes:** 1. **TRANSLATION_AMBIGUOUS** - Problem: AI can't map natural language to policy variables - Solution: Improve variable descriptions with more natural language synonyms 2. **SATISFIABLE when expecting VALID** - Problem: Your expected result label is likely WRONG, not the policy - SATISFIABLE = "This scenario is logically consistent with the policy rules" - VALID = "This is the correct/expected answer according to the policy" - Solution: Change `expectedAggregatedFindingsResult` from `VALID` to `SATISFIABLE` 3. **Empty testFindings arrays** - Problem: Translation issues, not rule violations - Solution: Focus on improving natural language descriptions, not policy logic **Valid values for `expectedAggregatedFindingsResult`:** - `VALID` - The claims are true, implied by the premises and the policy - `INVALID` - The claims are false, not implied by the premises and policy - `SATISFIABLE` - The claims can be true or false depending on assumptions - `IMPOSSIBLE` - Automated Reasoning can't make a statement (e.g., conflicting policy rules) - `TRANSLATION_AMBIGUOUS` - Ambiguity in translation prevented validity checking - `TOO_COMPLEX` - Input too complex for Automated Reasoning to process within latency limits - `NO_TRANSLATION` - Some or all of the input wasn't translated into logic ### Running Tests Against a Build After creating test cases, run them against a completed build workflow: ```bash # Run all tests against a completed build aws bedrock start-automated-reasoning-policy-test-workflow \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" # Run specific tests only aws bedrock start-automated-reasoning-policy-test-workflow \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --test-case-ids '["A1B2C3D4E5F6"]' # Get result for a specific test case aws bedrock get-automated-reasoning-policy-test-result \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --test-case-id "A1B2C3D4E5F6" # List all test results for a build aws bedrock list-automated-reasoning-policy-test-results \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" ``` ## Build Workflow Monitoring **Critical Build Limits**: The API supports maximum 2 total build workflows per policy, with only 1 allowed to be IN_PROGRESS at any time. When a build workflow completes, you can instruct the user to review the output using the console. ### Check Build Status ```bash aws bedrock get-automated-reasoning-policy-build-workflow \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" ``` ### List Build History ```bash aws bedrock list-automated-reasoning-policy-build-workflows \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --max-results 50 ``` ### Best Practice: Clean Build Management ```bash # 1. Check existing builds before starting new ones aws bedrock list-automated-reasoning-policy-build-workflows \ --policy-arn <policy-arn> \ --max-results 10 # 2. Delete old/completed builds if you have 2 already aws bedrock delete-automated-reasoning-policy-build-workflow \ --policy-arn <policy-arn> \ --build-workflow-id "old-workflow-id" \ --last-updated-at "2025-11-15T00:41:18.608000+00:00" # 3. Now start your new build aws bedrock start-automated-reasoning-policy-build-workflow \ --policy-arn <policy-arn> \ --build-workflow-type INGEST_CONTENT \ --source-content <content> ``` ## Build Workflow Assets After a build workflow completes successfully, you can retrieve various assets. After you complete a build workflow, you can ask the user to check the build diff using the Automated Reasoning checks console. ### Asset Types #### 1. ASSET_MANIFEST - Index of All Assets ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "ASSET_MANIFEST" ``` **What it contains:** - A manifest listing all available assets and their IDs for the build workflow - Use this to discover asset IDs needed for retrieving assets #### 2. POLICY_DEFINITION - The Main Output ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "POLICY_DEFINITION" ``` **What it contains:** - Compiled policy with extracted/refined rules, variables, and types - SMT-LIB expressions for all rules - Complete policy structure ready for deployment #### 3. BUILD_LOG - Build Process Details ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "BUILD_LOG" ``` **What it shows:** - Document processing steps - What content was analyzed - Extraction results - What rules, variables, and types were found - Processing warnings - Content that couldn't be interpreted - Success/failure status for each extraction step #### 4. QUALITY_REPORT - Policy Quality Analysis ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "QUALITY_REPORT" ``` **What it contains:** - Conflicting rules - Rules that contradict each other - Unused variables - Variables not referenced by any rules - Unused type values - Enum values not used in rules - Disjoint rule sets - Groups of rules that don't interact #### 5. GENERATED_TEST_CASES - Auto-Generated Tests ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "GENERATED_TEST_CASES" ``` **What it contains:** - Automatically generated test cases based on the policy rules #### 6. POLICY_SCENARIOS - Policy Test Scenarios ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "POLICY_SCENARIOS" ``` **What it contains:** - AI-generated scenarios for comprehensive policy validation #### 7. FIDELITY_REPORT - Policy Fidelity Analysis ```bash aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "FIDELITY_REPORT" ``` **What it contains:** - Fidelity analysis results from a GENERATE_FIDELITY_REPORT build workflow #### 8. SOURCE_DOCUMENT - Original Source Documents ```bash # Requires --asset-id obtained from the ASSET_MANIFEST aws bedrock get-automated-reasoning-policy-build-workflow-result-assets \ --policy-arn "arn:aws:bedrock:region:account:automated-reasoning-policy/policy-id" \ --build-workflow-id "workflow-123" \ --asset-type "SOURCE_DOCUMENT" \ --asset-id "a1b2c3d4-e5f6-4a7b-8c9d-e0f1a2b3c4d5" ``` **What it contains:** - The original source document used in the build workflow - The `--asset-id` parameter is required because multiple source documents may have been used