feat(examples): add browser-based agent example#384
feat(examples): add browser-based agent example#384michaelruelas wants to merge 6 commits intostrands-agents:mainfrom
Conversation
cagataycali
left a comment
There was a problem hiding this comment.
👀 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_canvastool) - ✅ Uses
dangerouslyAllowBrowser: truecorrectly 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
- Is the
dangerouslyAllowBrowserapproach acceptable, or should there be additional warnings in the docs about API key security? - 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! 🦆
|
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: |
c6a18c0 to
7f17337
Compare
|
@Unshure The Zod error Root cause: The example has Fix: Remove @michaelruelas could you verify this fix resolves the issue? |
|
Hi @michaelruelas, I was messing around with this example locally and made some changes to address the comments I had. I'm going to review this with the rest of my team to try and get it merged asap. |
|
In hindsight, perhaps Homer Simpson was not the best example. |
|
@michaelruelas Are you interested in addressing this feedback? Im happy to take over this pull request and get it merged. I think it brings a lot of value and would like to get it merged soon |
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.
…le updates, improve streaming UI for tool calls, and simplify build configuration.
d5e3649 to
af170d1
Compare
| * The conversation history of messages between user and assistant. | ||
| */ | ||
| public readonly messages: Message[] | ||
| public messages: Message[] |
There was a problem hiding this comment.
Make this not readonly so we can easily reset the messages array like this:
agent.messages = []
| * The conversation history of messages between user and assistant. | ||
| */ | ||
| public readonly messages: Message[] | ||
| public messages: Message[] |
There was a problem hiding this comment.
Note: This changes the public API by removing readonly from the messages property.
This is a reasonable change that enables agent.messages = [] for clearing conversation history. However, since it's a public API change:
- Users can now accidentally overwrite the messages array with a different object
- Consider if a
clearMessages()method would be a safer API
If the team has discussed this and decided direct assignment is the preferred pattern, this is fine. Just flagging for visibility since it wasn't explicitly mentioned in the PR description.
|
Assessment: Comment (Updated from Request Changes) Great progress addressing the previous feedback! The critical Zod dependency issue has been fixed, and several other improvements have been made. Review SummaryFixed ✅
Needs Clarification 🔍
For Awareness 📋
The example now demonstrates browser-based agents effectively. Nice work on the improvements! 🎉 |

Description
This PR adds a new example in
examples/browser-agentthat demonstrates how to implement a Strands Agent in a browser environment.The example includes:
OpenAIModelwithdangerouslyAllowBrowser: trueto run client-side.update_canvasto demonstrate how agents can interact with the webpage DOM.Related Issues
Closes #382
Documentation PR
N/A
Type of Change
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:
npm run buildinexamples/browser-agent(verified passing with aligned dependencies)npm run check(SDK root tests passing)Checklist
examples/browser-agent/README.mdand updated root README)