-
Notifications
You must be signed in to change notification settings - Fork 51
feat(examples): add browser-based agent example #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
cagataycali
left a comment
There was a problem hiding this 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_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! 🦆
examples/browser-agent/src/index.ts
Outdated
| // 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({ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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?
…le updates, improve streaming UI for tool calls, and simplify build configuration.
|
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: |
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)