# Prevent last LLM call after tool calls

**URL:** <https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063>\
**Category:** LangChain\
**Tags:** python-help\
**Created:** [March 2, 2026, 6:13pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063 "2026-03-02T18:13:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric-burel](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/eric-burel/32/712_2.png) [@eric-burel](https://forum.langchain.com/u/eric-burel)\
**Post date:** [March 2, 2026, 6:13pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/1 "2026-03-02T18:13:17Z")

</div>

Hi folks,

In a `create_agent` loop, is it possible to prevent the very last LLM call to happen?  
For instance say that model wants to call tool 1, then tool 2 to solve an issue, with 2 rounds of the agentic loop.  
I’d like the agent to output the JSON of tool 2 but NOT feed it back to the LLM.  
Most of my “final” tool will output a comprehensive response that doesn’t need the final LLM interpretation and could be sent to user as is.  
I feel like the problem is that the agent loop termination is based on whether the LLM calls a tool or not, at least last time I’ve checked LangGraph react agent template.  
It might be more efficient to allow the model to output a termination boolean alongside the final tool call to stop the loop? Is that doable in LangChain without falling back to LangGraph?

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [March 2, 2026, 6:26pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/2 "2026-03-02T18:26:10Z")

</div>

hi @eric-burel

use `return_direct` prop of the `tool` decorator or `BaseTool` subclass [return\_direct | langchain\_core | LangChain Reference](https://reference.langchain.com/python/langchain-core/tools/base/BaseTool/return_direct)

---

<div class="post-metadata">

**Author:** ![eric-burel](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/eric-burel/32/712_2.png) [@eric-burel](https://forum.langchain.com/u/eric-burel)\
**Post date:** [March 2, 2026, 6:37pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/3 "2026-03-02T18:37:25Z")

</div>

Interesting, it’s a step forward but that means that you need to define some tools that are specifically considered as “end tools” that kills the agent loop. That works for certain use case but I really feel like the agent loop itself is not 100% efficient, I wonder if some model provider do output this kind of “done” flag.

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [March 2, 2026, 6:39pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/4 "2026-03-02T18:39:49Z")

</div>

do you build with custom state graph, or `create_agent`/`create_deep_agent`?

---

<div class="post-metadata">

**Author:** ![eric-burel](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/eric-burel/32/712_2.png) [@eric-burel](https://forum.langchain.com/u/eric-burel)\
**Post date:** [March 2, 2026, 6:51pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/5 "2026-03-02T18:51:05Z")

</div>

I am looking for a `create_agent` solution, I suspect it would not be too hard to implement with a custom LangGraph graph (though there might be many gotchas) but I wonder about LangChain create\_agent which is newer to me.

---

<div class="post-metadata">

**Author:** ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)\
**Post date:** [March 2, 2026, 7:05pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/6 "2026-03-02T19:05:50Z")

</div>

then look at the middleware funability [Custom middleware - Docs by LangChain](https://docs.langchain.com/oss/python/langchain/middleware/custom) - you can control everything with this feature

---

<div class="post-metadata">

**Author:** ![eric-burel](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/eric-burel/32/712_2.png) [@eric-burel](https://forum.langchain.com/u/eric-burel)\
**Post date:** [March 13, 2026, 7:59am UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/7 "2026-03-13T07:59:18Z")

</div>

Yeah so after pouring more thoughts on it, I think what could work is differentiating a notion of “tool call” vs “tool trigger”. Not sure yet of the best implementation but it could rely on asking explicitly the LLM whether it needs to process the ToolMessage, or if we can skip it and just go ahead with displaying the result to the end user, by generating a “fake” AI message with the tool result in it. Could be done in before\_model perhaps.

---

<div class="post-metadata">

**Author:** ![eric-burel](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/eric-burel/32/712_2.png) [@eric-burel](https://forum.langchain.com/u/eric-burel)\
**Post date:** [March 16, 2026, 2:11pm UTC](https://forum.langchain.com/t/prevent-last-llm-call-after-tool-calls/3063/8 "2026-03-16T14:11:12Z")

</div>

Another idea borrowed from AI SDK stop conditions : implementing something similar to the [`hasToolCall`](https://ai-sdk.dev/docs/reference/ai-sdk-core/has-tool-call#hastoolcall) stopping condition + a special tool that I can intercept and treat as a special case, like a “shouldDisplayRawResult” tool. This way I let the agent pick whether the tool call should be “final” or not, using a special tool.
