How praaihub/mai-builder-labs-supplement works
Ami is an Amazon customer-support agent, presented as two independently runnable stages: Stage 1 provides the core agent, while Stage 2 adds authenticated, per-customer access, policy checks, and long-term memory. The main workflow is a customer request entering through chat, passing through planning and model/tool calls, then returning a support answer grounded in retrieved guidance and order data. Evaluation and feedback scripts are omitted because they support development rather than runtime. Some subsystem wiring is documented but not shown in sampled source, so uncertain links are left out.
Main entry points: main.py Terminal chat · llm.py Model gateway · tools.py Support tools · web.py Browser chat
Components 23
Chat entrypoints
- Browser chat
stage2/web.py - Terminal chat
stage2/main.py - Stage 1 chat
stage1/main.py
Identity and policy
- Auth and sessions
stage2/ami/auth.py - Input/output policy
stage2/ami/policy.py
Agent runtime
- ReAct planner
stage2/ami/planner.py - Plan-execute planner
stage2/ami/plan_execute.py - Baseline agent
stage2/ami/agent.py - Agent profile
stage2/ami/agent_profile.py - Conversation memory
stage2/ami/memory.py - Model gateway
stage2/ami/llm.py - Stage 1 planner
stage1/ami/planner.py
Support capabilities
- Support tools
stage2/ami/tools.py - Order store
stage2/ami/store.py - Knowledge retrieval
stage2/ami/knowledge.py - Local embedder
stage2/ami/embedder.py - Human support desk
stage2/ami/desk.py - Stage 1 tools
stage1/ami/tools.py - Stage 1 order store
stage1/ami/store.py
Tracing and cost
- Trace logging
stage2/ami/observe.py - Call pricing
stage2/ami/pricing.py
Other components
- Customer
- LLM proxy
Connections 21
- Customer → Browser chat: sends chat
- Customer → Terminal chat: sends chat
- Browser chat → Auth and sessions: checks session
- Terminal chat → Auth and sessions: authenticates key
- Terminal chat → Input/output policy: checks input/output
- Terminal chat → ReAct planner: runs turn
- Terminal chat → Plan-execute planner: runs selected plan
- Terminal chat → Baseline agent: runs baseline
- Terminal chat → Conversation memory: reads and remembers
- ReAct planner → Model gateway: requests completion
- Plan-execute planner → Model gateway: requests completion
- Baseline agent → Model gateway: requests completion
- Model gateway → LLM proxy: sends model request
- Terminal chat → Agent profile: loads prompt
- Support tools → Order store: reads and changes orders
- Support tools → Human support desk: creates support ticket
- Knowledge retrieval → Local embedder: embeds queries
- Model gateway → Trace logging: logs calls
- Model gateway → Call pricing: prices usage
- Stage 1 chat → Stage 1 planner: runs turn
- Stage 1 tools → Stage 1 order store: reads and changes orders