Invoke an inline agent
Before you invoke your inline agent, make sure you've completed the Prerequisites.
To invoke an inline agent, send a InvokeInlineAgent API request with an Agents for Amazon Bedrock runtime endpoint and minimally include the following fields.
Field | Use case |
---|---|
instruction | Provide instructions that tell the inline agent what it should do and how it should interact with users. |
foundationModel | Specify a foundation model to use for orchestration by the inline agent you create. For example, anthropic claude, meta Llama3.1, etc. |
sessionId | An unique identifier of the session. Use the same value across requests to continue same conversation. |
The following fields are optional:
Field | Use case |
---|---|
actionGroups | List of action groups with each action group defining the actions that the inline agent can carry out. |
knowledgeBases | Knowledge base associations with inline agent to augment response generated by the model. |
guardrailConfiguration | Guardrail configurations to block topics, to prevent hallucinations, and to implement safeguards for your application. |
promptOverrideConfiguration | Configurations for advanced prompts used to override the default prompts. |
enableTrace | Specify whetehr to turn on the trace or not to track the inline agent's reasoning process. |
idleSessionTTLInSeconds | Specify the duration after which the inline agent should end the session and delete any stored information. |
customerEncryptionKeyArn | Specify the ARN of a KMS key to encrypt agent resources, |
endSession | Specify whether to end the session with the inline agent or not. |
inlineSessionState | Parameters that specify the various attributes of a sessions. |
inputText | Specify the prompt text to send to the agent. |
The following InvokeInlineAgent
API example provides complete inline agent
configurations including the foundation model, instructions, action groups with code
interpreter, guardrails, and knowledge bases.
response = bedrock_agent_runtime.invoke_inline_agent( // Initialization parameters: cannot be changed for a conversation sessionId='uniqueSessionId', customerEncryptionKeyArn: String, // Input inputText="Hello, can you help me with a task?", endSession=False, enableTrace=True, // Agent configurations foundationModel='anthropic.claude-3-haiku-20240307-v1:0', instruction="You are a helpful assistant...", actionGroups=[ { 'name': 'CodeInterpreterAction', 'parentActionGroupSignature': 'AMAZON.CodeInterpreter' }, { 'actionGroupName': 'FetchDetails', 'parentActionGroupSignature': '', "actionGroupExecutor": { ... }, "apiSchema": { ... }, "description": "string", "functionSchema": { ... } } ], knowledgeBases=[ { knowledgeBaseId: "string", description: 'Use this KB to get all the info', retrievalConfiguration: { vectorSearchConfiguration: { filter: { ... }, numberOfResults: number, overrideSearchType: "string" } } } ], guardrailConfiguration={ guardrailIdentifier: 'BlockEverything', gurardrailVersion: '1.0' }, promptOverrideConfiguration: {...} // session properties: persisted throughout conversation inlineSessionState = { sessionAttributes = { 'key': 'value' }, promptSessionAttributes = {k:v}, returnControlInvocationResults = {...}, invocationId = 'abc', files = {...}, } }