Skip to content

Conversation

@michaelruelas
Copy link

Description

This PR adds a new example in examples/browser-agent that demonstrates how to implement a Strands Agent in a browser environment.

The example includes:

  • Interactive UI: A simple HTML/Tailwind interface with a chat window and a modifiable canvas (DOM element).
  • Browser-Ready Agent: Configures OpenAIModel with dangerouslyAllowBrowser: true to run client-side.
  • Custom Tool: Implements update_canvas to demonstrate how agents can interact with the webpage DOM.
  • Vite Integration: Includes configuration for developing and building the agent with Vite, using path aliases to link against the local SDK source.
  • Documentation: Includes a dedicated README for the example and updates the root README.

Related Issues

Closes #382

Documentation PR

N/A

Type of Change

  • New feature
  • Documentation update

Testing

I manually verified the example by running it locally and interacting with the agent to request UI changes. I captured a demonstration of the agent successfully modifying the canvas based on natural language commands.
I also verified the build pipeline:

  • I ran npm run build in examples/browser-agent (verified passing with aligned dependencies)
  • I ran npm run check (SDK root tests passing)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works (Manual verification example provided)
  • I have updated the documentation accordingly (Added examples/browser-agent/README.md and updated root README)
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

This commit adds a new example in  that demonstrates
how to use the SDK in a browser environment. It includes:
- A simple HTML UI with a chat interface and a modifiable canvas.
- An agent configured with  and a custom tool.
- Vite configuration for development and building.
- README documentation for the example.

Updates root README to link to the new example.
Copy link
Member

@cagataycali cagataycali left a comment

Choose a reason for hiding this comment

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

👀 Initial Review - Browser Agent Example

Summary

Great example demonstrating browser-based Strands agents! This addresses the "good first issue" #382 nicely.

What I Like

  • ✅ Clear PR description with all checklist items completed
  • ✅ Proper documentation (README in example + root README update)
  • ✅ Demonstrates real DOM manipulation (update_canvas tool)
  • ✅ Uses dangerouslyAllowBrowser: true correctly with OpenAI
  • ✅ Vite integration for modern development workflow

Observations

The CI is still pending (waiting for integration tests). Once CI passes, this looks ready for maintainer review.

Questions for Maintainers

  1. Is the dangerouslyAllowBrowser approach acceptable, or should there be additional warnings in the docs about API key security?
  2. Any concerns about the Vite path alias configuration linking to local SDK source?

Looking forward to seeing this merged - it will be a valuable example for the community! 🦆

// Initialize model
// Note: In a production app, you should proxy requests to avoid exposing keys,
// or use a provider that supports browser-safe authentication.
const model = new OpenAIModel({
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this configurable between bedrock or openAI?

Copy link
Member

Choose a reason for hiding this comment

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

Do we need this file? I tested locally after removing this file, and it worked for me. I want to remove as much unnecessary code as possible so this is really easy to replicate


// We will update this div as tokens come in
for await (const event of agent.stream(text)) {
if (event.type === 'modelContentBlockDeltaEvent' && event.delta.type === 'textDelta') {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can we add some sort of message to indicate what the toolUse was in the chat ui?

@Unshure Unshure self-assigned this Jan 14, 2026
@strands-agents strands-agents deleted a comment from strands-agent Jan 14, 2026
…le updates, improve streaming UI for tool calls, and simplify build configuration.
@Unshure
Copy link
Member

Unshure commented Jan 30, 2026

I just tried running this example, and it seems like the chat experience is broken now?

Im getting this error when I try to send a message:

Uncaught TypeError: can't access property "_zod", schema is undefined
    process to-json-schema.js:15
    process to-json-schema.js:340
    process to-json-schema.js:539
    process to-json-schema.js:52
    process to-json-schema.js:211
    toJSONSchema to-json-schema.js:819
    ZodTool zod-tool.ts:91
    tool zod-tool.ts:237
    <anonymous> tools.ts:3
[to-json-schema.js:15:21](http://localhost:5173/node_modules/zod/v4/core/to-json-schema.js)
    process to-json-schema.js:15
    process to-json-schema.js:340
    process to-json-schema.js:539
    process to-json-schema.js:52
    process to-json-schema.js:211
    toJSONSchema to-json-schema.js:819
    ZodTool zod-tool.ts:91
    tool zod-tool.ts:237
    <anonymous> tools.ts:3

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Browser Agent Example

3 participants