https://subscription.packtpub.com/video/data/9781806675555/p1/video1_5/ai-agents-in-finance # **AI Agents in Finance** Hanane Dupouy breaks down how agentic AI systems are reshaping finance. She'll explain how agent workflows differ from standard LLM pipelines, explore key reasoning patterns like ReAct and Self-Refine, and share practical design principles for building autonomous, coordinated agents. You'll also get an overview of popular frameworks, including OpenAI's Agents SDK, AutoGen, CrewAI, LlamaIndex, and LangChain. Hanane will connect it all to real finance use cases, from fundamental analysis to strategy refinement. --- This talk, **“AI Agents in Finance,”** introduces how agentic workflows extend standard LLM pipelines, the reasoning and architecture patterns behind them, and concrete trading and analysis use cases built with tools like LangGraph, LlamaIndex, CrewAI, and OpenAI agents.paste.txt​ --- ## 1. LLM limitations and standard fixes in finance - Three core limitations are highlighted for raw LLMs in finance: - **Knowledge cut‑off** (e.g., GPT‑4o trained only up to mid‑2024, so recent events like 2025 elections or latest prices are unknown or weakly answered even with naive web search).paste.txt​ - **Domain specificity**: general models struggle with precise financial, legal, or medical questions unless adapted.paste.txt​ - **Proprietary data**: firm‑internal data is not in pretraining, so models hallucinate plausible‑sounding but wrong answers.paste.txt​ - Standard mitigation techniques: - **Fine‑tuning** on labeled domain datasets (e.g., sentiment analysis over news), but requires large, regularly refreshed supervised datasets and is time‑consuming/costly.paste.txt​ - **Instruction prompting** and **few‑shot learning** to inject domain behavior via careful prompts and examples.paste.txt​ - **RAG (retrieval‑augmented generation)** to pull from internal PDFs, reports, and databases into the context before generation.paste.txt​ --- ## 2. From non‑agentic LLM use to agentic workflows ## Non‑agentic use - Typical usage since 2022: user asks a question (e.g., “Explain this trading strategy”), LLM answers, user manually refines through follow‑up questions.paste.txt​ - This is **single‑shot, manual, and limited** by the earlier LLM constraints.paste.txt​ ## Agentic workflows - **Agent** definition: an autonomous system that can perform tasks, make decisions, interact with external environments, and refine internal answers to achieve a goal.paste.txt​ - Key characteristics: **autonomy, interactivity, adaptability, goal‑orientation**.paste.txt​ - Agentic workflows introduce: - **Multi‑step reasoning loops** where the system iteratively improves its own answers. - **Tool use**: APIs, databases, web search, code execution. - **Multi‑agent collaboration**: specialized agents that communicate, each with narrow, well‑defined responsibilities and tools.paste.txt​ --- ## 3. Anthropic’s three levels: augmented LLM, workflows, agents The speaker adopts Anthropic’s “agentic system” framing as a maturity ladder.paste.txt​ 1. **Augmented LLM (“brilliant blob”)** - A single LLM enhanced with: - **Retrieval** (external search, internal corpora). - **Tools** (APIs, databases). - **Memory** (stored state in a database for reuse).paste.txt​ 2. **Workflows** (multi‑step but not fully autonomous) - **Prompt chains**: break a task into subtasks, each handled by a separate LLM; outputs feed sequentially down the chain.paste.txt​ - **Parallelization**: - **Decomposition**: different independent subtasks processed simultaneously by different agents.paste.txt​ - **Voting**: same task given to several LLMs with different parameters (e.g., temperatures); results aggregated or voted on.paste.txt​ - **Orchestrator–worker (leader–follower)**: one “orchestrator” agent splits tasks and dispatches them to specialized worker agents, then aggregates results.paste.txt​ - **Routing**: a router decides which specialized agent should handle an incoming request based on input classification.paste.txt​ - **LLM‑as‑judge**: a second model evaluates or critiques the first model’s outputs and drives refinement (evaluator/optimizer pattern).paste.txt​ 3. **Agents (fully agentic loop)** - Agents observe environment, take actions, and update internal state in a continuous feedback loop, optionally including **human‑in‑the‑loop checkpoints** (e.g., “Are you OK with this answer?” before proceeding).paste.txt​ --- ## 4. Reasoning paradigms and architectural styles ## Reasoning paradigms - The talk surveys several reasoning patterns and focuses on two: - **Self‑Refine / Reflection**: - A **generator** produces an initial answer. - A **feedback provider** critiques that answer. - A **refiner** uses the original output + feedback to produce an improved answer.paste.txt​ - This loop repeats until no more feedback or a max iteration count.paste.txt​ - **ReAct (Reason + Act)**: - The agent first generates a **thought** (reasoning trace) to decide what to do. - Then takes an **action** (e.g., call a tool). - Receives an **observation** (tool output) which updates context. - Repeats Thought → Action → Observation until it has enough to answer.paste.txt​ ## Architectural styles - Architectures describe how agents communicate and coordinate:paste.txt​ - **Leader–follower (orchestrator–worker)**: a central leader manages tasks and delegates to workers; communication is primarily horizontal from leader to followers.paste.txt​ - **Peer‑to‑peer**: all agents are equal, can talk to each other directly, and coordinate to reach a goal (used in some finance examples).paste.txt​ - **Hierarchical**: multiple levels (leader, sub‑leaders, agents), with both vertical and horizontal communication; powerful but complex to implement and debug.paste.txt​ --- ## 5. Guardrails and safety - **Guardrails** are emphasized as critical in finance: - **Input guardrails**: validate that incoming user requests are not harmful or out of scope before processing.paste.txt​ - **Output guardrails**: check whether agent answers leak confidential information or violate policy before returning to the user.paste.txt​ - Guardrails can be implemented at multiple layers—pre‑agent, per‑agent, and post‑agent—and are considered standard design patterns in agentic systems.paste.txt​ --- ## 6. Frameworks for financial agents The speaker briefly reviews several popular frameworks and their strengths.paste.txt​ - **LangGraph (LangChain + graph engine)** - Highly **customizable**; allows building arbitrary graphs of agents, workflows, and shared state.paste.txt​ - Supports **internal state** (shared between agents during execution) and **external memory** (database‑backed context).paste.txt​ - Higher learning curve; often requires multiple iterations to converge on a robust workflow.paste.txt​ - **OpenAI agents (Agentic API)** - “Agent” (e.g., `gpt-actions/Agentic` style) supports: - **Hands‑off** routing to specific agents, enabling custom topologies (leader‑follower, peer‑to‑peer) via agent‑as‑tool design.paste.txt​ - Built‑in **tracing and observability** in the OpenAI dashboard, showing tools used and arguments.paste.txt​ - **Assistants API** is an older agent flavor (sandboxed file/code environment) and is being superseded by the newer agents.paste.txt​ - **CrewAI** - Multi‑agent framework where you define **agents**, **tasks**, and **tools**, orchestrated by a **“crew” manager**.paste.txt​ - Supports a set of predefined architectures; less flexibility than raw LangGraph but easier to start with.paste.txt​ - **LlamaIndex** - Strong RAG and **React‑agent support**, with built‑in **ReAct agents** and financial examples described later.paste.txt​ - **Autogen** - Early version aligned closely with the original Autogen research paper was straightforward; newer version has **chat‑style** and **core** modes and a higher entry cost.paste.txt​ - **Other tools** - **SmolAgents** (Python‑code‑executing agent from Hugging Face), Anthropic’s **Computer Use** (agents controlling your desktop to write code, run VS Code, etc.), Google’s **Agent Developer Kits**, and memory systems like **MemGPT** are also mentioned.paste.txt​ --- ## 7. Detailed financial agent use cases ## 7.1 Strategy generator + evaluator (LLM‑as‑judge with OpenAI Agent) - Architecture: - **Strategy generator agent**: prompted to produce a **Python implementation** of a trading strategy.paste.txt​ - **Strategy evaluator agent**: receives the code, critiques it, and labels it (“needs refinement,” etc.), providing detailed feedback.paste.txt​ - The generator refines its code using this feedback in a loop until a satisfactory solution emerges.paste.txt​ - Built using OpenAI’s **agents**, with tracing showing: - Hand‑offs between generator and evaluator. - Intermediate code versions and evaluator comments. - Final accepted strategy implementation.paste.txt​ ## 7.2 Multi‑agent fundamental analysis with LlamaIndex (peer‑to‑peer) - Goal: **analyze a company’s fundamentals** and comment on profitability and liquidity.paste.txt​ - Agents and tools: - **Fundamental agent**: - Calls an external financial modeling API to fetch all financial ratios for a given ticker.paste.txt​ - **Profitability agent**: - Receives only profitability ratios, applies **explicit thresholds**, and produces commentary on profit health.paste.txt​ - **Liquidity agent**: - Receives only liquidity ratios, applies thresholds, and comments on liquidity risk.paste.txt​ - **Supervisor agent**: - Aggregates outputs from profitability and liquidity agents into a global assessment of the firm’s health (e.g., Apple).paste.txt​ - Design details: - **Peer‑to‑peer architecture** with explicit **handoffs** between agents.paste.txt​ - **Shared state**: a common state object that all agents read/write, enabling each to see what others have done.paste.txt​ - Tools per agent are tightly scoped to enforce specialization and minimize cross‑contamination of responsibilities.paste.txt​ ## 7.3 Financial analysis agent with OpenAI (leader–follower) - Architecture: **leader–follower** using OpenAI’s agents: - **Manager agent**: interprets user queries (e.g., “Current stock price of Amazon and Nvidia”) and routes subtasks.paste.txt​ - Specialized worker agents: - **Stock price agent**. - **Company basics agent**. - **Income statement agent**, etc.paste.txt​ - Tracing: - Dashboard shows manager handing off to stock‑price agent twice (one for each ticker), including arguments and outputs.paste.txt​ - Demonstrates how to inspect agent behavior in production via the logs/traces API as well as the UI.paste.txt​ ## 7.4 React finance agent with LlamaIndex - Built using the **built‑in ReAct agent** in LlamaIndex.paste.txt​ - Tools: - `get_stock_price` – last price for ticker. - `search_news` – fetch financial news via API. - `summarize_news` – summarize retrieved articles. - `plot_prices` – plot price series over time.paste.txt​ - Example interactions: - Question: “What is the last price of Nvidia?” → agent: - **Thought**: decides to call `get_stock_price`. - **Action**: calls tool with ticker “NVDA”. - **Observation**: receives numeric price. - Terminates with a concise answer.paste.txt​ - Question: “Summarize recent news on OpenAI” → agent: - Calls `search_news`, then `summarize_news`, returning a synthesized summary.paste.txt​ - Question: “Plot recent prices” → calls plotting tool and returns the visualization.paste.txt​ ## 7.5 Reflection‑based finance agent - Demonstrates the **Self‑Refine** pattern for financial tasks: - **Generator**: initial output (e.g., analysis or code). - **Reflection agent**: critiques and suggests improvements. - **Reviewer**: reconciles output + reflection into a final refined result.paste.txt​ - This structure is applied to increase reliability of financial recommendations or calculations.paste.txt​ --- ## 8. Practical design advice for finance agents - **Start simple**: - Begin with an augmented LLM, then add tools, then simple workflows (deterministic flows, basic parallelization, LLM‑as‑judge), and only then move to fully agentic patterns.paste.txt​ - **Specialize agents and tools**: - Each agent should have a **narrow, clear task** with well‑defined tools and instructions; multi‑agent systems work best when roles are crisp.paste.txt​ - **Latency and cost management**: - Split large agents into smaller sub‑agents to reduce per‑call workload and context size.paste.txt​ - Use less verbose models where possible and consider **small LLMs** for simple subtasks, reserving frontier models for complex reasoning.paste.txt​ - **External memory for personalization**: - Store past interactions and summaries in external databases per client; on new queries, retrieve client history and feed it into the agent to personalize responses and avoid re‑asking the same questions.paste.txt​ - **Career angle**: - The speaker notes that many finance professionals are not yet up‑to‑speed on LLMs and agents; learning these tools and understanding their limits, use cases, and justification to business stakeholders can be a major differentiator for data scientists and quants.paste.txt​ 1. [https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/aff95306-1187-4c03-8550-57188987c3e3/paste.txt](https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/aff95306-1187-4c03-8550-57188987c3e3/paste.txt) 2. [https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/2ee025f7-cabe-4041-992e-39e39dd2d69e/paste.txt](https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/2ee025f7-cabe-4041-992e-39e39dd2d69e/paste.txt) 3. [https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/c9fd2284-b316-4126-b35b-873091643fe9/paste.txt](https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/c9fd2284-b316-4126-b35b-873091643fe9/paste.txt) 4. [https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/92f15510-9262-495d-8c8a-3cf05c571b33/paste.txt](https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/attachments/139614499/92f15510-9262-495d-8c8a-3cf05c571b33/paste.txt) ---