Amazon Bedrock Agents let you build managed AI agents on AWS that orchestrate foundation models, knowledge bases, and action groups. Weave traces calls to theDocumentation Index
Fetch the complete documentation index at: https://wb-21fd5541-dbrian-docs-2514-bedrock-agents.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
bedrock-agent-runtime client so you can inspect each invoke_agent invocation, including the foundation model, token usage, session ID, and the agent’s response.
The Weave TypeScript SDK doesn’t currently Bedrock Agent integration.
Prerequisites
- A W&B API key. For more information, see API keys.
- AWS credentials configured for an account with access to Bedrock Agents (see Authentication).
-
An existing Bedrock agent and alias. Note the
agentIdandagentAliasId. You can return a list of agents associated with your ID by running the following AWS CLI command, replacing<your-region>with the region slug your agent resides in:
Installation
Install Weave and the AWS SDK:Trace invoke_agent calls
Create a bedrock-agent-runtime client and pass it to patch_client. Weave detects the client type and wraps the invoke_agent method. After patching, use the client as you normally would.
invoke_agent call appears in the Weave UI as a BedrockAgentRuntime.invoke_agent trace. The trace records:
- The agent inputs (
agentId,agentAliasId,sessionId,inputText). - The extracted assistant text from the completion event stream.
- The underlying foundation model used by the agent (extracted from the orchestration trace).
- Token usage (
prompt_tokens,completion_tokens,total_tokens) when reported by the agent.
orchestrationTrace events, which Bedrock only emits when invoke_agent is called with enableTrace=True. Without this flag, traces still capture the inputs and the generated response text, but the foundation model falls back to bedrock-agent:<agentId> and token counts are unavailable.
Wrap an agent call with weave.op
To group an invoke_agent call with related logic, such as preprocessing, postprocessing, or chained API calls, wrap your function with @weave.op. Weave nests the patched invoke_agent trace inside the parent op.
Multi-turn conversations
Bedrock Agents preserve conversation state on the service side when you reuse asessionId. To group multiple turns into a single trace in the Weave UI, wrap the turns in weave.thread:
View traces
When you run the example, Weave prints a link to the project dashboard. Open the link to inspect the agent inputs, foundation model, token usage, and the generated response for eachinvoke_agent call.