View a markdown version of this page

권장 사항 가져오기 - Amazon Bedrock AgentCore

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

권장 사항 가져오기

권장 사항의 상태 및 결과를 검색합니다. 권장 사항이 터미널 상태(COMPLETED 또는 )에 도달할 때까지이 작업을 폴링합니다FAILED.

코드 샘플

예
AgentCore CLI

agentcore run recommendation는 fire-and-forget 작업을 제출합니다. 터미널 상태에 도달할 때까지 블록--wait에 전달하거나 나중에 ID로 확인합니다.

agentcore view recommendation <recommendation-id>

모든 권장 작업을 나열하거나 JSON으로 봅니다.

agentcore view recommendation agentcore view recommendation <recommendation-id> --json
AWS SDK (boto3)

완료될 때까지 폴링하고 결과를 추출합니다.

import time import boto3 client = boto3.client("bedrock-agentcore", region_name="us-west-2") # Poll until terminal state while True: result = client.get_recommendation(recommendationId=recommendation_id) status = result["status"] print(f"Status: {status}") if status in ("COMPLETED", "FAILED"): break time.sleep(15) # Extract system prompt result if status == "COMPLETED": rec_result = result.get("recommendationResult", {}) if "systemPromptRecommendationResult" in rec_result: sys_result = rec_result["systemPromptRecommendationResult"] print(f"Recommended prompt:\n{sys_result['recommendedSystemPrompt']}") if "explanation" in sys_result: print(f"Explanation:\n{sys_result['explanation']}") if "configurationBundle" in sys_result: bundle = sys_result["configurationBundle"] print(f"New bundle version: {bundle['versionId']}") elif "toolDescriptionRecommendationResult" in rec_result: tool_result = rec_result["toolDescriptionRecommendationResult"] for tool in tool_result.get("tools", []): print(f"{tool['toolName']}: {tool['recommendedToolDescription']}") if "explanation" in tool: print(f" Explanation: {tool['explanation']}") elif status == "FAILED": rec_result = result.get("recommendationResult", {}) r = rec_result.get("systemPromptRecommendationResult") or rec_result.get("toolDescriptionRecommendationResult") print(f"Error: [{r['errorCode']}] {r['errorMessage']}")

A/B 테스트에 사용할 구성 번들 참조 추출:

result = client.get_recommendation(recommendationId=recommendation_id) if result["status"] == "COMPLETED": rec_result = result["recommendationResult"] sys_result = rec_result.get("systemPromptRecommendationResult", {}) if "configurationBundle" in sys_result: bundle_arn = sys_result["configurationBundle"]["bundleArn"] version_id = sys_result["configurationBundle"]["versionId"] print(f"Use in A/B test: bundle={bundle_arn}, version={version_id}")

요청 파라미터

파라미터 유형 필수 설명

recommendationId

문자열

예

에서 반환한 권장 사항 ID입니다StartRecommendation. 경로 파라미터로 전달됩니다.

응답

Field 유형 설명

recommendationId

문자열

권장 사항의 고유 식별자입니다.

recommendationArn

문자열

권장 사항의 ARN입니다.

name

문자열

권장 사항 이름입니다.

type

문자열

SYSTEM_PROMPT_RECOMMENDATION 또는 TOOL_DESCRIPTION_RECOMMENDATION

status

문자열

현재 상태: PENDING, IN_PROGRESS, COMPLETEDFAILED, 또는 DELETING.

recommendationConfig

객체

제출한 구성입니다.

recommendationResult

객체

상태가 일 때 표시됩니다COMPLETED. 최적화된 구성을 포함합니다. 셰이프는 권장 사항 유형에 따라 다릅니다.

createdAt

타임스탬프

권장 사항이 생성된 시간입니다.

updatedAt

타임스탬프

권장 사항이 마지막으로 업데이트된 시간입니다.

시스템 프롬프트 결과 필드

유형이 인 recommendationResult.systemPromptRecommendationResult 경우에 있음SYSTEM_PROMPT_RECOMMENDATION:

Field 유형 설명

recommendedSystemPrompt

문자열

최적화된 시스템 프롬프트 텍스트입니다.

configurationBundle

객체

입력이 구성 번들일 때 표시됩니다. 새 번들 버전에 versionId 대한 bundleArn 및를 포함합니다.

explanation

문자열

권장 사항이 생성된 이유와 제안된 변경 사항의 근거에 대한 설명입니다.

errorCode

문자열

실패 시 존재합니다. 오류 코드.

errorMessage

문자열

실패 시 존재합니다. 사람이 읽을 수 있는 설명입니다.

도구 설명 결과 필드

유형이 인 recommendationResult.toolDescriptionRecommendationResult 경우에 있음TOOL_DESCRIPTION_RECOMMENDATION:

Field 유형 설명

tools

목록

도구별 결과. 각 항목에는 toolName, 및 recommendedToolDescription가 포함됩니다explanation.

configurationBundle

객체

입력이 구성 번들일 때 표시됩니다. 새 번들 버전에 versionId 대한 bundleArn 및를 포함합니다.

errorCode

문자열

실패 시 존재합니다. 오류 코드.

errorMessage

문자열

실패 시 존재합니다. 사람이 읽을 수 있는 설명입니다.

예제 응답

완료된 시스템 프롬프트 권장 사항(인라인 입력):

{ "recommendationId": "MyPromptRec-Ab1Cd2Ef3G", "recommendationArn": "arn:aws:bedrock-agentcore:us-west-2:123456789012:recommendation/MyPromptRec-Ab1Cd2Ef3G", "name": "my-prompt-rec", "type": "SYSTEM_PROMPT_RECOMMENDATION", "status": "COMPLETED", "recommendationConfig": { ... }, "recommendationResult": { "systemPromptRecommendationResult": { "recommendedSystemPrompt": "<optimized system prompt text>", "explanation": "<explanation of why the recommendation was generated>" } }, "createdAt": "2025-03-15T10:00:00Z", "updatedAt": "2025-03-15T10:05:30Z" }

완료된 시스템 프롬프트 권장 사항(구성 번들 입력):

{ "recommendationId": "MyBundleRec-Xy9Zw8Vq1R", "recommendationArn": "arn:aws:bedrock-agentcore:us-west-2:123456789012:recommendation/MyBundleRec-Xy9Zw8Vq1R", "name": "my-bundle-prompt-rec", "type": "SYSTEM_PROMPT_RECOMMENDATION", "status": "COMPLETED", "recommendationConfig": { ... }, "recommendationResult": { "systemPromptRecommendationResult": { "recommendedSystemPrompt": "<optimized system prompt text>", "configurationBundle": { "bundleArn": "arn:aws:bedrock-agentcore:us-west-2:123456789012:configuration-bundle/myBundle-Ab1Cd2Ef3G", "versionId": "12345678-1234-1234-1234-123456789012" }, "explanation": "<explanation of why the recommendation was generated>" } }, "createdAt": "2025-03-15T10:00:00Z", "updatedAt": "2025-03-15T10:06:12Z" }

완료된 도구 설명 권장 사항:

{ "recommendationId": "MyToolRec-Qr5St6Uv7W", "recommendationArn": "arn:aws:bedrock-agentcore:us-west-2:123456789012:recommendation/MyToolRec-Qr5St6Uv7W", "name": "my-tool-rec", "type": "TOOL_DESCRIPTION_RECOMMENDATION", "status": "COMPLETED", "recommendationConfig": { ... }, "recommendationResult": { "toolDescriptionRecommendationResult": { "tools": [ { "toolName": "<tool-name-1>", "recommendedToolDescription": "<optimized description for tool 1>", "explanation": "<explanation of why this tool description was changed>" }, { "toolName": "<tool-name-2>", "recommendedToolDescription": "<optimized description for tool 2>", "explanation": "<explanation of why this tool description was changed>" } ] } }, "createdAt": "2025-03-15T11:00:00Z", "updatedAt": "2025-03-15T11:04:45Z" }

실패한 권장 사항:

{ "recommendationId": "MyFailedRec-Mn3Op4Qr5S", "recommendationArn": "arn:aws:bedrock-agentcore:us-west-2:123456789012:recommendation/MyFailedRec-Mn3Op4Qr5S", "name": "my-failed-rec", "type": "SYSTEM_PROMPT_RECOMMENDATION", "status": "FAILED", "recommendationConfig": { ... }, "recommendationResult": { "systemPromptRecommendationResult": { "errorCode": "<error-code>", "errorMessage": "<human-readable error description>" } }, "createdAt": "2025-03-15T12:00:00Z", "updatedAt": "2025-03-15T12:01:10Z" }

오류

오류 HTTP 상태 설명

ResourceNotFoundException

404

지정된 ID로 추천을 찾을 수 없습니다.

ValidationException

400

잘못된 권장 사항 ID 형식입니다.

AccessDeniedException

403

권한이 부족합니다.

ThrottlingException

429

요청 속도가 초과되었습니다.

InternalServerException

500

서비스 측 오류입니다.