Skip to content
PodSubs
ShowsPeopleGuestsJobsNewsEvents
More
BlogPodCred
Menu
ShowsPeopleGuestsJobsNewsEventsBlogPodCredNetworksSign in
Join nowSign in
  • Shows
  • People
  • Jobs
  • News
  • More
    • Guests
    • Events
    • Blog
    • PodCred
    • Networks
    Join nowSign in

The AI Practitioner Podcast

The AI Practitioner Podcast artwork

PODCAST — TextGrad in Practice: Optimizing LLM Agent Prompts with Textual Gradients

Nov 3, 202615 minAudio
ShareXLinkedInFacebookWhatsAppEmail

Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. What if AI agents could improve their own prompts instead of relying on manual updates? In production, data evolves, models change, and new failures emerge. Keeping prompts effective requires continuous evaluation and refinement, but manually managing this process quickly becomes difficult to scale. TextGrad offers a different approach: it uses natural-language feedback, called textual gradients, to identify errors and automatically update prompts without modifying the underlying model. In this episode, the focus is on how TextGrad works, what a real banking classification experiment reveals about its effectiveness, and the challenges of evaluating prompt improvements when no correct answer exists. You’ll learn: * How can AI agents optimize their own prompts? Exploring how TextGrad turns errors into textual gradients and uses them to automatically update instructions. * Does automated prompt optimization actually improve performance? Examining experimental results, why some updates introduce regressions, and the trade-offs between accuracy, cost, and prompt complexity. * What happens when there is no correct answer? Understanding how LLM judges can guide optimization for open-ended tasks, why their feedback can be misleading, and what reliable evaluation requires. 👉 Enjoyed this episode? Subscribe to The AI Practitioner to get future articles and podcasts delivered straight to your inbox: aipractitioner.substack.com Get full access to The AI Practitioner at aipractitioner.substack.com/subscribe

Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.

Transcript

From the show. Tap a time to play from there.

[music]

SPEAKER_02Welcome back to The AI Practitioner. I'm Lina Faik, ML Engineer, Consultant, and Lecturer in Advanced Machine Learning at Sorbonne University. I help companies turn their data into real outcomes with AI, and this is where I share what I learn from actual projects. The deep technical write-ups live on Substack at aipractitioner.substack.com, and these conversations are the audio companion. Today I'm joined by John, a data scientist who builds LLM applications and has plenty of opinion about prompts,

SPEAKER_02but has not yet gone deep on automatic prompt optimization. John, welcome.

SPEAKER_01Thanks, Lina. Happy to be here. So what's on the table today?

SPEAKER_02Picture a customer support agent for an online store. It reads incoming tickets, classifies them, looks things up with tools, and writes a reply. Before launch, it passes every test. A month later, it is quietly failing real users, and nobody touched the prompt.

SPEAKER_01Ouch.

SPEAKER_02Right. Models evolve, users behave differently, policies change. The prompt stays frozen while the world moves. Keeping prompts reliable over time is a core challenge of what people now call agent tops, and that is what the article is about, how to continuously optimize agent prompts in production.

SPEAKER_01Hold on though, isn't this just prompt engineering? Someone looks at the failures, rewrites the instructions, tests again. We have done that for years.

SPEAKER_02We have, and it works. The trouble is what it looks like in practice. Improvements often rely on a handful of examples. A fix can introduce new failures somewhere else, and every iteration starts mostly from scratch. Even when you ask an LLM to suggest the edits, those limits remain.

SPEAKER_01Okay, so the human or the model is not the real issue. The process is.

SPEAKER_02Exactly. The methods in the article turn that process into a structured loop. Analyze failures, propose an update, use the result to guide the next round. Three of them are the stars. TexGrad, JIPA, and ACE.

SPEAKER_01Before we get to the names, why can't I just look at the score? Say the agent gets 82% accuracy. I track that number, I try changes, I keep what raises it.

SPEAKER_02You can, and some methods do exactly that. One of them has an LLM proposed And reinforcement learning? That also learns from

SPEAKER_01scores.

SPEAKER_02It does, and it updates the model weights, which adds a real computational cost. In both cases, the signal is a number without an explanation.

SPEAKER_01So what's the alternative?

SPEAKER_02Written feedback. Instead of reporting a wrong label, the evaluator says, this customer asked for a refund on an order bought with a promo code. The agent chose billing because the ticket mentions payment, but refunds belong in returns. From that sentence, an LLM can propose a targeted instruction. Classify refund requests as returns, including those with promotional codes.

SPEAKER_01That is much more useful than a number.

SPEAKER_02And it connects to something familiar. In neural network training, a gradient tells the parameters how to change to reduce an error. Prompts are text, so there is no tiny step between the word billing and the word returns. But a written critique can say what should change and why. That is why researchers call it a textual gradient.

SPEAKER_01Okay, I like the analogy, but I want to push on it. A real gradient is precise. A paragraph of LLM opinion sounds like a vibe.

SPEAKER_02Fair, and the article is honest about that. The quality of the feedback decides everything. A vague critique gives you a vague update. A good critique tied to the actual failure gives you a targeted fix. Keep that in mind because it comes back at the end.

SPEAKER_01Noted. So the first method.

SPEAKER_02Textgrad, from Stanford, published in Nature. Its design deliberately resembles PyTorch. Your AI system becomes a graph. Pieces of text, like the system prompt, the user input, and the intermediate outputs are the nodes, and the LLM calls connect them. Any text you want to improve is marked as trainable.

SPEAKER_01So for our support agent, the trainable thing is the system prompt.

SPEAKER_02Yes, then it mimics training. Run the system forward. Evaluate the output with an LLM judge or a test. Send the feedback backward through the graph, where an LLM explains how each piece contributed to the error. Finally, another LLM rewrites the trainable text using that explanation.

SPEAKER_01Forward, loss, backward, update. Same rhythm as training a network, except everything is words.

SPEAKER_02Precisely. In our example, the backward step concludes that the instructions never say how to classify refunds with promo codes, and the update adds a rule for it. I will not unpack the full mechanics here. The article walks through each step with a figure, so that is the place for the details.

SPEAKER_01Does it actually work, or is it just elegant?

SPEAKER_02The results are real but modest, and they come in two flavors. Instance optimization improves one output. You critique and rewrite the answer to one refund ticket until it is right, and the next ticket starts from zero. Prompt optimization updates the shared instructions, so every future refund ticket benefits. The paper reports gains for both. For example, GPT-40 on a graduate-level science benchmark went from 51% to 55%.

SPEAKER_01Four points. That is not exactly a revolution.

SPEAKER_02Ha! No, and the article is careful here. The most prominent results concern improving individual outputs, not reusable prompts. There are two limitations. The search is greedy, meaning it keeps improving the current candidate without holding on to diverse alternatives. And it is costly, since each iteration needs several LLM calls.

SPEAKER_01Greedy sounds like the thing that gets stuck on a hill that is not the tallest.

SPEAKER_02That is exactly the worry, and it leads straight to the second method. What if the optimizer explored several promising prompts at once?

SPEAKER_01Which is JIPA.

SPEAKER_02JIPA, which stands for Genetic Peridot, from UC Berkeley, Stanford, and Databricks. It looks at execution traces, inputs, intermediate outputs, tool calls, tool results, errors. That is far richer than a score, because the model can see where things went wrong.

SPEAKER_01And the genetic part?

SPEAKER_02JIPA keeps a population of candidate prompts. It picks one, runs it on a small batch of examples, reads the traces, and asks an LLM to reflect and write an improved version. If the child beats its parent, it gets validated on separate examples and joins the pool. It can also merge complementary improvements from different candidates. So it feels evolutionary, except the mutations are not random. They come from reflection.

SPEAKER_01Smart mutations, fine. But why a Pareto front? Why not keep the best average prompt?

SPEAKER_02Here is the intuition. Prompt A is excellent on promo code refunds. Prompt B is better on damaged item claims. If you only keep the highest average, you may throw away a specialist that carries a useful idea. JIPA keeps every candidate that is the best at something, so strengths can be refined or combined.

SPEAKER_01Process of elimination would have killed the specialists.

SPEAKER_02Right, and that broader search helps avoid local optima, those solutions that look good but are not the best overall.

SPEAKER_01Okay, numbers. Is it better than the heavy machinery of reinforcement learning?

SPEAKER_02As the author's report, across six tasks, it beat the reinforcement learning method by six points on average, up to 19, with up to 35 times fewer rollouts. It also beat an earlier prompt optimizer by more than 10 points in reported comparisons, with prompts up to 9.2 times shorter.

SPEAKER_01I want to believe that, but I have seen plenty of papers where the baseline is conveniently weak.

SPEAKER_02Healthy skepticism. And the article keeps it. The reinforcement learning method still one-on-one math benchmark, and performance depends on the task, the model, and the evaluation setup. A separate study reported similar rankings, with GPA ahead of TexGrad. So the ordering holds up to treat the exact numbers as indicative. The full results are laid out in the article.

SPEAKER_01Fine. So offline optimization, TexGrad, or GPA sounds great. Where does it break?

SPEAKER_02The article lists four problems. First, evaluation quality. If your metric is poor, your updates will be poor. Second, the reflection model matters. In experiments by a customer support AI company, smaller models failed at prompt optimization, while every frontier model they tested succeeded.

SPEAKER_01Interesting. You cannot cheap out on the optimizer.

SPEAKER_02Third, and this one surprised me. More data does not always help. In the same experiments, growing the training set from 50 to 500 samples made the prompt 75% longer, and performance fell. The prompt overfit by piling on special cases.

SPEAKER_01So more data made it worse. That feels backwards.

SPEAKER_02It does. A 2026 study adds that on mixed tasks, different examples favor different prompts, and training on a small, informative subset beat, using everything. And the fourth problem is the big one. Once deployed, an optimized prompt is frozen. If user behavior or business policy changes, you run another cycle.

SPEAKER_01Which brings us back to your opening, the agent that decays after a month.

SPEAKER_02Yes. Offline methods learn from historical data, but they do not learn from what happens in production. That is where ACE comes in.

SPEAKER_01Wait. Why not the obvious thing? After every task, let an LLM rewrite the prompt or memory with the new lesson.

SPEAKER_02People have tried exactly that. One approach called dynamic cheat sheet keeps a memory of strategies and updates it after each task. But the ACE authors found two failure modes. The first is brevity bias. LLMs love to summarize. So a precise rule like promo code refunds belong to returns slowly becomes classify refund requests carefully.

SPEAKER_01Which is useless.

SPEAKER_02Completely. The second is context collapse. Repeated rewriting can erase useful knowledge, sometimes in one update. On an agent benchmark, a memory of 18,282 tokens shrank to 122 tokens after a single rewrite. Accuracy dropped from 66.7% to 57.1%, below the 63.7% the agent had with no adaptation at all.

SPEAKER_01Wow. So the learning made it worse than not learning.

SPEAKER_02That is the trade-off. Short prompts can be efficient, as Gpa showed, but excessive summarization throws away lessons.

SPEAKER_01So how does ACE avoid it?

SPEAKER_02It treats the context as a living playbook and never rewrites the whole thing. Each entry holds one reusable lesson, an identifier, and counters tracking how often it proved helpful or harmful. Updates are small, targeted edits.

SPEAKER_01So a notebook with a change log, not a document that gets rewritten from scratch.

SPEAKER_02Nicely put. Three roles split the work. The generator does the task with the current playbook. The reflector analyzes what happened and extracts lessons. The curator turns those lessons into small updates and plain deterministic code applies them, so unrelated entries stay untouched.

SPEAKER_01In our example, one misclassified refund becomes one new entry.

SPEAKER_02Exactly. Everything else in the playbook stays as it was. A refinement step also removes redundant entries, so duplicates do not pile up. I will not go through the entry format here. The article has a figure for it, and the second article in the series builds a concrete implementation. Its code is for paid subscribers.

SPEAKER_01Can it learn without labels? In production, nobody labels my tickets.

SPEAKER_02Yes. It can use execution feedback, such as a tool error or code that fails to run. For the support agent, signals like tool errors or reopen tickets could hint at problems. But the article is careful. They do not always mean the answer was wrong.

SPEAKER_01Which is where I get nervous. Bad feedback into a system that rewrites its own instructions.

SPEAKER_02You should. The article reports a case where online adaptation without labels reduced accuracy on a financial benchmark from 70.7% to 67.3%. Longer playbooks also cost more tokens. And there is a security angle. A 2026 study found that attacks on the feedback going into prompt optimizers raised attack success rates by up to 0.48%.

SPEAKER_01So someone could poison the feedback and your agent learns the wrong lessons.

SPEAKER_02That is the risk. On the positive side, ACE beat the earlier memory approach on both an agent benchmark and financial tasks, and in offline mode it reached 81.9% average accuracy Strong results, with the caveat that the feedback has - So who wins?

SPEAKER_01TexGrad, JIPA or ACE?

SPEAKER_02The article's answer is that they complement each other. TextGrad suits refining complex outputs and multi-step pipelines. JIPA suits tasks with a clear, measurable success criterion and an evaluation dataset. ACE suits agents doing recurring tasks in a changing environment. In production, JIPA can periodically optimize the base prompt while an ACE-style playbook accumulates lessons in between.

SPEAKER_01And what stops one bad update from wrecking everything?

SPEAKER_02Two guardrails. Evaluation gates, meaning a check against a fixed test set before any change goes live, and versioning, so you can roll back when an update causes problems.

SPEAKER_01Okay, last one, and it is practical. Monday morning, I want to try this on my own agent. Where do I start?

SPEAKER_02Start with the feedback, not the optimizer. All three methods depend on how good the evaluation is. So build a reliable evaluation first and add a fixed test set as a gate and versioning for rollback. Then pick the method that matches your situation, JIPA if you have a data set and clear metrics, and A-style playbook if the environment keeps changing.

SPEAKER_01Simple enough. And where do people go deeper?

SPEAKER_02The full article is on Substack, at AIpractitioner.substack.com, with the figures, the experiments, and all the references. The second article in the series covers a concrete implementation. One last thought. We spent years treating the prompt as something we write once and ship. These methods suggest it is closer to a living asset, and the real engineering work is making sure it learns from the right feedback. [music]

Open the transcript file

Hosts and Guests

Nobody is credited on this episode yet.

Credit the people on this episode

Be the first to rate this episode

More episodes

All episodes
  1. PODCAST — Beyond Static Prompts: Building Self-Improving LLM Agents with ACE

    Nov 19, 202611 minAudio

    Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. What if AI agents could learn from every interaction...

    Credit the people on this episode

  2. PODCAST — Inside GEPA: Evolving LLM Agent Prompts with Reflective Feedback

    Nov 11, 202611 minAudio

    Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. What if AI agents could continuously improve their...

    Credit the people on this episode

  3. PODCAST — Continuously Optimizing AI Agent Prompts in Production

    Oct 28, 202615 minAudio

    Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. What if the key to better AI agents isn’t writing...

    Credit the people on this episode

  4. PODCAST — From Prompt Engineering to Harness Engineering: Where the Real Leverage Moved

    Oct 16, 202613 minAudio

    Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. What if improving an AI agent’s performance had less...

    Credit the people on this episode

  5. PODCAST — GraphRAG vs. Vector RAG: Better Retrieval or Expensive Overengineering?

    Sep 23, 202613 minAudio

    Prefer reading instead? The full article is available here. The podcast is also available on Spotify and Apple Podcasts. Subscribe to keep up with the latest drops. Standard RAG works well when the answer is contained...

    Credit the people on this episode