Recommendations
Recommendations use AI to generate optimized agent configurations from real session traces. Instead of manually rewriting prompts or tool descriptions, you point the service at your agent’s traces, specify a target evaluator as the reward signal, and receive an optimized configuration.
Note
Recommendations are generated by LLMs. Review and test before applying them.
Amazon Bedrock AgentCore supports two recommendation types:
-
System prompt recommendation: Analyzes agent traces and generates an optimized system prompt that improves performance on the target evaluator. The service identifies failure patterns and adds specific behavioral instructions.
-
Tool description recommendation: Analyzes agent traces and generates sharpened tool descriptions that reduce tool selection confusion. This is useful when agents select the wrong tool for ambiguous requests.
Each recommendation requires two inputs: the current agent configuration to optimize, and agent traces to analyze.
Topics
Configuration input modes
You provide the current configuration in one of two ways:
-
Inline text: Provide the configuration directly as a string in the API request. For system prompt recommendations, pass the prompt text in the
systemPrompt.textfield. For tool description recommendations, pass each tool’s name and description in thetoolDescription.toolDescriptionText.toolslist. This mode is useful for quick experimentation, when you want to test a prompt you are actively iterating on, or when your configuration is not stored in a bundle.Recommendation type CLI flags API field System prompt
--inline "prompt text"or--prompt-file ./path.txtsystemPrompt.textTool description
--tools "name:description, name:description"toolDescription.toolDescriptionText.tools: list of objects withtoolNameandtoolDescription -
Configuration bundle: Reference an existing configuration bundle version. The service reads the current configuration from the bundle using the JSON path you specify, generates the optimized version, and writes the result back to a new bundle version. This keeps your optimization history versioned alongside your bundle. This mode is useful when you manage configurations centrally with configuration bundles and want the optimized output written back to the bundle automatically.
Recommendation type CLI flags API field System prompt
--bundle-name <bundle-name>+--bundle-version <bundle-version>+--system-prompt-json-path <path>systemPrompt.configurationBundlewithbundleArn,versionId,systemPromptJsonPathTool description
--bundle-name <bundle-name>+--bundle-version <bundle-version>+--tool-desc-json-path "name:jsonpath"(repeat for each tool)toolDescription.configurationBundlewithbundleArn,versionId, andtoolslist containingtoolNameandtoolDescriptionJsonPathWhen using a configuration bundle, the recommendation result includes a
configurationBundlefield with thebundleArnand a newversionIdpointing to the bundle version that contains the optimized configuration.
Agent trace sources
The agentTraces parameter accepts one of two sources:
-
CloudWatch Logs: Use when your agent runtime writes telemetry to CloudWatch. The service reads traces directly from the specified log groups within a required time range. You must provide
logGroupArns,serviceNames,startTime, andendTime. An optionalrulefield allows you to filter traces (for example, selecting only sessions wheregoal_success_rateis below a threshold).Note
The recommendations API uses log group ARNs (
logGroupArns), not log group names. This differs from batch evaluations, which uselogGroupNames.Field Type Required Description cloudwatchLogs.logGroupArnsList of strings
Yes
CloudWatch Logs log group ARNs where agent telemetry is stored. Format:
arn:aws:logs:{region}:{account}:log-group:{log-group-name}.cloudwatchLogs.serviceNamesList of strings
Yes
Service names that identify your agent’s traces in CloudWatch. Convention:
{RuntimeName}.DEFAULT.cloudwatchLogs.startTimeISO 8601 datetime
Yes
Start of the trace collection window. Only traces after this time are included.
cloudwatchLogs.endTimeISO 8601 datetime
Yes
End of the trace collection window. Only traces before this time are included.
cloudwatchLogs.ruleObject
No
Optional filter rule to narrow trace selection. Contains a
filterslist where each filter specifies akey,operator(such asLESS_THAN), andvalue(such as{"doubleValue": 0.5}).Example
-
Inline session spans: Use when you have traces available locally (for example, from a local test run, a CI/CD pipeline, or a specific session you want to optimize against). You provide the spans directly in the API request body as a list of OpenTelemetry-compatible span objects.
Field Type Required Description sessionSpansList of objects
Yes
Agent trace spans in OpenTelemetry-compatible format. Each span includes trace ID, span ID, name, timestamps, and attributes.
Example
The AgentCore CLI provides convenience flags that map to the underlying API trace source types:
| CLI flag | API mapping | Description |
|---|---|---|
|
|
|
Collects traces from the last N days via CloudWatch Logs. The CLI resolves log group ARNs and service names from the runtime configuration. |
|
|
|
Collects spans for the specified session client-side and passes them as inline session spans. The recommendation API itself does not support session ID filtering on CloudWatch sources. |
|
|
|
Reads spans from a local JSON file and passes them as inline session spans. |