Skip to content

feat(market-trends-agent): add demo UI, LangGraph checkpointer/store,…#1423

Open
deepaxs wants to merge 1 commit intoawslabs:mainfrom
deepaxs:feature/market-trends-agent-enhancements
Open

feat(market-trends-agent): add demo UI, LangGraph checkpointer/store,…#1423
deepaxs wants to merge 1 commit intoawslabs:mainfrom
deepaxs:feature/market-trends-agent-enhancements

Conversation

@deepaxs
Copy link
Copy Markdown

@deepaxs deepaxs commented Apr 30, 2026

Amazon Bedrock AgentCore Samples Pull Request

Important

  1. We strictly follow a issue-first approach, please first open an issue relating to this Pull Request.
  2. Once this Pull Request is ready for review please attach review ready label to it. Only PRs with review ready will be reviewed.

Issue number:
Extend the Market Trend AI Agent use cases with a new UI and memory integration #1422

Concise description of the PR

Changes to 02-use-cases/market-trends-agent, adding a React demo UI,
LangGraph AgentCore Memory checkpointer/store integration, FastAPI backend
proxy, and multi-region support. These changes turn the existing sample into
a full-stack interactive demo with persistent broker profiles across sessions.

Changes to the current market trend AI agent because as part of the customer demo, and webinars needed UI for user experience and persistent memory experience.

User experience

Before: The market-trends-agent could only be tested via CLI scripts (test_agent.py, test_broker_card.py). No visual interface, no conversation persistence across invocations, and hardcoded to us-east-1 only.

After: Users can launch a React chat UI (uv run python run_demo_ui.py) with pre-built broker profiles, markdown-rendered responses, and session management. The agent persists conversations within a session (checkpointer) and remembers broker preferences across sessions (store). Deployable to any region via --region flag.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • [ x] I have reviewed the contributing guidelines
  • Add your name to CONTRIBUTORS.md
  • [ x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you uploading a dataset?
  • [ x] Have you documented Introduction, Architecture Diagram, Prerequisites, Usage, Sample Prompts, and Clean Up steps in your example README?
  • [ x] I agree to resolve any issues created for this example in the future.
  • [x ] I have performed a self-review of this change
  • [x ] Changes have been tested
  • [x ] Changes are documented

Market Trends Agent: Interactive UI + LangGraph Checkpointer/Store Integration

Summary

Extends the market-trends-agent use case with LangGraph AgentCore Memory checkpointer and store integration, a React chat UI, and a FastAPI backend proxy — creating a full-stack demo of personalized financial intelligence with persistent broker profiles.


Changes by Area

Reviewers: each section below is independent. Review in order or jump to the area most relevant to you.


1. Agent Architecture — LangGraph Checkpointer + Store (market_trends_agent.py)

  • Added AgentCoreMemorySaver (checkpointer) to persist full conversation state across invocations via thread_id
  • Added AgentCoreMemoryStore for long-term cross-session preference extraction
  • Graph now compiled with both: graph_builder.compile(checkpointer=checkpointer, store=store)
  • Simplified chatbot node — removed manual conversation saving logic and message filtering (checkpointer handles this now)
  • Added RunnableConfig with thread_id and actor_id passed at invocation time
  • Memory ID retrieved from SSM Parameter Store at startup (no change to retrieval logic)
  • System prompt updates:
    • Added checkpointer-awareness paragraph: instructs agent that conversation history is automatic, no need to re-identify brokers within a session
    • Updated tool signatures to show actor_id parameter (e.g., get_broker_financial_profile(actor_id))
    • Fixed duplicate step numbering (original had two step 3s and two step 4s)
    • Renamed "Memory & Financial Profile Management" → "Long-Term Memory (persists across sessions)"
    • All original behavioral guidance, workflow steps, and memory strategy explanations preserved

2. FastAPI Backend Proxy (api_server.py) — NEW FILE

  • POST /api/chat — invokes deployed agent via bedrock-agentcore boto3 client, passes session ID for memory continuity
  • GET /api/health — reports agent deployment status (checks .agent_arn file)
  • Handles AgentCore double-serialized JSON responses (unwraps escaped newlines)
  • Extended boto3 read timeout (300s) for browser tool + LLM latency
  • CORS configured for Vite dev server (localhost:3000)

3. React Chat Frontend (frontend/) — NEW DIRECTORY

  • React 18 + Vite chat interface with dark financial dashboard theme
  • Three pre-built broker profiles (Growth Investor, Conservative Advisor, Emerging Markets) for one-click demo setup
  • Markdown rendering for agent responses (react-markdown + remark-gfm with GFM table support)
  • Session management with auto-generated IDs and "New Session" reset
  • Agent health status indicator (connected / not deployed / offline)
  • Suggested prompts for stock data, news search, memory recall, market briefings
  • Responsive layout with collapsible sidebar
  • Vite proxy config routes /api calls to backend on port 8001

4. Launcher (run_demo_ui.py) — NEW FILE

  • Single command (uv run python run_demo_ui.py) starts both backend (uvicorn:8001) and frontend (Vite:3000)
  • Auto-installs frontend npm dependencies if missing
  • Graceful shutdown of both processes on Ctrl+C

5. Deployment Updates (deploy.py)

  • Added IAM permissions for AgentCore Memory checkpointer operations: GetCheckpoint, PutCheckpoint, ListCheckpoints
  • Added IAM permissions for memory record operations: RetrieveMemoryRecords, CreateMemoryRecord, DeleteMemoryRecord, UpdateMemoryRecord
  • No other deployment logic changes

6. README.md Updates

  • Added Demo UI to overview, features section, and info table
  • Added Quick Start steps for frontend install (npm install) and run_demo_ui.py launcher
  • Added "Try It Out" walkthrough with sample broker profile flow
  • Rewrote architecture diagram: added Demo UI layer (React + FastAPI) and separated Agent Tools tier
  • Changed LLM reference from Claude Sonnet 4 → Claude Haiku 4.5
  • Added new sections: Project Structure, Stop the Demo UI, Clean Up Frontend
  • Added troubleshooting entries for port conflicts and frontend issues
  • Added API Server security notes (input validation, sanitized errors)
  • Softened Docker prerequisite (CodeBuild handles container builds)

7. Dependencies (pyproject.toml, requirements.txt)

  • Added fastapi, uvicorn[standard] for API server
  • Added langgraph-checkpoint-aws for AgentCore checkpointer integration
  • Frontend: react ^18.3.1, react-dom, react-markdown ^9.0.1, remark-gfm ^4.0.1, vite ^6.0.0

8. Tool Fixes (tools/memory_tools.py, tools/browser_tool.py)

  • Removed personal AWS_PROFILE=burner from error message — replaced with generic python deploy.py --region us-east-1
  • Tightened extract_actor_id regex to stop at delimiters ("and", "from", "at") instead of capturing entire line
  • Added three new intro patterns: "I am", "Name is", "Hi/Hello/Hey, I'm"
  • list_conversation_history now tries multiple actor IDs (session-based → override → default) instead of one
  • browser_tool.py: cosmetic blank line only

What Did NOT Change

  • broker_card_tools.py, tools/__init__.py — zero modifications
  • Core agent pattern — same LangGraph StateGraph (chatbot + ToolNode + conditional edges)
  • Memory creation/retrieval — same SSM-based approach from deploy.py
  • Cleanup scriptcleanup.py unchanged

How to Test

# 1. Install Python dependencies
cd 02-use-cases/market-trends-agent
uv sync

# 2. Deploy agent + memory to AgentCore
uv run python deploy.py --region us-east-1

# 3. Launch the full demo UI
uv run python run_demo_ui.py
# Backend: http://localhost:8001  |  Frontend: http://localhost:3000

# 4. Or test agent directly (no UI)
uv run python test_agent.py

Known Limitations

  • Browser tool requires AgentCore Browser session access (not available in all regions)
  • News source scraping may hit paywalls or rate limits — agent auto-falls back to reliable sources

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@github-actions github-actions Bot added the 02-use-cases 02-use-cases label Apr 30, 2026
@deepaxs
Copy link
Copy Markdown
Author

deepaxs commented Apr 30, 2026

Ready for review. I'm unable to add the review ready label

… multi-region support

- Add AgentCoreMemorySaver (checkpointer) and AgentCoreMemoryStore for dual-layer memory
- Add React chat UI with pre-built broker profiles and markdown rendering
- Add FastAPI backend proxy bridging UI to deployed AgentCore agent
- Add run_demo_ui.py launcher for single-command startup
- Replace hardcoded us-east-1 with os.getenv for multi-region deployability
- Add IAM permissions for checkpointer and memory record operations
- Fix extract_actor_id regex and add new intro patterns
- Remove personal AWS_PROFILE reference from error message
- Sync requirements.txt with pyproject.toml (fastapi, uvicorn, langgraph-checkpoint-aws)
- Update README with UI setup, architecture diagram, and troubleshooting
@deepaxs deepaxs force-pushed the feature/market-trends-agent-enhancements branch from aa6b03d to bc61834 Compare May 5, 2026 19:25
@deepaxs
Copy link
Copy Markdown
Author

deepaxs commented May 5, 2026

I have rebased onto latest main and resolved conflicts

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

Labels

02-use-cases 02-use-cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant