Agentic Architecture EAG Session6 Assignment
БесплатноНе проверенAgentic AI Chrome backend for multi-step stock research — powered by Gemini, FastAPI, and MCP tools with verified prompt reasoning and cognitive 4-layer archite
Описание
Agentic AI Chrome backend for multi-step stock research — powered by Gemini, FastAPI, and MCP tools with verified prompt reasoning and cognitive 4-layer architecture.
README
A lightweight Agentic AI backend built using FastAPI, Gemini LLM, and uv package manager. It powers a Chrome Extension that can perform multi-step, reasoning-based stock research, combining news, prices, and analysis through an agentic feedback loop.
⚡ Overview
This backend runs an agentic workflow for stock tickers (AAPL, TSLA, NVDA, etc.). Given a query like:
“Find the latest news about AAPL and link it with its price changes in the last 30 days.”
The system doesn’t just summarize — it acts like an autonomous financial analyst:
- Collects the stock’s recent price trend
- Fetches and links recent news headlines from Yahoo Finance
- Summarizes those headlines one by one
- Links them to the stock’s movement
- Returns a final reasoning-based analysis
🎬 Demo Video
🧩 Project Structure
The architecture follows the classic Agentic 4-layer design:
| Layer | File | Description |
|---|---|---|
| Perception | app.py |
FastAPI orchestrator — receives user query, preferences, and triggers flow. |
| Memory | memory.py |
Caches user sessions, turns, and preferences. |
| Decision | decision.py |
Planner using Gemini — produces FUNCTION_CALL or FINAL_ANSWER. |
| Action | action.py |
MCP tool layer — runs stock/news/summarization tools. |
| Schemas | models.py |
Pydantic I/O models defining all data contracts. |
| Prompt Eval | prompt_eval.py |
Runs Gemini-based evaluation on the system prompt. |
🧱 Cognitive Architecture (4 Layers)
👁️ Perceive → 🧠 Remember → 🧭 Decide → 🎯 Act
| Layer | Cognitive Role | Implementation | Key Behavior |
|---|---|---|---|
| 🧩 Perception | Understands user intent + query | app.py |
Parses JSON input, merges preferences, initiates loop |
| 💭 Memory | Stores past reasoning turns | memory.py |
Maintains transcript + prefs per session |
| 🧠 Decision | Plans next step or final answer | decision.py |
Uses Gemini with structured “FUNCTION_CALL / FINAL_ANSWER” outputs |
| ⚙️ Action | Executes real-world functions | action.py |
Runs MCP tools for stock, news, summarization |
⚙️ Setup (via uv)
1️⃣ Install dependencies
uv sync
2️⃣ Add your Gemini API key
Create a .env file:
GEMINI_API_KEY=your_api_key_here
3️⃣ Verify the system prompt
Run the Gemini verifier to ensure compliance:
uv run prompt-verify
Generates prompt_evaluation.json.
4️⃣ Start servers
uv run agent-server
# or start MCP tools for other agents
uv run mcp-server
🧩 Installing the Chrome Extension
Once your backend (agent-server) is running, you can side-load the Chrome Extension to interact with it locally.
Steps
Open Chrome Go to
chrome://extensions/Enable Developer Mode Toggle Developer mode at the top right.
Click “Load unpacked” Select the folder containing your extension files (must include
manifest.json,popup.html,background.js, etc.).The extension should appear in your toolbar — click the icon to open it.
The extension’s popup sends your queries and preferences to
http://localhost:8080/agent.
🧭 Reference: If you face issues loading it manually, check this helpful StackOverflow discussion: 👉 Install Chrome extension from outside the Chrome Web Store
🧠 Agent Flow (Step-by-Step)
User Input: Chrome extension sends query + preferences (likes, location, interests).
Perception:
app.pymerges prefs + query and creates a new session.Decision: Gemini reads context and outputs one line:
FUNCTION_CALL: ticker_info|ticker=AAPL|days=30FUNCTION_CALL: summarize_news|headline="Apple delays iPhone 17"FINAL_ANSWER: AAPL remained steady amid mixed news sentiment.
Action: Executes tools and stores results.
Memory: Saves all turns and feedback for next iteration.
Loop: Repeats until FINAL_ANSWER is produced or limits reached.
🧰 MCP Tool Layer
action.py now doubles as an MCP server, exposing tools for both internal and external agent access.
| Tool | Description |
|---|---|
ticker_info(ticker, days) |
Fetches price data using yfinance |
news_vs_price(ticker, days) |
Correlates latest news headlines with price change |
summarize_news(headline) |
Uses Gemini to summarize a news headline concisely |
Run independently:
uv run mcp-server
🧾 Sample Output
Input
Find the news about AAPL in the last 30 days and link it with daily stock price changes.
Output
# Agent Transcript
**User:** Find the news about AAPL in the last 30 days and link it with daily stock price changes.
**Tool `ticker_info` Result:**
AAPL Price Info (last 30d):
- Latest close: 255.46
- Change over 30d: -1.12%
- High: 263.10, Low: 249.32
**Tool `news_vs_price` Result:**
# News vs Price — AAPL (last 30d)
2025-09-26 | 255.46 | -1.00% | Apple (AAPL) Stock: UBS Reiterates Neutral...
2025-09-27 | 255.46 | -1.00% | AI Semiconductor Stock Will Join Nvidia, Apple...
**Tool `summarize_news` Result:**
Apple (AAPL) Stock... → UBS expects weaker iPhone demand, maintaining neutral outlook.
**Assistant:**
AAPL saw a minor decline around Sep 26–27. The UBS Neutral rating likely caused short-term selling, while positive AI-related headlines offset part of the sentiment. Overall, market confidence remained stable.
🧩 Key Features
| Feature | Description |
|---|---|
| Gemini-driven reasoning | Planner follows a deterministic protocol using FUNCTION_CALL: and FINAL_ANSWER: lines. |
| Multi-step loop | Planner–tool–planner loop with caps to avoid runaway calls. |
| Tool abstraction | Each tool is independent and validated through Pydantic schemas. |
| Transcript memory | Every agent turn is stored in memory for feedback and re-prompting. |
| Readable output | Markdown transcript built for direct display in Chrome extension. |
| Resilient LLM calls | Handles overload errors (503s), truncates long prompts, retries gracefully. |
🏗️ File Workflow
┌───────────────┐
│ Chrome Popup │
│ (user query) │
└──────┬────────┘
│ POST /agent
▼
┌───────────────┐
│ app.py │ ← Orchestrator (Perception)
│ • Receives request
│ • Loads prefs
│ • Iterates planner loop
└──────┬────────┘
▼
┌───────────────┐
│ decision.py │ ← Decision Layer
│ • LLM Planner
│ • Produces FUNCTION_CALL or FINAL_ANSWER
└──────┬────────┘
▼
┌───────────────┐
│ action.py │ ← Action Layer
│ • Runs tools
│ • Summarize / Fetch news / Price
└──────┬────────┘
▼
┌───────────────┐
│ memory.py │ ← Memory Layer
│ • Stores turns + prefs
└──────┬────────┘
▼
📤 Returns → Markdown transcript (displayed in Chrome extension)
🧠 Logging
All server-side operations use structured logging instead of prints:
- Logs LLM calls, tool executions, and outputs (truncated)
- Helps trace reasoning chain
- Simplifies debugging and grading
Example:
2025-10-29 21:45:11 INFO Calling tool: news_vs_price args={'ticker': 'AAPL', 'days': 30}
2025-10-29 21:45:17 INFO Planner step decided: summarize_news
🧰 Tech Stack
| Component | Technology |
|---|---|
| Language | Python 3.13+ |
| Environment | uv package manager |
| Framework | FastAPI |
| LLM | Gemini 2.0 Flash |
| Data | yfinance, pandas |
| Validation | Pydantic |
| Orchestration | MCP tools + Agent loop |
| Infra | Local backend / Chrome extension bridge |
🧩 Next Steps (Planned)
- Integrate with Chrome extension popup to pass ticker + prefs.
- Allow multiple tickers comparison.
- Store transcript history in a small SQLite or DynamoDB table.
- Add continuous monitoring mode (price alert triggers).
🏁 Summary
The Agentic Ticker Research backend demonstrates a verified, modular Agentic Cognitive Architecture with full Gemini prompt validation, MCP tool exposure, and Pydantic-typed cognitive layers.
It’s not just a stock summarizer — it’s a self-checking, multi-step reasoning agent that meets the standards of explicit reasoning, structured output, and fallback robustness.
from github.com/sushant097/Agentic-Architecture-EAG-Session6-Assignment
Установка Agentic Architecture EAG Session6 Assignment
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/sushant097/Agentic-Architecture-EAG-Session6-AssignmentFAQ
Agentic Architecture EAG Session6 Assignment MCP бесплатный?
Да, Agentic Architecture EAG Session6 Assignment MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Agentic Architecture EAG Session6 Assignment?
Нет, Agentic Architecture EAG Session6 Assignment работает без API-ключей и переменных окружения.
Agentic Architecture EAG Session6 Assignment — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Agentic Architecture EAG Session6 Assignment в Claude Desktop, Claude Code или Cursor?
Открой Agentic Architecture EAG Session6 Assignment на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Playwright
Browser automation, scraping, screenshots
автор: MicrosoftPuppeteer
Browser automation and web scraping.
автор: modelcontextprotocolopentabs-dev/opentabs
Plugin-based MCP server + Chrome extension that gives AI agents access to web applications through the user's authenticated browser session. 100+ plugins with a
автор: opentabs-devrobhunter/agentdeals
1,500+ developer infrastructure deals, free tiers, and startup programs across 54 categories. Search deals, compare vendors, plan stacks, and track pricing chan
автор: robhunterCompare Agentic Architecture EAG Session6 Assignment with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории browse
