Skip to content

Bedrock Agent Runtime  >  Operations  >  invoke_inline_agent

invoke_inline_agent

Operation

invoke_inline_agent async

invoke_inline_agent(input: InvokeInlineAgentInput, plugins: list[Plugin] | None = None) -> OutputEventStream[InlineAgentResponseStream, InvokeInlineAgentOutput]

Invokes an inline Amazon Bedrock agent using the configurations you provide with the request.

  • Specify the following fields for security purposes.

  • (Optional) customerEncryptionKeyArn -- The Amazon Resource Name (ARN) of a KMS key to encrypt the creation of the agent.

  • (Optional) idleSessionTTLinSeconds -- Specify the number of seconds for which the agent should maintain session information. After this time expires, the subsequent InvokeInlineAgent request begins a new session.

  • To override the default prompt behavior for agent orchestration and to use advanced prompts, include a promptOverrideConfiguration object. For more information, see Advanced prompts.

  • The agent instructions will not be honored if your agent has only one knowledge base, uses default prompts, has no action group, and user input is disabled.

Note:

Parameters:

Name Type Description Default
input InvokeInlineAgentInput

An instance of InvokeInlineAgentInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
OutputEventStream[InlineAgentResponseStream, InvokeInlineAgentOutput]

An OutputEventStream for server-to-client streaming.

Input

InvokeInlineAgentInput dataclass

Dataclass for InvokeInlineAgentInput structure.

Attributes

action_groups class-attribute instance-attribute
action_groups: list[AgentActionGroup] | None = None

A list of action groups with each action group defining the action the inline agent needs to carry out.

agent_collaboration class-attribute instance-attribute
agent_collaboration: AgentCollaboration | None = None

Defines how the inline collaborator agent handles information across multiple collaborator agents to coordinate a final response. The inline collaborator agent can also be the supervisor.

agent_name class-attribute instance-attribute
agent_name: str | None = field(repr=False, default=None)

The name for the agent.

bedrock_model_configurations class-attribute instance-attribute
bedrock_model_configurations: InlineBedrockModelConfigurations | None = None

Model settings for the request.

collaborator_configurations class-attribute instance-attribute
collaborator_configurations: list[CollaboratorConfiguration] | None = None

Settings for an inline agent collaborator called with InvokeInlineAgent.

collaborators class-attribute instance-attribute
collaborators: list[Collaborator] | None = None

List of collaborator inline agents.

custom_orchestration class-attribute instance-attribute
custom_orchestration: CustomOrchestration | None = None

Contains details of the custom orchestration configured for the agent.

customer_encryption_key_arn class-attribute instance-attribute
customer_encryption_key_arn: str | None = None

The Amazon Resource Name (ARN) of the Amazon Web Services KMS key to use to encrypt your inline agent.

enable_trace class-attribute instance-attribute
enable_trace: bool | None = None

Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Using trace.

end_session class-attribute instance-attribute
end_session: bool | None = None

Specifies whether to end the session with the inline agent or not.

foundation_model class-attribute instance-attribute
foundation_model: str | None = None

The model identifier (ID) of the model to use for orchestration by the inline agent. For example, meta.llama3-1-70b-instruct-v1:0.

guardrail_configuration class-attribute instance-attribute
guardrail_configuration: GuardrailConfigurationWithArn | None = None

The guardrails to assign to the inline agent.

idle_session_ttl_in_seconds class-attribute instance-attribute
idle_session_ttl_in_seconds: int | None = None

The number of seconds for which the inline agent should maintain session information. After this time expires, the subsequent InvokeInlineAgent request begins a new session.

A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and the data provided before the timeout is deleted.

inline_session_state class-attribute instance-attribute
inline_session_state: InlineSessionState | None = None

Parameters that specify the various attributes of a sessions. You can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group. For more information, see Control session context.

Note

If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.

input_text class-attribute instance-attribute
input_text: str | None = field(repr=False, default=None)

The prompt text to send to the agent.

Note

If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.

instruction class-attribute instance-attribute
instruction: str | None = field(repr=False, default=None)

The instructions that tell the inline agent what it should do and how it should interact with users.

knowledge_bases class-attribute instance-attribute
knowledge_bases: list[KnowledgeBase] | None = None

Contains information of the knowledge bases to associate with.

orchestration_type class-attribute instance-attribute
orchestration_type: OrchestrationType | None = None

Specifies the type of orchestration strategy for the agent. This is set to DEFAULT orchestration type, by default.

prompt_creation_configurations class-attribute instance-attribute
prompt_creation_configurations: PromptCreationConfigurations | None = None

Specifies parameters that control how the service populates the agent prompt for an InvokeInlineAgent request. You can control which aspects of previous invocations in the same agent session the service uses to populate the agent prompt. This gives you more granular control over the contextual history that is used to process the current request.

prompt_override_configuration class-attribute instance-attribute
prompt_override_configuration: PromptOverrideConfiguration | None = field(repr=False, default=None)

Configurations for advanced prompts used to override the default prompts to enhance the accuracy of the inline agent.

session_id class-attribute instance-attribute
session_id: str | None = None

The unique identifier of the session. Use the same value across requests to continue the same conversation.

streaming_configurations class-attribute instance-attribute
streaming_configurations: StreamingConfigurations | None = None

Specifies the configurations for streaming.

Note

To use agent streaming, you need permissions to perform the bedrock:InvokeModelWithResponseStream action.

Output

This operation returns an OutputEventStream for server-to-client streaming.

Event Stream Structure

Output Event Type

InlineAgentResponseStream

Initial Response Structure

InvokeInlineAgentOutput dataclass

Dataclass for InvokeInlineAgentOutput structure.

Attributes
content_type instance-attribute
content_type: str

The MIME type of the input data in the request. The default value is application/json.

session_id instance-attribute
session_id: str

The unique identifier of the session with the agent.