Skip to content

Commit dddc258

Browse files
committed
agent limitations
1 parent 898646c commit dddc258

3 files changed

Lines changed: 55 additions & 62 deletions

File tree

chapter_3/agents.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,44 @@ At FutureHouse, we're seeking to accelerate scientific research with an AI agen
8484
As introduced in chapter 2, [PaperQA2](https://github.com/Future-House/paper-qa) is our scientific information retrieval system. Our data analysis agent is named [Finch](https://github.com/Future-House/finch). Finch is an AI agent framework designed to perform complex scientific data analysis tasks by iteratively working through Jupyter notebooks. This agent takes in datasets and prompts, then systematically explores, analyzes, and interprets the data to provide comprehensive answers and insights. Then we have [Robin](https://www.futurehouse.org/research-announcements/demonstrating-end-to-end-scientific-discovery-with-robin-a-multi-agent-system), our first multi-agent system for scientific discovery. We applied Robin to identify ripasudil, a Rho-kinase (ROCK) inhibitor clinically used to treat glaucoma, as a novel therapeutic candidate for dry age-related macular degeneration (dAMD), a leading cause of irreversible blindness worldwide. The second iteration of Robin, named [Kosmos](https://edisonscientific.com/articles/announcing-kosmos?gad_source=1&gad_campaignid=23563065812&gbraid=0AAAABB7BYdBNoPj2BU82YRgDuN7FLSbFp&gclid=CjwKCAjwwJzPBhBREiwAJfHRnZ_daxcLWR4IyY7swufHvUA5GBDm-dNoDpG-gSJng_9pe96pNd0ciBoCT7wQAvD_BwE), is our first AI scientist. The core innovation in Kosmos is the use of structured world models, which allow efficient incorporation of information extracted over hundreds of agent trajectories. This also allows the agent to maintain coherence towards a specific research objective over tens of millions of tokens.
8585

8686

87-
## 3.1.4 Additional Reading
87+
## 3.1.4 Limitations of AI Agents
88+
89+
AI agents are comparatively better at performing domain specific tasks than LLMs by themselves. However, this is does **not** mean they are free of limitations. Let's take a look some limitations AI agents face.
90+
91+
* **Context window constraints** LLMs have a finite context window. In multi-step agentic workflows, the accumulated message history — including tool calls, observations, and reasoning — can quickly approach or exceed this limit. When truncation occurs, the agent loses access to earlier reasoning, which can cause it to repeat steps, contradict itself, or fail entirely.
92+
93+
* **No memory across runs** By default, agents have no memory between runs. Each new rollout starts from scratch. In other words, the `DemoEnvState` is ephemeral. Once a rollout ends, nothing persists. If we wanted the agent to learn from prior protein analyses, we'd need to add external memory (e.g., a vector store or a structured cache).
94+
95+
* **Hallucination and unreliable tool outputs** LLMs can generate plausible-sounding but factually incorrect content, especially when answering questions outside their training data or when tool outputs are ambiguous. For example `handle_tool_exc=True` in `step()` method catches tool exceptions and converts them to messages rather than crashing. This is safe, but the agent may not recover gracefully. It might keep retrying a broken tool or hallucinate a result.
96+
97+
* **Error propagation across steps** Agents take sequential actions, so an early mistake; a wrong tool choice, a misinterpreted observation, or a malformed argument can cascade through subsequent steps and compound into a larger failure. Errors are not always recoverable, especially if the agent lacks explicit error-handling logic.
98+
99+
* **Incomplete or premature termination** Agents driven by a fixed step budget may terminate before completing a task, or may call a termination tool too early because the LLM misjudges task completion. Conversely, without a step limit, agents can loop indefinitely on unsolvable tasks.
100+
101+
* **Limited generalization across tasks** Agents are sensitive to how tools are described and how prompts are framed. A system prompt or tool description that works well for one task may perform poorly on a slightly different one. Agents often lack the robustness to handle out-of-distribution inputs gracefully.
102+
103+
### Mitigations & Performance Improvements
104+
105+
| Limitation | Mitigation|
106+
| --- | --- |
107+
| Context overflow| Summarize or compress old messages; use sliding window memory; set output length limits on tool responses |
108+
| No persistent memory | memoryAdd a vector store or structured cache to persist and retrieve results across runs |
109+
| Hallucination | Ground LLM outputs with retrieval (RAG); require citations; use tool outputs as the source of truth over model priors |
110+
| Error propagation | Add explicit error handling and retry logic; validate tool inputs/outputs before passing them downstream |
111+
| Premature/no termination | Check for termination signals after every step; set sensible step budgets based on task complexity|
112+
| Poor generalization | Invest in prompt engineering and tool description clarity; test on diverse inputs; use few-shot examples in the system prompt |
113+
114+
### Evaluating agent performance
115+
116+
This is as important as building the agent itself. Rather than just inspecting final outputs, consider:
117+
118+
- Trajectory analysis: did the agent take the most efficient path, or did it waste steps?
119+
- Tool use accuracy: did it call the right tools with valid arguments?
120+
- Failure mode logging: track when and why agents fail to complete tasks, to guide future improvements
121+
122+
Frameworks like LDP and Aviary are designed with evaluation in mind: trajectories are structured objects you can analyze programmatically, making it straightforward to build automated eval pipelines on top of your existing rollout infrastructure.
123+
124+
## 3.1.5 Additional Reading
88125
- More mathematical explanations can be found in this paper: [Aviary: training language agents on challenging scientific tasks](https://arxiv.org/abs/2412.21154)
89126
- [AI Agents - IBM tutorials](https://www.ibm.com/think/topics/ai-agents)
90127

chapter_3/aviary_agent_implementation.ipynb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -528,50 +528,6 @@
528528
" if tc.function.name == \"submit_final_answer\":\n",
529529
" print(tc.function.arguments[\"answer\"])"
530530
]
531-
},
532-
{
533-
"cell_type": "markdown",
534-
"id": "15",
535-
"metadata": {},
536-
"source": [
537-
"## 3.2.5 Limitations of AI Agents & Improving Performance\n",
538-
"\n",
539-
"AI agents are comparatively better at performing domain specific tasks than LLMs by themselves. However, this is does **not** mean they are free of limitations. Let's take a look some limitations AI agents face.\n",
540-
"\n",
541-
"* **Context window constraints** LLMs have a finite context window. In multi-step agentic workflows, the accumulated message history — including tool calls, observations, and reasoning — can quickly approach or exceed this limit. When truncation occurs, the agent loses access to earlier reasoning, which can cause it to repeat steps, contradict itself, or fail entirely.\n",
542-
"\n",
543-
"* **No memory across runs** By default, agents have no memory between runs. Each new rollout starts from scratch. In other words, the `DemoEnvState` is ephemeral. Once a rollout ends, nothing persists. If we wanted the agent to learn from prior protein analyses, we'd need to add external memory (e.g., a vector store or a structured cache).\n",
544-
"\n",
545-
"* **Hallucination and unreliable tool outputs** LLMs can generate plausible-sounding but factually incorrect content, especially when answering questions outside their training data or when tool outputs are ambiguous. For example `handle_tool_exc=True` in `step()` method catches tool exceptions and converts them to messages rather than crashing. This is safe, but the agent may not recover gracefully. It might keep retrying a broken tool or hallucinate a result.\n",
546-
"\n",
547-
"* **Error propagation across steps** Agents take sequential actions, so an early mistake; a wrong tool choice, a misinterpreted observation, or a malformed argument can cascade through subsequent steps and compound into a larger failure. Errors are not always recoverable, especially if the agent lacks explicit error-handling logic.\n",
548-
"\n",
549-
"* **Incomplete or premature termination** Agents driven by a fixed step budget may terminate before completing a task, or may call a termination tool too early because the LLM misjudges task completion. Conversely, without a step limit, agents can loop indefinitely on unsolvable tasks.\n",
550-
"\n",
551-
"* **Limited generalization across tasks** Agents are sensitive to how tools are described and how prompts are framed. A system prompt or tool description that works well for one task may perform poorly on a slightly different one. Agents often lack the robustness to handle out-of-distribution inputs gracefully.\n",
552-
"\n",
553-
"### Mitigations & Performance Improvements\n",
554-
"\n",
555-
"| Limitation | Mitigation|\n",
556-
"| --- | --- |\n",
557-
"| Context overflow| Summarize or compress old messages; use sliding window memory; set output length limits on tool responses |\n",
558-
"| No persistent memory | memoryAdd a vector store or structured cache to persist and retrieve results across runs |\n",
559-
"| Hallucination | Ground LLM outputs with retrieval (RAG); require citations; use tool outputs as the source of truth over model priors |\n",
560-
"| Error propagation | Add explicit error handling and retry logic; validate tool inputs/outputs before passing them downstream |\n",
561-
"| Premature/no termination | Check for termination signals after every step; set sensible step budgets based on task complexity|\n",
562-
"| Poor generalization | Invest in prompt engineering and tool description clarity; test on diverse inputs; use few-shot examples in the system prompt |\n",
563-
"\n",
564-
"### Evaluating agent performance \n",
565-
"\n",
566-
"This is as important as building the agent itself. Rather than just inspecting final outputs, consider:\n",
567-
"\n",
568-
"- Trajectory analysis: did the agent take the most efficient path, or did it waste steps?\n",
569-
"- Tool use accuracy: did it call the right tools with valid arguments?\n",
570-
"- Failure mode logging: track when and why agents fail to complete tasks, to guide future improvements\n",
571-
"\n",
572-
"Frameworks like LDP and Aviary are designed with evaluation in mind: trajectories are structured objects you can analyze programmatically, making it straightforward to build automated eval pipelines on top of your existing rollout infrastructure.\n",
573-
"\n"
574-
]
575531
}
576532
],
577533
"metadata": {

resources/python_basics.ipynb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"\n",
1919
"Python is popular because it is easy to read, has a large ecosystem of scientific libraries, and works well with modern AI tools.\n",
2020
"\n",
21-
"## Installing Python\n",
21+
"## 4.2.1 Installing Python\n",
2222
"\n",
2323
"The easiest way to get started is by installing:\n",
2424
"\n",
@@ -34,7 +34,7 @@
3434
"\n",
3535
"> **Video:** Installation walkthrough [for Windows](https://www.youtube.com/watch?v=YKSpANU8jPE), [for Mac](https://www.youtube.com/watch?v=utVZYVJSTZA).\n",
3636
"\n",
37-
"## Your First Python Program\n",
37+
"## 4.2.2 Write Your First Python Program\n",
3838
"\n",
3939
"Python scripts are saved with `.py` extension. You can create a file named `hello.py` write `print(\"Hello, world!\")` in it. \n",
4040
"\n",
@@ -60,7 +60,7 @@
6060
"id": "2",
6161
"metadata": {},
6262
"source": [
63-
"# Integrated Development Environments (IDEs)\n",
63+
"### Integrated development environments (IDEs)\n",
6464
"\n",
6565
"While Python code can be written in a simple text editor, most programmers use an **Integrated Development Environment (IDE)**. An IDE provides tools that make coding easier, including syntax highlighting, code completion, debugging, and project management.\n",
6666
"\n",
@@ -79,7 +79,7 @@
7979
"> **Video:** Getting started with VS code - \n",
8080
"> [Link](https://www.youtube.com/watch?v=D2cwvpJSBX4)\n",
8181
"\n",
82-
"### AI-Assisted Coding with Cursor\n",
82+
"### AI-assisted coding with cursor\n",
8383
"\n",
8484
"In recent years, AI-powered code editors have become popular tools for learning and programming. One example is **Cursor**, an editor built on top of VS Code that includes AI features for writing, explaining, and debugging code.\n",
8585
"\n",
@@ -99,7 +99,7 @@
9999
"\n",
100100
"Now let's shift gears and take a much more detailed look into writing python codes.\n",
101101
"\n",
102-
"## Variables in python\n",
102+
"## 4.2.3 Variables in Python\n",
103103
"\n",
104104
"Variables are used to store information that can be referenced and manipulated later in a program. You can think of a variable as a labeled container that holds a value, such as a number, a piece of text, or a collection of data.\n",
105105
"\n",
@@ -144,7 +144,7 @@
144144
"id": "6",
145145
"metadata": {},
146146
"source": [
147-
"## Basic Data Types\n",
147+
"## 4.2.4 Basic Data Types\n",
148148
"\n",
149149
"Every value stored in Python has a data type. The data type determines what kind of information is stored and what operations can be performed on it.\n",
150150
"\n",
@@ -171,7 +171,7 @@
171171
"is_significant = True\n",
172172
"```\n",
173173
"\n",
174-
"## Basic Arithmetic\n",
174+
"## 4.2.5 Basic Arithmetic\n",
175175
"\n",
176176
"Python can perform mathematical calculations just like a calculator. Arithmetic operations are useful in many scientific applications, including data analysis, statistical calculations, unit conversions, and numerical simulations.\n",
177177
"\n",
@@ -208,7 +208,7 @@
208208
"id": "8",
209209
"metadata": {},
210210
"source": [
211-
"## Data Structures\n",
211+
"## 4.2.6 Data Structures\n",
212212
"\n",
213213
"As programs become more complex, we often need to store and organize collections of data rather than individual values. **Data structures** are ways of organizing data so that it can be accessed, modified, and analyzed efficiently.\n",
214214
"\n",
@@ -244,7 +244,7 @@
244244
"id": "10",
245245
"metadata": {},
246246
"source": [
247-
"## Dictionaries\n",
247+
"### Dictionaries\n",
248248
"\n",
249249
"Dictionaries are data structures that store information as **key-value pairs**. Instead of accessing values by their position (as in a list), values in a dictionary are accessed using a unique key.\n",
250250
"\n",
@@ -275,7 +275,7 @@
275275
"id": "12",
276276
"metadata": {},
277277
"source": [
278-
"## Conditional Statements\n",
278+
"### Conditional Statements\n",
279279
"\n",
280280
"Conditional statements allow your program to make decisions based on whether a condition is true or false. They are commonly used in scientific analysis to filter data, apply thresholds, or trigger different actions depending on the results.\n",
281281
"\n",
@@ -302,7 +302,7 @@
302302
"id": "14",
303303
"metadata": {},
304304
"source": [
305-
"## Loops\n",
305+
"## 4.2.7 Loops\n",
306306
"\n",
307307
"Loops allow you to repeat the same operation multiple times without rewriting code. This is especially useful when working with datasets, collections of genes, proteins, samples, or experimental measurements.\n",
308308
"\n",
@@ -355,7 +355,7 @@
355355
"id": "18",
356356
"metadata": {},
357357
"source": [
358-
"## Functions\n",
358+
"## 4.2.8 Functions\n",
359359
"\n",
360360
"As programs grow larger, it becomes useful to group related code into reusable blocks called **functions**. Functions allow you to perform a specific task whenever needed without rewriting the same code multiple times.\n",
361361
"\n",
@@ -388,7 +388,7 @@
388388
"id": "20",
389389
"metadata": {},
390390
"source": [
391-
"## Best Practices\n",
391+
"## 4.2.9 Python Best Practices\n",
392392
"\n",
393393
"* Use meaningful variable names.\n",
394394
"* Write small, reusable functions.\n",
@@ -398,7 +398,7 @@
398398
"* Use version control (Git) for larger projects.\n",
399399
"\n",
400400
"\n",
401-
"## Importing Libraries\n",
401+
"## 4.2.10 Importing Libraries\n",
402402
"\n",
403403
"Python's power comes from its libraries. A library is a collection of pre-written code that provides additional functionality, allowing you to perform complex tasks without writing everything from scratch.\n",
404404
"\n",
@@ -451,7 +451,7 @@
451451
"id": "24",
452452
"metadata": {},
453453
"source": [
454-
"## Working with Data\n",
454+
"## 4.2.11 Working with Data\n",
455455
"\n",
456456
"One of the main reasons scientists use Python is its ability to work efficiently with data. Experimental results, survey responses, genomic datasets, and simulation outputs are often stored in tabular formats such as CSV (Comma-Separated Values) files.\n",
457457
"\n",
@@ -486,7 +486,7 @@
486486
"id": "26",
487487
"metadata": {},
488488
"source": [
489-
"## Plotting Data\n",
489+
"### Plotting Data\n",
490490
"\n",
491491
"Visualizing data is an important part of scientific analysis. Graphs and charts can help reveal patterns, trends, outliers, and relationships that may not be obvious when looking at raw numbers alone.\n",
492492
"\n",
@@ -518,7 +518,7 @@
518518
"id": "28",
519519
"metadata": {},
520520
"source": [
521-
"## Learn More\n",
521+
"## 4.2.12 Additional Resources\n",
522522
"\n",
523523
"* [NumPy basics](https://www.youtube.com/watch?v=QUT1VHiLmmI)\n",
524524
"* [Pandas basics](https://www.youtube.com/watch?v=EXIgjIBu4EU)\n",

0 commit comments

Comments
 (0)