Finance Advisor Agent: Production Deployment Story

Inspiration

The financial advisor multiagent system started as an educational Jupyter notebook demonstrating sophisticated AI orchestration patterns with the Strands Agents framework. While powerful for learning and prototyping, we recognized a critical gap: the system needed to scale beyond local development and serve real users through production infrastructure.

Amazon Bedrock AgentCore Runtime emerged as the perfect deployment target—offering serverless agent hosting, automatic scaling, built-in observability, and seamless AWS integration. The challenge was clear: transform our notebook-based system into a production-ready AgentCore application while preserving all functionality, maintaining our sophisticated multi-agent architecture, and keeping the educational value intact.

We were inspired by the potential to demonstrate how complex AI systems can transition from research prototypes to production deployments with minimal code changes, showing developers a clear path from experimentation to real-world applications.

What it does

The Finance Advisor Agent is a production-ready multi-agent AI system deployed on Amazon Bedrock AgentCore that provides comprehensive financial analysis through four specialized AI agents working in orchestrated harmony:

Market Intelligence Agent conducts web-based research using DuckDuckGo Search to gather current news, SEC filings, analyst commentary, and market sentiment for any stock ticker. It provides comprehensive market context with full source attribution.

Strategy Architect Agent develops a minimum of 5 distinct trading strategies tailored to the user's risk tolerance (Conservative/Moderate/Aggressive) and investment horizon (Short/Medium/Long-term). Each strategy includes detailed rationale, entry/exit conditions, and risk assessments.

Execution Planner Agent converts trading strategies into actionable execution plans with specific order types, position sizing guidance, timing recommendations, and comprehensive risk controls including stop-loss levels and hedging strategies.

Risk Assessor Agent evaluates the total risk profile across all proposed strategies, assesses alignment with user preferences, identifies potential misalignments, and provides actionable risk mitigation recommendations.

The system accepts natural language queries like "Analyze AAPL stock for a moderate risk investor with a long-term horizon" and returns structured, comprehensive financial analysis through AgentCore's HTTP API. All outputs include educational disclaimers emphasizing that this is for learning purposes only, not licensed financial advice.

How we built it

We built the Finance Advisor Agent using a five-phase approach that transformed our Jupyter notebook into a production-ready AgentCore application:

Phase 1: Foundation Architecture Started with the existing financial_advisor_multiagent.py module containing our FinancialAdvisorOrchestrator class and four specialist agents built with Strands Agents SDK. The system already had sophisticated error handling with multi-parameter format attempts for model compatibility, web search integration with DuckDuckGo, and conservative 2000-token limits.

Phase 2: AgentCore Wrapper Layer Created financial_advisor_agentcore.py using the SDK Integration approach with BedrockAgentCoreApp. This wrapper provides the HTTP server and deployment tools while preserving all existing agent logic:

from bedrock_agentcore.runtime import BedrockAgentCoreApp
from financial_advisor_multiagent import FinancialAdvisorOrchestrator

app = BedrockAgentCoreApp()
advisor = FinancialAdvisorOrchestrator()

@app.entrypoint
def invoke(payload):
    user_query = process_agentcore_payload(payload)
    response = advisor.analyze(user_query)
    return format_agentcore_response(response)

Phase 3: Payload Processing & Security Implemented payload transformation functions that extract and validate the prompt field from AgentCore's JSON format. Added security validations including input length limits (5000 characters), content filtering for injection attempts, and helpful error messages guiding users on proper request format.

Phase 4: Production Error Handling Enhanced error handling to return structured JSON responses instead of exceptions. Implemented specific handlers for 10+ exception types including ValueError (payload validation), RatelimitException (web search), TypeError (agent parameters), MemoryError (token limits), ConnectionError, TimeoutError, and PermissionError. Each error response includes error type, timestamp, metadata, and recovery suggestions.

Phase 5: Testing & Deployment Tested locally using AgentCore's built-in server on localhost:8080, validating all agent workflows, web search functionality, and error scenarios. Deployed to AWS using AgentCore CLI (agentcore configureagentcore launch), which automatically created the necessary AWS infrastructure including Lambda functions, API Gateway, and IAM roles.

Technology Stack:

  • Strands Agents SDK for multi-agent orchestration
  • Amazon Bedrock Claude 3.5 Sonnet for AI models
  • DuckDuckGo Search for market research
  • BedrockAgentCoreApp for runtime integration
  • Python 3.12+ with comprehensive dependency management

Challenges we ran into

Preserving Complex Error Handling: The existing system had sophisticated error handling with multiple fallback mechanisms—multi-parameter format attempts for different model providers, web search rate limiting, and graceful degradation. We needed to preserve all of this while adding AgentCore compatibility. We solved this by wrapping the orchestrator invocation with logging but not modifying internal error handling. The existing mechanisms continue working while we add observability through AgentCore's logger.

Payload Format Transformation: AgentCore expects a specific payload format with a prompt field, while our system needed flexible input parsing to extract ticker symbols, risk tolerance, and investment horizons. We created a processing layer that validates AgentCore format while providing helpful error messages guiding users on proper request format, including examples like "Analyze AAPL for moderate risk investor with long-term horizon."

Security in Production: Moving from notebook to production required security validations that weren't necessary in development. We added input length validation (5000 character limit), content filtering to detect potential injection attempts (checking for patterns like <script, eval(, __import__), security event logging for monitoring, and structured error responses that don't leak system details.

Dependency Management: AgentCore runtime needed all dependencies available with correct package names. We discovered that the package is strands-agents-tools, not strands-tools, which caused initial deployment failures. We created a comprehensive requirements.txt with all dependencies including bedrock-agentcore>=1.0.0, strands-agents>=1.10.0, strands-agents-tools>=0.2.9, and duckduckgo-search>=6.3.4.

Testing in Containerized Environment: Web search and external API calls behave differently in containers versus local development. DuckDuckGo rate limiting became more apparent in the containerized environment. We solved this through comprehensive local testing using AgentCore's built-in server, validating all agent workflows, web search functionality, and error handling scenarios before AWS deployment.

Accomplishments that we're proud of

Zero Changes to Core Agent Logic: We successfully deployed a complex multi-agent system to production without modifying any of the existing agent orchestration, tool integration, or business logic. The FinancialAdvisorOrchestrator and all four specialist agents work identically in production as they did in the notebook.

Comprehensive Error Handling: Implemented production-grade error handling with 10+ specific exception types, each returning structured JSON responses with error type, timestamp, metadata, and recovery suggestions. The system gracefully handles everything from payload validation errors to web search rate limits to agent parameter mismatches.

Security-First Approach: Built security validations from day one including input length limits, content filtering for injection attempts, security event logging, and structured error responses. The system is production-ready with proper safeguards against common attack vectors.

Minimal Code Transformation: The entire AgentCore integration required only a single wrapper file (financial_advisor_agentcore.py) that's under 500 lines including extensive comments and documentation. This demonstrates how the SDK Integration approach enables rapid production deployment.

Complete Documentation: Created comprehensive specifications with 8 requirements, 40+ acceptance criteria, detailed design documentation, and a complete implementation checklist. The project serves as a reference implementation for deploying multi-agent systems to AgentCore.

Educational Value Preserved: Maintained all educational disclaimers, responsible AI practices, and source attribution throughout the production deployment. The system continues to emphasize its educational purpose and encourages users to consult qualified financial advisors.

What we learned

Runtime Adaptation Patterns: The SDK Integration approach with BedrockAgentCoreApp proved ideal for complex systems. We gained automatic HTTP server setup and deployment tools while making minimal changes to existing logic. This pattern is perfect for systems with sophisticated internal orchestration that need production deployment.

Error Handling Philosophy: AgentCore requires structured error responses rather than exceptions. We learned to catch specific exception types, return JSON error objects with metadata for debugging, preserve existing fallback mechanisms while adding observability, and log security events for monitoring suspicious activity.

Token Management in Production: Our conservative 2000-token limits became even more critical in production. They prevent resource exhaustion in serverless environments, maintain response quality while controlling costs, enable predictable latency for user experience, and work seamlessly with AgentCore's ARM64 container runtime.

Separation of Concerns: The wrapper pattern cleanly separated AgentCore runtime concerns (HTTP handling, payload transformation) from business logic (agent orchestration, financial analysis). This architectural decision made the system maintainable and testable.

Observability from Day One: Comprehensive logging proved essential for production systems. We log request/response characteristics for debugging, error categorization for monitoring, security events for compliance, and performance metrics for optimization. AgentCore's built-in logger integration made this straightforward.

Hierarchical Orchestration Scales: The "Agents as Tools" pattern works beautifully in production. Our orchestrator managing four specialist agents scales horizontally, handles concurrent requests, and maintains clean separation of concerns between different analytical domains.

What's next for Finance Advisor Agent

AgentCore Memory Integration: Implement persistent conversation history across sessions using AgentCore Memory service. This will enable the system to remember user preferences, previous analyses, and build context over multiple interactions for more personalized financial guidance.

AgentCore Browser Integration: Replace DuckDuckGo search with AgentCore Browser for enhanced web research capabilities. This will provide faster, more reliable market data gathering with better rate limiting and more comprehensive content extraction from financial websites.

AgentCore Gateway for Real-Time Data: Deploy AgentCore Gateway to transform existing financial APIs (market data providers, SEC EDGAR, earnings calendars) into agent tools. This will enable real-time market data integration beyond web search capabilities.

Multi-Region Deployment: Expand deployment to multiple AWS regions for global availability and regional failover. This will reduce latency for international users and provide high availability through geographic redundancy.

Advanced Monitoring & Observability: Implement CloudWatch dashboards with custom metrics for agent performance, token usage, error rates, and user interaction patterns. Set up alerting for anomalies and automated scaling based on demand.

Enhanced Risk Assessment: Integrate portfolio analysis capabilities allowing users to evaluate how new strategies fit with existing holdings. This will provide more comprehensive risk assessment considering concentration, correlation, and diversification.

Strategy Backtesting: Add historical performance simulation for proposed strategies using market data APIs. This will help users understand how strategies would have performed in different market conditions while maintaining educational disclaimers.

Multi-Language Support: Expand the system to support financial analysis in multiple languages, making educational financial guidance accessible to a global audience while maintaining cultural and regulatory context awareness.


Built with: Strands Agents SDK, Amazon Bedrock AgentCore, Claude 3.5 Sonnet
Purpose: Educational demonstration of multi-agent system deployment
License: Educational Use Only

Built With

Share this project:

Updates