Create a Strands agent with browser capabilities. Returns: Configured Strands Agent instance
()
| 46 | |
| 47 | |
| 48 | def create_agent(): |
| 49 | """ |
| 50 | Create a Strands agent with browser capabilities. |
| 51 | |
| 52 | Returns: |
| 53 | Configured Strands Agent instance |
| 54 | """ |
| 55 | # Conversation manager to handle token limits |
| 56 | conversation_manager = SlidingWindowConversationManager( |
| 57 | window_size=25, |
| 58 | per_turn=True |
| 59 | ) |
| 60 | |
| 61 | return Agent( |
| 62 | model=MODEL_ID, |
| 63 | tools=[browser_tool.browser], |
| 64 | conversation_manager=conversation_manager, |
| 65 | system_prompt="""You are an intelligent research assistant with web browsing capabilities. |
| 66 | |
| 67 | Your capabilities: |
| 68 | - Navigate to websites and extract information |
| 69 | - Analyze financial data from stock market websites |
| 70 | - Research topics by visiting multiple sources |
| 71 | - Extract structured data from web pages |
| 72 | |
| 73 | Guidelines: |
| 74 | 1. Use the browser tool efficiently - aim for 2-3 interactions per task |
| 75 | 2. Extract specific data points with actual numbers |
| 76 | 3. Summarize findings clearly with sources |
| 77 | 4. Handle errors gracefully and try alternative approaches |
| 78 | |
| 79 | For financial analysis, focus on: |
| 80 | - Current prices and trends |
| 81 | - Key metrics (P/E, Market Cap, Volume) |
| 82 | - Recent news and market sentiment |
| 83 | - Analyst recommendations""", |
| 84 | ) |
| 85 | |
| 86 | |
| 87 | @app.entrypoint |