Skip to content

docs(weave): add Bedrock Agents integration guide#2616

Open
dbrian57 wants to merge 2 commits into
mainfrom
dbrian/docs-2514-bedrock-agents
Open

docs(weave): add Bedrock Agents integration guide#2616
dbrian57 wants to merge 2 commits into
mainfrom
dbrian/docs-2514-bedrock-agents

Conversation

@dbrian57
Copy link
Copy Markdown
Contributor

@dbrian57 dbrian57 commented May 12, 2026

Summary

  • Adds a new Weave integration guide for Amazon Bedrock Agents at weave/guides/integrations/bedrock_agents.mdx.
  • Documents tracing invoke_agent calls via patch_client, wrapping calls with @weave.op, and grouping multi-turn sessions with weave.thread.
  • Adds the new page to the Frameworks group in docs.json, alongside other agent-orchestration integrations (openai_agents, claude_agent).

Jira: DOCS-2514

Supersedes #2615 (that branch had unrelated MCP-server commits mixed in).

Test plan

  • Mintlify preview renders the new page correctly
  • Page appears in the sidebar under Integrate with your LLM provider and frameworks > Frameworks
  • Code samples run end-to-end against a real Bedrock agent (requires AWS credentials and an existing agent + alias)
  • SME accuracy review (see PR comment)

🤖 Generated with Claude Code

Add a new Weave integration page for Amazon Bedrock Agents under the
Frameworks group, mirroring the structure of the existing Bedrock and
agent-framework integration docs. Covers tracing invoke_agent calls via
patch_client, wrapping calls with weave.op, and grouping multi-turn
sessions with weave.thread.

Jira: DOCS-2514

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dbrian57 dbrian57 requested a review from a team as a code owner May 12, 2026 18:27
@dbrian57 dbrian57 added the author-docs-plugin Docs PRs authored via Cursor author-docs skill label May 12, 2026
@dbrian57
Copy link
Copy Markdown
Contributor Author

dbrian57 commented May 12, 2026

Sources and decision log

Sources

  • Existing Weave integration patterns:
  • Source of truth for the integration's behavior: weave/integrations/bedrock/bedrock_sdk.py in the wandb/weave repo. Specifically:
    • patch_client detects the bedrock-agent-runtime client via hasattr(client, "invoke_agent") and wraps it with _patch_invoke_agent. Op name: BedrockAgentRuntime.invoke_agent.
    • postprocess_output_invoke_agent walks the completion EventStream, extracts chunk.bytes text, and reads orchestrationTrace.modelInvocationInput.foundationModel and orchestrationTrace.modelInvocationOutput.metadata.usage for the foundation model name and token usage.
    • bedrock_agent_on_finish_invoke_agent falls back to bedrock-agent:<agentId> when foundation model info is unavailable.
  • Test reference: tests/integrations/bedrock/bedrock_test.py::test_bedrock_agent_invoke_agent — confirms the invoke_agent(agentId=..., agentAliasId=..., sessionId=..., inputText=...) call signature and the captured trace structure.
  • Re-export: weave/integrations/bedrock/__init__.py re-exports patch_client, so the short import path from weave.integrations.bedrock import patch_client works.

Decisions

  • Nav placement under Frameworks, not LLM Providers. Bedrock Agents is an agent-orchestration framework (it wraps a foundation model with tools, knowledge bases, and action groups), so it sits more naturally next to openai_agents and claude_agent than next to bedrock. Confirmed with the author.
  • Example includes enableTrace=True. The integration only captures the foundation model name and token usage when orchestrationTrace events are present in the completion stream, which Bedrock only emits when enableTrace=True is passed. Without it, traces still capture inputs and the assistant text, but model/usage fall back to defaults. A <Note> callout explains this.
  • Short import path. Used from weave.integrations.bedrock import patch_client (re-exported) rather than the deeper bedrock_sdk path used by the existing bedrock.mdx page. Confirmed with the author.
  • No "How It Works" section. Per the author's request.
  • No image/screenshot. Skipped because there's no existing Bedrock Agents screenshot in weave/guides/integrations/imgs/ and the author didn't request one.

Intentionally omitted

  • Action groups, knowledge bases, and guardrail configuration on the Bedrock side. Out of scope for a Weave integration page — readers configure those in the AWS console and Bedrock docs.
  • A weave.Model example. The Bedrock page includes one for the converse API; Bedrock Agents is invoked by ID + alias, so a Model subclass adds little beyond what @weave.op already shows. Skipped to keep the page concise.

Needs SME verification

  • Token usage capture: Confirm token counts are populated in the BedrockAgentRuntime.invoke_agent trace summary when enableTrace=True is set on a real Bedrock Agent (not a mock). The code reads orchestrationTrace.modelInvocationOutput.metadata.usage, but I have not run this against a live agent.
  • Foundation model extraction: Confirm _bedrock_agent_foundation_model is reliably populated from the first orchestrationTrace.modelInvocationInput.foundationModel seen in the stream. The code looks correct but I haven't verified end-to-end.
  • weave.thread + Bedrock sessionId: I recommend reusing t.thread_id as the Bedrock sessionId. This works as long as t.thread_id is a valid Bedrock session ID format. If Bedrock has stricter format requirements (length, character set), readers may need to derive a separate ID. Please verify.
  • patch_client idempotency: If a reader calls patch_client more than once on the same client (for example, after re-running a notebook cell), does it double-wrap? The page doesn't warn about this. Worth confirming whether to add a note.

Related

Resume prompt

I'm picking up work on #2615 (Jira: DOCS-2514), a new Weave integration page for Amazon Bedrock Agents at weave/guides/integrations/bedrock_agents.mdx. The page documents tracing invoke_agent calls via patch_client on a bedrock-agent-runtime boto3 client, including enableTrace=True so the foundation model and token usage get captured. It's listed under the Frameworks group in docs.json, next to openai_agents and claude_agent. Decisions made: short import path (from weave.integrations.bedrock import patch_client), no "How It Works" section, no weave.Model example, no screenshot. Outstanding items for SME verification are listed in the PR comment under "Needs SME verification". The integration source code is in weave/integrations/bedrock/bedrock_sdk.py — specifically _patch_invoke_agent, postprocess_output_invoke_agent, and bedrock_agent_on_finish_invoke_agent. The test reference is tests/integrations/bedrock/bedrock_test.py::test_bedrock_agent_invoke_agent.

{
  "skill": "docs",
  "version": "unknown",
  "depends_on": "unknown",
  "model": "claude-opus-4-7",
  "note": "versions.json not present in the skill folder at runtime"
}

@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 12, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
wandb 🟢 Ready View Preview May 12, 2026, 6:32 PM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

📚 Mintlify Preview Links

🔗 View Full Preview

✨ Added (1 total)

📄 Pages (1)

File Preview
weave/guides/integrations/bedrock_agents.mdx Bedrock Agents

📝 Changed (1 total)

⚙️ Other (1)
File
docs.json

🤖 Generated automatically when Mintlify deployment succeeds
📍 Deployment: 2542dc6 at 2026-05-15 14:43:34 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

🔗 Link Checker Results

All links are valid!

No broken links were detected.

Checked against: https://wb-21fd5541-dbrian-docs-2514-bedrock-agents.mintlify.app

Copy link
Copy Markdown
Contributor

@anastasiaguspan anastasiaguspan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! is this part of the agent launch at EOM?


## Installation

Install Weave and the AWS SDK:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Install Weave and the AWS SDK:
Install Weave and the AWS SDK for Python:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are 11+ AWS SDKs :) this is more specific


- A W&B API key. For more information, see [API keys](/platform/app/settings-page/user-settings#api-keys).
- AWS credentials configured for an account with access to Bedrock Agents (see [Authentication](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html)).
- An existing Bedrock agent and alias. Note the `agentId` and `agentAliasId`. 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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confused by this note? where am i to note these, i don't see them mentioned elsewhere

## Prerequisites

- A W&B API key. For more information, see [API keys](/platform/app/settings-page/user-settings#api-keys).
- AWS credentials configured for an account with access to Bedrock Agents (see [Authentication](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html)).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- AWS credentials configured for an account with access to Bedrock Agents (see [Authentication](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html)).
- AWS credentials configured for an account with access to Bedrock Agents (see [Identity and access management for Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes it clearer to user they're linking out from us

ask_agent(prompt, session_id=t.thread_id)
```

Weave displays each turn in the UI as individual rows in the Threads view.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a new page coming in the new Agents section of the UI?

- 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.

Foundation model and token usage are extracted from `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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Foundation model and token usage are extracted from `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.
The foundation model and token usage are extracted from `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.


Foundation model and token usage are extracted from `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`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MOre of a philosophical question, but although this topic header is not wrong, and i often write them the same way (as does ai), it seems more like the answer than what the user is wanting to know. i wonder if "Nest related agent calls together" might be the scenario they'd be searching/scanning for? (i also wonder if this is something we could improve on the plugin)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-docs-plugin Docs PRs authored via Cursor author-docs skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants