Skip to content
Nguyen Le edited this page Nov 15, 2026 · 20 revisions

Agents

Before you hit "sell", five agents check whether you are reacting to the market or to your own fear, and show you the proof.

Each agent is its own Amazon Bedrock AgentCore runtime built with the Strands Agents SDK. A model decides when to call the agent's tool, but the tool produces every figure, and an agent returns what its tool returned, never the model's text. If the model skips its tool, the agent still calls it.

Routing

The FastAPI gateway only signs and forwards. Every call goes to the Orchestrator, which sends it to the agent that owns it.

flowchart TD
  GW["FastAPI gateway"] -->|every call| O["Orchestrator"]

  O -->|"trade check · trade question in chat"| P["Trade pipeline"]
  O -->|"investor and account actions"| IN
  O -->|"sentiment questions"| CF
  O -->|"scenario analysis · knowledge answers"| XP
  O -->|"preload on Refresh"| MK
  O -->|"preload on Refresh"| CF

  P --> IN & MK
  IN["Intake"] --> CF["Classifier"]
  MK["Market"] --> CF
  CF --> XP["Explainer"]
Loading
Request Goes to
trade_check, a trade question in chat Intake and Market in parallel, then Classifier, then Explainer
set_investor, get_investor, clear_profile, accounts, delete_account, approve, reject, account creation in chat Intake
sentiment_ask Classifier
analysis, knowledge answers (FAQ, macro) Explainer
preload Market, then Classifier
Chat A model reads the message, then routes as above

The five agents

Agent Role Tools
Orchestrator Single entry point. Routes by action, runs the pipeline, passes evidence IDs between agents, records the execution trace. Does no calculation. Bedrock (chat routing, tool calling), the four agents
Intake Turns who is asking into a low, mid or high risk persona and applies the account rules (an RRSP lowers the risk one step). Saves the selected investor to S3. Persona presets, S3 investor record, Bedrock for free-text descriptions
Market Compares the two market snapshots and reports what changed: price move, volume, rebound, how many tickers fell together, the ticker's typical daily move. Lambda over versioned S3 data
Classifier Labels the move market-driven, company-driven or hype, with scores, a sentiment label and the verdict. Adjusts for the risk band and for growth-style holdings. Deterministic Lambda calculation; headline sentiment pre-scored by Bedrock
Explainer Writes the short pop-up warning and the full chat detail, citing only the Classifier's evidence IDs. Bedrock Converse API with validation (no digits, no predictions, no advice, cited IDs must exist), Persona Fit

Runtime names: portfolioguard_{orchestrator,intake,market,classifier,explainer}_workshop.

Preloading

Answers that depend on nothing else are computed ahead of time:

  • On Refresh market: Market compares every tracked ticker in parallel; the Classifier then scores buy and sell for the low, mid and high risk bands (66 results for 11 tickers). The verdict depends on the band, not on who is asking, so it can be computed before anyone clicks.
  • On a click: Market runs in parallel with Intake, and cached answers are marked preloaded answer in the trace.
  • Safety: a cached result is the Lambda's own output for the exact same inputs, kept for 10 minutes. It is never a guess.

A preloaded trade check takes about 11 s, against about 20 s cold. Most of the remainder is the two model calls.

Seeing the trace

Each step in the chat's How I got this and in the pop-up's AWS agents that ran shows the AgentCore runtime that executed it.

Why separate runtimes

Delegation is inspectable per agent, each has its own least-privilege role, and a failure or redeploy is contained to one agent.

The system reads the market, not you. It helps you pause; you decide.

Clone this wiki locally