翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
自動推論ポリシーで Kiro CLI を使用する
Kiro CLI を使用して、自動推論ポリシーについて質問したり、さまざまなルールの動作を理解したり、失敗したテストやポリシー自体のあいまいさに対処する変更をリクエストしたりできます。Kiro CLI は、ポリシー定義のロード、テスト結果の分析、自然言語会話による注釈の適用が可能な自動推論ポリシーのトラブルシューティングと絞り込みため、 で説明されている反復的な絞り込みワークフローに特に役立ちます。
前提条件
自動推論ポリシーで Kiro CLI を使用するには、まず次のステップを完了する必要があります。
-
Kiro CLI
の最新バージョンをインストールします。 -
AWS CLIの最新バージョンをインストールします。
-
コンソールまたは APIs を使用してドキュメントを使用して自動推論ポリシーを作成します。すぐに開始するには、コンソールから組み込みのサンプルホームワークポリシーを使用します。詳細については、「自動推論ポリシーを作成する」を参照してください。
-
自動推論チェックの概念、特にポリシー、ルール、変数、検出結果を理解します。詳細については、「自動推論チェックの概念」を参照してください。
-
で提供されたコンテキストプロンプトの内容をコピー自動推論ポリシー API コンテキストプロンプトし、プロジェクトフォルダの Markdown ファイルに保存します。このプロンプトは、Kiro CLI が自動推論ポリシーコントロールプレーンを使用して API を正しくテストするのに役立ちます。
注記
以下のプロンプト例では、サンプルホームワークポリシーを使用します。プロンプトは他のポリシーと同様に機能します。強調表示されたトピックを変更するだけです。
注記
自動推論ポリシーは複雑になる場合があり、Kiro CLI は複雑な論理構造を通じて推論する必要があります。最高のパフォーマンスを得るには、Anthropic Sonnet 4.5 などのより大きな LLMs を使用することをお勧めします。Kiro CLI でモデルを変更するには、 /model コマンドを使用します。
開始方法
Kiro CLI でワークフローを開始するには、作成した自動推論ポリシーの ARN が必要です。
-
コンソールを使用して自動推論ポリシーを開き、ポリシーの概要ページからポリシーの詳細タブを開きます。
-
ポリシーの詳細タブで、ポリシー ARN を見つけてクリップボードにコピーします。
-
ターミナルを使用して、次のコマンドを使用して Kiro CLI セッションを開始します。
kiro-cli -
最初のプロンプトで、前提条件の一部としてこのページからコピーした Markdown ファイルを検索するように Kiro に依頼します。例えば、次のようになります。
We will be using Automated Reasoning checks control plane APIs. I have saved an instructions file calledyour_file_name.md in this folder. Read this file as it will give you the context you need to work with the APIs. -
Kiro CLI が自動推論チェックの APIs をロードして理解したら、ポリシーの最新ビルドをロードして探索を開始するように依頼します。コピーした ARN で次のプロンプトのバリエーションを使用します。
Load the policy assets for the latest build of the policy with ARNYOUR_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.
この時点で、Kiro CLI はポリシーのルールと変数の簡単な説明を提供します。Kiro CLI はポリシー品質レポートもロードし、未使用のタイプや変数などの問題を要約する必要があります。
ポリシーの問題の解決
Kiro CLI を使用して、ポリシーレポートで報告されたポリシーの問題を解決できます。まず、品質レポートの概要を提供するように Kiro に依頼します。
Can you give me a summary of the quality report for this policy?
品質レポートには、未使用の変数、競合するルール、結合されていないルール、およびポリシーに関するその他の潜在的な問題のリストが含まれます。品質レポートの解釈の詳細については、「」を参照してください品質レポートを使用する。
ルールが競合すると、ポリシーはすべての検証リクエストIMPOSSIBLEに応答します。競合するルールとその解決方法の詳細については、「」を参照してくださいポリシーの競合。Kiro CLI に競合を説明し、解決策を提案するように依頼できます。
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?
変数を使用しないと、検証結果がTRANSLATION_AMBIGUOUS結果を返す可能性があります。未使用の変数が原因で問題が発生する理由の詳細については、「」を参照してください未使用の変数。Kiro CLI にこの問題のサポートを依頼できます。
I see the quality report lists some unused variables, can you get rid of them?
同様に、意味的に類似したあいまいな変数では、検証結果がTRANSLATION_AMBIGUOUS結果を返す可能性があります。重複する変数とその修正方法の詳細については、重複する変数「」および「」を参照してください変数定義の重複。Kiro CLI にこの問題のサポートを依頼できます。
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.
注記
一部の変更を処理すると、Kiro CLI は適用の確認を求めます。この時点で、Bedrock コンソールのユーザーインターフェイスを使用して、差分画面で提案された変更を確認できます。コンソールを使用して変更を確認および承認する場合は、ポリシー定義の最新ビルドを再ロードするように Kiro CLI に指示することを忘れないでください。
ポリシーの操作
Kiro CLI を使用してポリシーを調べることができます。たとえば、特定の領域に関連するポリシールールを要約するように Kiro CLI に依頼できます。サンプル宿題ポリシーを例として使用して、数学の宿題を特に制約するルールについて Kiro CLI に指示してもらうことができます。
Can you tell me about the rules that constrainmath homework? Explain the rules themselves and how they fit in the broader policy.
Kiro CLI を使用して、ポリシーに機能を追加することもできます。自動推論ポリシーは、多くの場合、ユーザーのインテントをキャプチャするいくつかの主要な出力変数を回避します。たとえば、サンプル宿題送信ポリシーでは、 isSubmissionAcceptable変数をルールの出力として使用します。Kiro CLI を使用してポリシーを変更し、他のユーザーからの質問をキャプチャできます。新しいルールを追加するときは、「」で説明されているベストプラクティス自動推論ポリシーのベストプラクティス、特に「」に従ってください影響 (=>) を使用してルールを構築する。
ポリシーの編集または改訂
ポリシーがユーザーからの特定の質問を検証できるかどうかを Kiro CLI に尋ねることができます。例えば、宿題ポリシーは、宿題の送信が受け入れられるかどうかを判断することに重点を置いています。この質問では、Kiro CLI から肯定的な回答が期待できます。
Can this policy validate answers about whetherhomework submissions are acceptable?
サンプルホームワークポリシーで宿題提出の遅延について質問した場合、Kiro CLI は、ポリシーが以下の質問に答えることができないことを説明します。
Can this policy validate answers aboutpermissible delays in homework submissions?
Kiro CLI は、ポリシーができることとできないことを説明します。
> 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.
ポリシーでできないことがわかったら、次のプロンプトを使用して Kiro CLI にポリシーを更新してこの情報をキャプチャするように依頼できます。
I would like the policy to also validate answers aboutby 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.
このプロンプトに応答して、Kiro CLI は、新しいタイプの質問を検証するためにポリシーに追加できる一連の変数とルールを提案します。提案を確認し、インテントと一致している場合は、自動推論チェックの注釈 APIs を使用してポリシーにこれらの変更を加えるように Kiro CLI に指示できます。
Looks good. Can you use the annotation APIs to submit these changes to the policy.
Kiro CLI が注釈の準備が整ったことを確認したら、コンソールでポリシーを開いて注釈を確認できます。注釈が正しい場合は、注釈の適用を選択します。
注釈を適用したら、Kiro CLI にポリシーの最新ビルドを再ロードするように依頼し、Kiro CLI が現在のコピーで動作していることを確認します。
I applied the annotations. Reload the latest build of the policy.
テストの失敗に対処する
自動推論ポリシーがアプリケーションによって生成された自然言語を検証できることをテストする良い方法は、テストを使用することです。期待される結果を含むテスト Q&A を作成したら、Kiro CLI を使用して、テストが期待される結果を返さなかった理由を理解し、ポリシーを調整できます。テストの作成と実行の詳細については、「」を参照してください自動推論ポリシーをテストする。Kiro CLI を使用せずにテスト障害を診断する体系的なアプローチについては、「」を参照してください自動推論ポリシーのトラブルシューティングと絞り込み。
-
最初のステップとして、失敗したテストをロードし、ポリシー定義に基づいて期待される結果を返さない理由を説明するように Kiro CLI に依頼します。コンソールまたは APIs を使用して、失敗したテストのテスト ID をコピーします。コンソールでは、テスト ID は、テストを一覧表示するテーブルと、各テストの詳細ページの両方で使用できます。
The test with IDYOUR_TEST_IDis 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. -
Kiro CLI の説明は、ポリシーが正しいことを行っているかどうか (およびテストで期待される結果を変更する必要があるかどうか)、またはポリシーが間違っているかどうかを示します。Kiro CLI にポリシーの変更を提案するように依頼して、テストが期待される結果を返すようにすることができます。
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.注記
ルールの変更を提案する場合、Kiro CLI は特定の例に過剰適合し、他のユースケースでは役に立たないルールを作成しようとすることがあります。テスト出力を確認し、適切な問題に焦点を当てるためのガイダンスを Kiro CLI に与えます。有効なルールの記述に関するガイダンスについては、「」を参照してください自動推論ポリシーのベストプラクティス。
たとえば、
SATISFIABLEテストが を返すようにサンプルのホームワークポリシーを変更するように Kiro に依頼するとVALID、 というルールを作成するなど、テストが常に合格するポリシーにアキシオムを追加することを Kiro が提案する可能性があります(false isHomeworkSubmissionAcceptable)。これにより、値は常に false になります。これにより技術的に問題のあるテストが修正されますが、ポリシー機能全体に悪影響を及ぼす可能性があります。SATISFIABLEテスト結果によって返されるシナリオを分析すると、Kiro CLI に、テストで指定された制約のみを対象とする新しいルールを作成するか、既存のルールを更新してテスト制約のみをチェックするように、より適切なガイダンスを与えることがわかります。 -
提案された変更に満足したら、Kiro CLI に注釈の送信を依頼し、コンソールのユーザーインターフェイスを使用して注釈を確認します。
Looks good. Can you start a build workflow to apply these changes to the policy. -
変更を適用して次のテストに合格したら、Kiro CLI にポリシーの最新ビルドを再ロードするよう依頼します。
I applied the changes. Reload the latest build of the policy.
次の手順
自動推論ポリシーに満足したら、Amazon Bedrock ガードレールで使用できるようにデプロイできます。詳細については、「自動推論ポリシーをアプリケーションでデプロイする」を参照してください。
ポリシーをデプロイした後、実行時に自動推論チェックを使用して LLM レスポンスを検証し、フィードバックに基づいて行動するためのガイダンス自動推論チェックをアプリケーションに統合するについては、「」を参照してください。
自動推論ポリシー API コンテキストプロンプト
次のコンテンツをコピーし、Kiro CLI のプロジェクトフォルダの Markdown ファイルに保存します。このプロンプトは、自動推論ポリシー APIsを正しく操作するために必要なコンテキストを Kiro CLI に提供します。
# 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