Skip to content

BedrockAgentRuntimeClient.invoke_agent

rboto-bedrock-agent-runtime==0.4.0 · Service index · Types

Model summary (excerpt): Amazon Bedrock Agents (now Amazon Bedrock Agents Classic) is no longer open to new customers. For capabilities similar to Bedrock Agents Classic, explore Amazon Bedrock AgentCore. Existing customers can continue to use the service as normal. For more information, see Amazon Bedrock Agents Classic availability change . Sends a prompt for the agent to process and respond to. Note the following...

Install and imports

python -m pip install "rboto[bedrock-agent-runtime]==0.4.0"
from rboto import BedrockAgentRuntimeClient
from rboto_bedrock_agent_runtime.types import (
    BedrockModelConfigurations,
    InvokeAgentOutput,
    PromptCreationConfigurations,
    SessionState,
    StreamingConfigurations,
)

Signature

async def invoke_agent(
    *,
    agent_id: str,
    agent_alias_id: str,
    session_id: str,
    session_state: SessionState | None = None,
    end_session: bool | None = None,
    enable_trace: bool | None = None,
    input_text: str | None = None,
    memory_id: str | None = None,
    bedrock_model_configurations: BedrockModelConfigurations | None = None,
    streaming_configurations: StreamingConfigurations | None = None,
    prompt_creation_configurations: PromptCreationConfigurations | None = None,
    source_arn: str | None = None,
) -> InvokeAgentOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
agent_id Yes The unique identifier of the agent to use.
agent_alias_id Yes The alias of the agent to use.
session_id Yes The unique identifier of the session. Use the same value across requests to continue the same conversation.
session_state No Contains parameters that specify various attributes of the session. For more information, see Control session context . If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.
end_session No Specifies whether to end the session with the agent or not.
enable_trace No Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Trace enablement .
input_text No The prompt text to send the agent. If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.
memory_id No The unique identifier of the agent memory.
bedrock_model_configurations No Model performance settings for the request.
streaming_configurations No Specifies the configurations for streaming. To use agent streaming, you need permissions to perform the bedrock:InvokeModelWithResponseStream action.
prompt_creation_configurations No Specifies parameters that control how the service populates the agent prompt for an InvokeAgent 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.
source_arn No The ARN of the resource making the request.

Output

InvokeAgentOutput.

Typed response mapping, accessed as response["field"].

Field Type Presence References
completion AsyncIterator[ResponseStream] Always present ResponseStream
content_type str Always present —
session_id str Always present —
memory_id str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

BedrockModelConfigurations, InvokeAgentOutput, PromptCreationConfigurations, SessionState, StreamingConfigurations

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

Output streams: InvokeAgentOutput.

Consume with async for. Do not reuse a consumed stream.

Errors

Import from rboto_bedrock_agent_runtime.exceptions:

AccessDeniedError, BadGatewayError, ConflictError, DependencyFailedError, InternalServerError, ModelNotReadyError, ResourceNotFoundError, ServiceQuotaExceededError, ThrottlingError, ValidationError.

Stream decoding may also raise the linked modeled event errors.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model