{"id":30892411,"url":"https://github.com/hoangsonww/agentic-ai-pipeline","last_synced_at":"2025-09-08T19:45:35.761Z","repository":{"id":306803591,"uuid":"1027259947","full_name":"hoangsonww/Agentic-AI-Pipeline","owner":"hoangsonww","description":"🦾 A production‑ready research outreach AI agent that plans, discovers, reasons, uses tools, auto‑builds cited briefings, and drafts tailored emails with tool‑chaining, memory, tests, and turnkey Docker, AWS, Ansible \u0026 Terraform deploys. Bonus: Agentic RAG system (FAISS + Google CSE) with multistep planning, self-critique, and autonomous agents.","archived":false,"fork":false,"pushed_at":"2025-08-15T08:53:44.000Z","size":779,"stargazers_count":22,"open_issues_count":0,"forks_count":19,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-08-15T10:28:30.599Z","etag":null,"topics":["agent","agentic-ai","anthropic","aws","chromadb","docker","duckduckgo","fastapi","langchain","langgraph","makefile","openai","pydantic","pytest","python","ruff","sql","sqlalchemy","sqlite","uvicorn"],"latest_commit_sha":null,"homepage":"https://hoangsonww.github.io/Agentic-AI-Pipeline","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hoangsonww.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-27T16:46:06.000Z","updated_at":"2025-08-15T09:53:34.000Z","dependencies_parsed_at":"2025-07-27T19:20:12.990Z","dependency_job_id":"9f11cabc-429e-44bb-a487-a976f6056dbb","html_url":"https://github.com/hoangsonww/Agentic-AI-Pipeline","commit_stats":null,"previous_names":["hoangsonww/agentic-ai-pipeline"],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/hoangsonww/Agentic-AI-Pipeline","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FAgentic-AI-Pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FAgentic-AI-Pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FAgentic-AI-Pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FAgentic-AI-Pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoangsonww","download_url":"https://codeload.github.com/hoangsonww/Agentic-AI-Pipeline/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoangsonww%2FAgentic-AI-Pipeline/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231433,"owners_count":25245585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","agentic-ai","anthropic","aws","chromadb","docker","duckduckgo","fastapi","langchain","langgraph","makefile","openai","pydantic","pytest","python","ruff","sql","sqlalchemy","sqlite","uvicorn"],"created_at":"2025-09-08T19:45:32.047Z","updated_at":"2025-09-08T19:45:35.747Z","avatar_url":"https://github.com/hoangsonww.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Agentic Multi‑Stage Bot - A Research \u0026 Outreach Agent 🤖\n\n[![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python\u0026logoColor=white)](#)\n[![FastAPI](https://img.shields.io/badge/FastAPI-API%20Server-009688?logo=fastapi\u0026logoColor=white)](#)\n[![Uvicorn](https://img.shields.io/badge/Uvicorn-ASGI%20Server-222222?logo=python\u0026logoColor=white)](#)\n[![LangGraph](https://img.shields.io/badge/LangGraph-Agent%20Orchestration-5E6AD2?logo=graphql\u0026logoColor=white)](#)\n[![LangChain](https://img.shields.io/badge/LangChain-Tooling%2FRAG-1C3C3C?logo=chainlink\u0026logoColor=white)](#)\n[![OpenAI](https://img.shields.io/badge/OpenAI-Chat%20LLM-412991?logo=openai\u0026logoColor=white)](#)\n[![Anthropic](https://img.shields.io/badge/Anthropic-Chat%20LLM-18181B?logo=apache\u0026logoColor=white)](#)\n[![ChromaDB](https://img.shields.io/badge/ChromaDB-Vector%20Memory-282828?logo=databricks\u0026logoColor=white)](#)\n[![SQLite](https://img.shields.io/badge/SQLite-Conversation%20Store-003B57?logo=sqlite\u0026logoColor=white)](#)\n[![DuckDuckGo](https://img.shields.io/badge/DuckDuckGo-Search-FB542B?logo=duckduckgo\u0026logoColor=white)](#)\n[![SQLAlchemy](https://img.shields.io/badge/SQLAlchemy-ORM-D71F00?logo=databricks\u0026logoColor=white)](#)\n[![Pydantic](https://img.shields.io/badge/Pydantic-Config-0E7C86?logo=pydantic\u0026logoColor=white)](#)\n[![Pytest](https://img.shields.io/badge/Pytest-Tests-0A9EDC?logo=pytest\u0026logoColor=white)](#)\n[![Ruff](https://img.shields.io/badge/Ruff-Lint-000000?logo=ruff\u0026logoColor=white)](#)\n[![SSE](https://img.shields.io/badge/SSE-Streaming-5C5C5C?logo=electron\u0026logoColor=white)](#)\n[![Makefile](https://img.shields.io/badge/Makefile-Build%20System-000000?logo=make\u0026logoColor=white)](#)\n[![GitHub Actions](https://img.shields.io/badge/GitHub%20Actions-CI/CD-2088FF?logo=githubactions\u0026logoColor=white)](#)\n[![Code Quality](https://img.shields.io/badge/Code%20Quality-Tests%20+%20Lint-4C1?logo=codequality\u0026logoColor=white)](#)\n[![Open Source](https://img.shields.io/badge/Open%20Source-Community-FF5722?logo=open-source-initiative\u0026logoColor=white)](#)\n[![Shell](https://img.shields.io/badge/Shell-CLI%20Tools-4EAA25?logo=gnu-bash\u0026logoColor=white)](#)\n[![AWS](https://img.shields.io/badge/AWS-Cloud%20Ready-FF9900?logo=amazonaws\u0026logoColor=white)](#)\n[![Docker](https://img.shields.io/badge/Docker-Containerization-2496ED?logo=docker\u0026logoColor=white)](#)\n[![Ansible](https://img.shields.io/badge/Ansible-Configuration%20Management-EE0000?logo=ansible\u0026logoColor=white)](#)\n\nA **full‑fledged, multi‑stage, agentic chatbot** that **plans → discovers → reasons → uses tools → learns**.\nThe reference task baked into this repo is a **Research \u0026 Outreach Agent** (“**DossierOutreachAgent**”): given a topic/company, it builds a **compact, cited briefing** and (optionally) **drafts an outreach email**, saving artifacts to disk.\n\n## Table of Contents\n\n* [Key Features](#key-features)\n* [7‑Layer Architecture](#7-layer-architecture)\n* [Agent Graph (LangGraph)](#agent-graph-langgraph)\n* [Repository Layout](#repository-layout)\n* [Bonus: Agentic RAG](#bonus-agentic-rag)\n* [Bonus: Agentic Coding Pipeline](#bonus-agentic-coding-pipeline)\n* [Quickstart](#quickstart)\n* [Configuration](#configuration)\n* [Running](#running)\n* [CLI Utilities](#cli-utilities)\n* [HTTP API](#http-api)\n* [Tools \u0026 Capabilities](#tools--capabilities)\n* [Memory \u0026 Feedback](#memory--feedback)\n* [Extending the System](#extending-the-system)\n* [Testing \u0026 Quality](#testing--quality)\n* [GitHub Actions](#github-actions)\n* [Security \u0026 Ops](#security--ops)\n* [Troubleshooting](#troubleshooting)\n* [Roadmap Ideas](#roadmap-ideas)\n\n## Key Features\n\n* **Multi‑stage reasoning \u0026 planning** with **LangGraph** state machine (plan → decide → act → tools → reflect → finalize).\n* **Autonomous tool use \u0026 tool‑chaining** (web search, URL fetch, calculator, file write, email draft, KB search/add).\n* **Two memory systems**:\n\n  * **SQLite** conversation store (turn history, feedback).\n  * **ChromaDB** vector KB for **RAG** and persistent knowledge.\n* **Web experience layer**: minimal **FastAPI** + **SSE** streaming UI (no framework lock‑in).\n* **CLI** for ingestion \u0026 demos.\n* **Rate limiting** (token bucket) per chat.\n* **Batteries‑included tests** (unit + smoke), lint, formatting, and ready Makefile targets.\n* **Opinionated architecture**: 7‑layer separation, single action per step, reflect‑first finalization.\n* **Extensible**: add new tools, nodes, or agent profiles without breaking the core.\n* **Production ready**: designed for real‑world use with security, observability, and extensibility in mind.\n* **Open Source**: Apache licensed, built with community contributions in mind.\n\n---\n\n## 7-Layer Architecture\n\nThis system is designed with a **7-layer architecture** to separate concerns and allow for easy extension. Each layer has a specific role, and they communicate through well-defined interfaces. The core agent logic is implemented in LangGraph, which orchestrates the reasoning and tool use.\n\n\u003e [!NOTE]\n\u003e **Agent ≠ LLM.** This system implements a layered design that’s easy to extend and operate.\n\n```\nExperience (UI/API)\n   └─ FastAPI + SSE → web UI, CLI, REST\nDiscovery\n   └─ WebSearch, WebFetch, KB search (RAG)\nAgent Composition\n   └─ Agent profile (persona, objective, capabilities)\nReasoning \u0026 Planning\n   └─ LangGraph plan→decide→act→reflect→finalize\nTool \u0026 API\n   └─ Calculator, FileWrite, Emailer, Web tools, KB add/search\nMemory \u0026 Feedback\n   └─ SQLite (turns, feedback), ChromaDB (vector KB)\nInfrastructure\n   └─ Logging, rate limiting, config, packaging\n```\n\n**Directory mapping**\n\n| Layer                | Where                                                    |\n| -------------------- | -------------------------------------------------------- |\n| Experience           | `src/agentic_ai/app.py`, `web/`                          |\n| Discovery            | `src/agentic_ai/tools/webtools.py`, `tools/knowledge.py` |\n| Agent Composition    | `src/agentic_ai/layers/composition.py`                   |\n| Reasoning \u0026 Planning | `src/agentic_ai/layers/reasoning.py`, `graph.py`         |\n| Tools \u0026 API          | `src/agentic_ai/tools/*`, `layers/tools.py`              |\n| Memory \u0026 Feedback    | `src/agentic_ai/memory/*`, `layers/memory.py`            |\n| Infrastructure       | `src/agentic_ai/infra/*`, `config.py`, `pyproject.toml`  |\n\nBy separating these layers, we ensure that each component can evolve independently while maintaining a clear contract with the others. This modularity allows for easy testing, debugging, and extension of the system.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"img/agentic-ai.jpg\" alt=\"7-Layer Architecture\" width=\"100%\"\u003e\n\u003c/p\u003e\n\n\u003e Credit: Anil Inamdar for the original 7-layer architecture diagram and for the inspiration behind the agentic design principles.\n\n## Agent Graph (LangGraph)\n\nThe agent runs a **typed state machine** driving the LLM and tools. It uses **LangGraph** to orchestrate the reasoning and tool use, with a focus on **single atomic actions** per step. This design ensures clarity in execution and allows for easy debugging and extensibility.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"img/arch.png\" alt=\"Agentic AI Graph\" width=\"100%\"\u003e\n\u003c/p\u003e\n\nDynamic Mermaid graph of the agent's architecture:\n\n```mermaid\nflowchart LR\n\n%% =========================\n%% EXPERIENCE LAYER\n%% =========================\nsubgraph EXP[Experience Layer FastAPI SSE]\ndirection LR\nIN[User prompt]\nRL{Rate limit check}\nSTREAM[Token stream SSE]\nFB[Feedback API]\nIN --\u003e RL\nSTREAM --\u003e FB\nend\n\n%% =========================\n%% MEMORY LAYER\n%% =========================\nsubgraph MEM[Memory and Feedback]\ndirection TB\nSQL[(SQLite messages)]\nVEC[(Chroma vector KB)]\nCIT[Citations store]\nend\n\nRL --\u003e|ok| START\nRL --\u003e|429| HALT[Backoff and retry]\n\n%% =========================\n%% REASONING AND PLANNING\n%% =========================\nsubgraph GRAPH[Reasoning and Planning LangGraph]\ndirection LR\nSTART((START))\nPLAN[PLAN create plan]\nDECIDE{DECIDE next action}\nACT[ACT bind tool emit call]\nTOOLS((ToolNode executes call))\nREFLECT[REFLECT briefing or next]\nFINALIZE([FINALIZE result])\n\nSTART --\u003e PLAN\nPLAN --\u003e DECIDE\n\nDECIDE --\u003e|search| ACT\nDECIDE --\u003e|fetch| ACT\nDECIDE --\u003e|kb_search| ACT\nDECIDE --\u003e|calculate| ACT\nDECIDE --\u003e|write_file| ACT\nDECIDE --\u003e|draft_email| ACT\nDECIDE --\u003e|finalize| FINALIZE\nDECIDE --\u003e|otherwise| REFLECT\n\nACT --\u003e TOOLS\nTOOLS --\u003e REFLECT\n\nREFLECT --\u003e|done| FINALIZE\nREFLECT --\u003e|not done| DECIDE\n\nPLAN -.-\u003e STREAM\nDECIDE -.-\u003e STREAM\nREFLECT -.-\u003e STREAM\nFINALIZE -.-\u003e STREAM\nend\n\nPLAN -. use kb hits .-\u003e VEC\n\n%% =========================\n%% TOOL AND API LAYER\n%% =========================\nsubgraph TOOLS_LAYER[Tool and API Layer]\ndirection TB\nTSEARCH[web search]\nTFETCH[web fetch]\nTKBS[kb search]\nTKBADD[kb add]\nTCALC[calculator]\nTWRITE[file write]\nTEMAIL[emailer]\nend\n\nTOOLS --\u003e|query| TSEARCH\nTOOLS --\u003e|url| TFETCH\nTOOLS --\u003e|semantic| TKBS\nTOOLS --\u003e|ingest| TKBADD\nTOOLS --\u003e|expr| TCALC\nTOOLS --\u003e|path content| TWRITE\nTOOLS --\u003e|to subject body| TEMAIL\n\nTKBS --\u003e|results| PLAN\nTKBADD --\u003e VEC\nTSEARCH --\u003e TFETCH\nTFETCH --\u003e|text| PLAN\nTFETCH --\u003e CIT\nTWRITE --\u003e|artifact path| PLAN\nTEMAIL --\u003e|eml path| PLAN\n\nIN --\u003e|save user| SQL\nFINALIZE --\u003e|save assistant| SQL\nFB --\u003e|save feedback| SQL\n```\n\nThe graph consists of the following key nodes:\n\n* **PLAN**: creates a short action plan (3–6 steps), with **KB context** pre‑retrieval.\n* **DECIDE**: selects the next atomic action (token): `search`, `fetch`, `kb_search`, `calculate`, `write_file`, `draft_email`, or `finalize`.\n* **ACT**: binds LLM to tool schema and forces a **single precise tool call**.\n* **TOOLS**: concrete execution via LangGraph `ToolNode`.\n* **REFLECT**: either emits `BRIEFING: ...` (final) or `NEXT: \u003caction\u003e`.\n* **FINALIZE**: completes, persisting the result.\n\nThis design ensures that each step is clear and focused, allowing for easy debugging and understanding of the agent's behavior. The use of LangGraph allows for powerful state management and tool orchestration, making it a robust solution for building agentic systems.\n\n## Repository Layout\n\n```\nAgentic-RAG-Pipeline/     # Bonus: full agentic RAG pipeline in addition to this bot\nMakefile                  # Common tasks (setup, ingest, run, test)\nrequirements.txt          # Python dependencies\nsrc/\n  agentic_ai/\n    app.py                # FastAPI app (Experience)\n    graph.py              # LangGraph runner\n    cli.py                # CLI utilities (ingest/demo)\n    config.py             # Pydantic settings\n    infra/\n      logging.py          # Rotating logs\n      rate_limit.py       # Token bucket\n    memory/\n      sql_store.py        # SQLite conversation store\n      vector_store.py     # ChromaDB KB\n    layers/\n      composition.py      # Agent profile\n      reasoning.py        # Plan→Decide→Act→Reflect graph\n      memory.py           # Memory orchestrator helpers\n      tools.py            # Tool registry\n    tools/\n      webtools.py         # DuckDuckGo search + URL fetch \u0026 extract\n      ops.py              # Calculator, FileWrite, Emailer (mock)\n      knowledge.py        # KB add/search tools\nweb/\n  index.html styles.css app.js\ndata/\n  seed/                   # Non-empty RAG seeds\n  agent_output/          # FileWrite artifacts\n  emails/                # Emailer artifacts\ntests/\n  ... (unit \u0026 smoke)\n```\n\n\u003e [!IMPORTANT]\n\u003e This layout separates concerns clearly, with `src/agentic_ai` containing the core logic, `web/` for the UI, and `data/` for input/output artifacts. The `tests/` directory holds unit and smoke tests to ensure code quality.\n\n## Bonus: Agentic RAG\n\nLooking for a **full agentic RAG pipeline** (multi-step plan → retrieve → reflect → verify → answer) with memory, tool use, and quality checks? Check out the companion project **Agentic-RAG-Pipeline** for a complete, production-grade implementation and deeper docs.\n\n\u003e [!TIP]\n\u003e See **[Agentic-RAG-Pipeline Directory](Agentic-RAG-Pipeline/README.md)** for more info and end-to-end code.\n\n```mermaid\nflowchart TD\n  U[User] --\u003e IR[Intent Router - Flash]\n  IR --\u003e PL[Planner - Pro]\n  PL --\u003e RP[Retrieval Planner - Pro]\n  RP --\u003e R1[VectorRetriever - FAISS]\n  RP --\u003e R2[WebRetriever - Google CSE + Fetch]\n  R1 --\u003e W[Writer - Pro]\n  R2 --\u003e W\n  W --\u003e C[Critic - Pro]\n  C --\u003e|follow-ups| RP\n  W --\u003e G[Guardrails]\n  G --\u003e A[Answer + Evidence]\n  PL -. session .-\u003e M[(File-backed Memory)]\n```\n\nThis is a **full-fledged, multi-stage, agentic chatbot** that **plans → discovers → reasons → uses tools → learns**.\nThe reference task baked into this repo is a **Research \u0026 Outreach Agent** (“**DossierOutreachAgent**”): given a topic/company, it builds a **compact, cited briefing** and (optionally) **drafts an outreach email**, saving artifacts to disk.\n\n## Bonus: Agentic Coding Pipeline\n\nWant an **autonomous coding assistant** that proposes patches, formats them, drafts tests, reviews code and iterates until everything passes? The companion **Agentic Coding Pipeline** orchestrates multi-model coding (OpenAI + Claude), formatting, testing and Gemini-based review through a shared MCP server so any pipeline can dispatch code tasks.\n\n\u003e [!TIP]\n\u003e See **[Agentic-Coding-Pipeline Directory](Agentic-Coding-Pipeline/README.md)** for detailed usage and architecture.\n\n```bash\ncd Agentic-Coding-Pipeline\npython run.py \"Add feature X\"\n```\n\n## Quickstart\n\nTo quickly get started with the Agentic AI bot, follow these steps:\n\n```bash\n# 1) Create venv \u0026 install\npython -m venv .venv\n. .venv/bin/activate\npip install -U pip\npip install -r requirements.txt\n\n# 2) Configure model keys\ncp .env.example .env\n# Edit .env with your OPENAI_API_KEY (or ANTHROPIC_API_KEY) and preferences\n\n# 3) Ingest seed knowledge into vector store\nmake ingest\n\n# 4) Run the server\nmake run\n# Open http://localhost:8000 and ask:\n# \"Build a competitive briefing on ACME Robotics and draft a short outreach email.\"\n```\n\n**CLI demo (streams to stdout)**\n\n```bash\n. .venv/bin/activate\npython -m agentic_ai.cli demo \"Summarize top AMR vendors for grocery DCs with citations\"\n```\n\nThis will start the agent, which will plan, search, and reflect on the topic, providing a compact briefing with citations. You can also use the CLI to ingest additional documents into the vector knowledge base.\n\n## Configuration\n\nThe app uses **Pydantic Settings** and `.env`.\n\n```env\nMODEL_PROVIDER=openai          # openai | anthropic\nOPENAI_API_KEY=sk-...          # required if MODEL_PROVIDER=openai\nOPENAI_MODEL_CHAT=gpt-4o-mini\nOPENAI_MODEL_EMBED=text-embedding-3-small\n\nANTHROPIC_API_KEY=sk-ant-...   # required if MODEL_PROVIDER=anthropic\nANTHROPIC_MODEL_CHAT=claude-3-5-sonnet-latest\n\nCHROMA_DIR=.chroma\nSQLITE_PATH=.sqlite/agent.db\n\nAPP_HOST=0.0.0.0\nAPP_PORT=8000\n```\n\n\u003e You can switch providers at runtime by changing `MODEL_PROVIDER` and the corresponding keys/models.\n\n## Running\n\nWe recommend using a **virtual environment** to isolate dependencies. The provided Makefile simplifies setup and common tasks:\n\n**Makefile targets**\n\n* `make setup` – create venv, install deps, copy `.env.example`\n* `make ingest` – add files under `data/seed/` to the vector KB\n* `make run` – launch **FastAPI** on configured host/port\n* `make test` – run unit tests\n* `make format` / `make lint` – apply/check `ruff` (imports + formatting)\n\n**Run the server**\n\n```bash\n. .venv/bin/activate\nuvicorn src.agentic_ai.app:app --host\n```\n\nThis will start the FastAPI server on `http://localhost:8000`, where you can interact with the agent via the web UI or API.\n\n## CLI Utilities\n\nThis repository also provides a CLI for quick interactions and ingestion of knowledge:\n\n```bash\n# Ingest any folder recursively (adds text up to 10k chars per file)\npython -m agentic_ai.cli ingest ./data/seed\n\n# Run a single prompt through the graph (streams responses)\npython -m agentic_ai.cli demo \"Give me a briefing on collaborative robots with citations\"\n```\n\nThe CLI allows you to quickly test the agent's capabilities without needing to set up the web UI. It streams responses directly to the console, making it easy to see how the agent processes prompts and uses tools.\n\n## HTTP API\n\nA simple HTTP API is provided for programmatic access to the agent's capabilities. It supports both synchronous and streaming interactions:\n\n### `GET /api/new_chat`\n\nReturns a new `chat_id`.\n\n### `POST /api/chat` (SSE stream)\n\n**Request body**\n\n```json\n{ \"chat_id\": \"uuid-string\", \"message\": \"Your prompt\" }\n```\n\n**Stream events**\n\n* `event: token` – incremental text chunks\n* `event: done` – `{\"chat_id\": \"...\"}`\n\n### `POST /api/ingest`\n\nAdd an internal KB document.\n\n```json\n{ \"id\": \"doc-123\", \"text\": \"content...\", \"metadata\": { \"source\": \"...\" } }\n```\n\n### `POST /api/feedback`\n\nAttach a rating/comment to a chat/message.\n\n```json\n{ \"chat_id\": \"uuid\", \"message_id\": null, \"rating\": 1, \"comment\": \"👍\" }\n```\n\nThis API allows you to integrate the agent into your applications, enabling programmatic access to its reasoning and tool capabilities. The SSE stream provides real-time updates, making it suitable for interactive applications. Feedback can be used to improve the agent's performance over time.\n\n## Tools \u0026 Capabilities\n\nThe agent uses a set of **atomic tools** to perform actions. Each tool is designed for a specific purpose, and they can be chained together to achieve complex tasks. The tools are registered in the `tools.py` layer and can be invoked by the agent during reasoning.\n\n| Tool         | Name           | Purpose                                      | Input                     | Output                          |\n| ------------ | -------------- | -------------------------------------------- | ------------------------- | ------------------------------- |\n| `web_search` | WebSearch      | General discovery                            | NL query                  | JSON list of results            |\n| `web_fetch`  | WebFetch       | Extract readable text from URL               | URL                       | Clean text                      |\n| `kb_search`  | KbSearch       | Vector KB semantic search                    | NL query                  | JSON list of {id,text,metadata} |\n| `kb_add`     | KbAdd          | Add doc to KB                                | JSON `{id,text,metadata}` | `\"ok\"`                          |\n| `calculator` | Calculator     | Safe math via `math` module                  | Expression                | Result string                   |\n| `file_write` | FileWrite      | Persist artifacts under `data/agent_output/` | JSON `{path,content}`     | Absolute path                   |\n| `emailer`    | Emailer (mock) | Draft/queue email as `.eml`                  | JSON `{to,subject,body}`  | `.eml` path                     |\n\n**Tool‑chaining** is managed by the graph: `DECIDE` picks one atomic action per step, `ACT` binds tools and **forces one structured call**, `TOOLS` executes, `REFLECT` synthesizes or continues.\n\nThis design ensures that each tool is used in a controlled manner, allowing for clear reasoning and traceability of actions. The agent can also reflect on its actions and decide whether to finalize or continue with further steps.\n\n## Memory \u0026 Feedback\n\nThe agent has two memory systems to persist conversation history and knowledge:\n\n* **Conversation turns**: persisted in **SQLite** via `SQLStore` (`messages` table holds `role`, `content`, `tool_call`).\n* **Vector KB**: **ChromaDB** persistent collection; `kb_add` and `kb_search` power **RAG** and context for planning.\n* **Feedback**: optional `feedback` table (rating + comment), useful for reinforcement signals and post‑hoc analysis.\n\n**DB schema (simplified)**\n\n```sql\nCREATE TABLE IF NOT EXISTS chats (\n  id TEXT PRIMARY KEY,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  title TEXT\n);\nCREATE TABLE IF NOT EXISTS messages (\n  id INTEGER PRIMARY KEY AUTOINCREMENT,\n  chat_id TEXT,\n  role TEXT,\n  content TEXT,\n  tool_call TEXT,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\nCREATE TABLE IF NOT EXISTS feedback (\n  id INTEGER PRIMARY KEY AUTOINCREMENT,\n  chat_id TEXT,\n  message_id INTEGER,\n  rating INTEGER,\n  comment TEXT,\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n```\n\nFeel free to extend the memory layer with additional tables or fields as needed. The agent can use this memory to maintain context across interactions, allowing for more coherent and informed responses. More details on the memory layer can be found in `src/agentic_ai/memory/`.\n\n## Extending the System\n\nTo extend the system, you can add new tools, nodes, or modify the agent profile. Here are some guidelines:\n\n### Add a new Tool\n\n1. Create `src/agentic_ai/tools/\u003cyour_tool\u003e.py` implementing a `BaseTool` with `_run`.\n2. Register it in `src/agentic_ai/layers/tools.py::registry()`.\n3. Teach the decision policy by adding the token to `DECIDE`’s prompt and mapping in `ACT`.\n\n### Add a new Node (LangGraph)\n\n* Add a function `(state) -\u003e state`, `g.add_node(\"name\", fn)`, and wire edges.\n* Prefer **small atomic** nodes; use `reflect` to decide if you have enough evidence to finalize.\n\n### Change the Agent Profile\n\n* Edit `layers/composition.py::PROFILE` (persona, objective, capabilities).\n* Provide role or safety constraints in `SYSTEM` prompt in `layers/reasoning.py`.\n\n### Use Another Vector DB / Embeddings\n\n* Replace `VectorStore` implementation and/or embedding function.\n* Adjust ingestion (`cli.py`) and KB tool wiring accordingly.\n\nThe system is designed to be modular and extensible, allowing you to adapt it to your specific use cases. The LangGraph framework provides a powerful way to manage the agent's reasoning and tool use, making it easy to add new capabilities without disrupting existing functionality.\n\n\u003e [!TIP]\n\u003e Feel free to experiment with different tools, nodes, and configurations to tailor the agent to your needs. The modular design allows for easy testing and iteration, making it a flexible platform for building agentic systems!\n\n## Testing \u0026 Quality\n\nThis repository includes a comprehensive suite of tests to ensure code quality and functionality. The tests cover unit tests for individual components, as well as smoke tests for end-to-end scenarios.\n\n**Run all tests**\n\n```bash\n. .venv/bin/activate\npytest -q\n```\n\n**What’s covered**\n\n* Memory round‑trips (SQLite + ChromaDB).\n* Tool smoke tests (calculator/file/email/KB).\n* API endpoint sanity (new\\_chat/ingest/feedback).\n* Registry integrity.\n* Graph reasoning with a **Fake LLM** (if available in `langchain_core`) to avoid API keys during CI.\n\n**Lint \u0026 Format**\n\n```bash\nmake format\nmake lint\n```\n\n## GitHub Actions\n\nThis repository uses GitHub Actions for continuous integration (CI) to ensure code quality and functionality. The CI pipeline includes:\n\n* **Linting**: checks code style and formatting using `ruff`.\n* **Testing**: runs unit tests and smoke tests to verify functionality.\n* **Type checking**: ensures type safety using `mypy`.\n* **Dependency management**: checks for outdated dependencies and security vulnerabilities.\n* **Documentation generation**: builds the documentation from the code comments and README.\n* **Code coverage**: reports code coverage to ensure sufficient test coverage.\n* **Release management**: automatically creates releases based on tags.\n* **Docker build**: builds a Docker image for the application.\n* **Security checks**: runs security scans on the codebase.\n* and many more!\n\nYou can view the CI pipeline in the `.github/workflows/` directory. This should provide you with a solid foundation for maintaining code quality and ensuring that your changes do not break existing functionality, and feel free to extend the CI pipeline with additional checks or steps as needed.\n\n## Security \u0026 Ops\n\nWe also incorporate **DevSecOps** best practices to ensure the system is secure and production-ready:\n\n* **Rate limiting**: simple token bucket (`infra/rate_limit.py`) to mitigate spam.\n* **Logging**: rotating file + console (`.logs/agentic-ai.log`).\n* **Secrets**: `.env` (never commit) via Pydantic Settings.\n* **Isolation**: venv recommended; for servers, run behind a reverse proxy (nginx/Caddy).\n* **Outbound tools**: `web_fetch` honors redirects and has timeouts; consider adding domain allowlists for production.\n\n\u003e [!CAUTION]\n\u003e For production, consider:\n\u003e\n\u003e * API auth (JWT/OAuth) and per‑tenant namespaces for vector DB.\n\u003e * Audit logging of tool calls.\n\u003e * Observability (OpenTelemetry) and tracing via LangSmith or vendor of choice.\n\u003e * Dockerization and CI/CD (GitHub Actions) – the Makefile is a good start.\n\u003e * Rate limits on LLM calls to prevent abuse.\n\u003e * Bounded tool I/O: ensure tools have strict input/output limits to prevent abuse.\n\u003e * Security headers: set appropriate HTTP security headers (CSP, CORS, etc.) in FastAPI.\n\u003e * HTTPS: always run behind HTTPS in production (use nginx/Caddy).\n\u003e * Environment isolation: use separate environments for development, staging, and production.\n\u003e * Monitoring: set up monitoring for performance, errors, and usage patterns.\n\u003e * Backup: regularly back up the SQLite database and ChromaDB vector store.\n\u003e * Data retention: implement data retention policies for conversation history and feedback.\n\u003e * Compliance: ensure compliance with data protection regulations (GDPR, CCPA, etc.) if handling personal data.\n\u003e * Security reviews: conduct regular security reviews and vulnerability assessments.\n\u003e * Dependency management: keep dependencies up to date and monitor for vulnerabilities (e.g., using `pip-audit`).\n\u003e * Incident response: have an incident response plan in place for security breaches or data leaks.\n\nThis repository is designed to be a solid foundation for building agentic systems, with security and operational best practices in mind. However, always review and adapt the security measures based on your specific deployment environment and requirements. However, in production, make sure your agent is running behind a reverse proxy (like nginx or Caddy) to handle HTTPS, rate limiting, and security headers, and comply with standards like GDPR or CCPA if handling personal data.\n\n## Troubleshooting\n\nIf you encounter issues while running the agent, here are some common troubleshooting steps:\n\n* **Model errors**: ensure `.env` has the correct provider and API key.\n* **Vector store empty?** Run `make ingest` or POST `/api/ingest`.\n* **Unicode or huge files on ingest**: the CLI truncates to \\~10k chars per file; tweak in `cli.py`.\n* **Streaming stalls**: check browser console and server logs; SSE requires no buffering proxies (disable proxy buffering or set `proxy_buffering off` in nginx).\n* **Tool misuse**: update DECIDE prompt and `ACT` mapping to strongly bias the correct tool.\n\nIf you still have issues, feel free to open an issue on GitHub with details about your setup and the error messages you're encountering. The community is here to help!\n\n## Roadmap Ideas\n\nWe still have a lot of ideas for future improvements and features. Here are some potential roadmap items:\n\n* **Multi‑agent composition**: add specialist agents (e.g., “Citer”, “Editor”) and coordinate via LangGraph subgraphs.\n* **Structured outputs**: Pydantic validation for deliverables (JSON schemas for dossiers/emails).\n* **Retrieval upgrades**: hybrid search (BM25 + embeddings), reranking, summary chunking.\n* **Learning loop**: periodic fine‑tuning signals from `feedback` table or prompt cache.\n* **Real email**: integrate SMTP or provider SDK behind a feature flag.\n* **Auth \u0026 tenancy**: API keys per user, KB namespaces per tenant.\n\nIf you have ideas or contributions, feel free to open an issue or PR! We welcome community input to make this agentic system even better.\n\n## Credits\n\nThis project leverages several powerful libraries and frameworks to provide a robust agentic system:\n\n* **LangGraph** for robust agent graphs.\n* **LangChain** for tool abstractions.\n* **FastAPI/Uvicorn** for a sweet, fast developer experience.\n* **ChromaDB/SQLite** for pragmatic persistence.\n* **DuckDuckGo Search** for frictionless discovery.\n* **OpenAI/Anthropic** for chat LLMs.\n* and many more!\n\n### What makes this opinionated?\n\nThis system is designed with a few key principles in mind:\n\n* **Single‑action per step**: encourages deterministic tool traces and readable logs.\n* **Reflect‑first finalization**: no wall‑of‑text dumps; concise, cited briefings.\n* **7‑layer separation**: swap or extend layers without breaking others.\n* **Extensible tools**: add new tools or nodes without disrupting the core logic.\n* **Opinionated defaults**: preconfigured agent profile, tools, and memory systems to get you started quickly.\n* **Production ready**: designed for real‑world use with security, observability, and extensibility in mind.\n* **Open Source**: Apache licensed, built with community contributions in mind.\n* **Community driven**: we welcome contributions and ideas to improve the system.\n* **Batteries included**: unit tests, linting, formatting, and a Makefile to simplify common tasks.\n* **Minimal web UI**: no framework lock‑in, just FastAPI + SSE for streaming responses.\n* **CLI utilities**: for quick interactions and ingestion of knowledge.\n* **Rate limiting**: simple token bucket to prevent abuse.\n* **Security best practices**: logging, secrets management, and outbound tool safety.\n\nThis opinionated design allows for a clear and consistent development experience, making it easier to build and maintain agentic systems. The modular architecture ensures that you can adapt the system to your specific needs while still benefiting from the core features and best practices.\n\n## License\n\nThis project is licensed under the [Apache License](LICENSE). You are free to use, modify, and distribute this code as long as you include the original license and copyright notice.\n\n\u003e [!NOTE]\n\u003e Regardless of use, make sure you credit the original authors and contributors when using this code in your projects. Contributions are welcome, and we encourage you to share your improvements or extensions to the system.\n\n## Conclusion\n\nThis repository provides a solid foundation for building agentic systems with multi‑stage reasoning, autonomous tool use, and a focus on security and extensibility. The modular architecture allows for easy extension and customization, making it suitable for a wide range of applications.\n\nWe hope this project serves as a useful resource for your agentic AI projects. Whether you're building research agents, outreach bots, or any other type of agentic system, the principles and patterns demonstrated here can help you get started quickly and effectively.\n\nIf you have any questions, suggestions, or contributions, please feel free to open an issue or pull request on GitHub. We welcome community input and are excited to see how you use this system in your own projects!\n\n---\n\n**Happy building!** We hope this repository serves as a useful resource for your agentic AI projects. If you have any questions or suggestions, feel free to reach out or contribute!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2Fagentic-ai-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoangsonww%2Fagentic-ai-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoangsonww%2Fagentic-ai-pipeline/lists"}