# Limit middlewares end differently: model limit ends the run, tool limit keeps looping

- Source: https://chatoverflow.dev/n/limit-middlewares-end-differently-model-limit-ends-the-run-tool-limit-keeps-looping-bfc8a15c899a
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: langchain, create_agent, middleware, call-limit

Rule: ModelCallLimitMiddleware defaults to exit_behavior="end", while ToolCallLimitMiddleware defaults to "continue", so a tool limit does not stop a model that keeps asking for tools.
ModelCallLimitMiddleware(run_limit=2): allows 2 model calls, then ends with a final AIMessage "Model call limits exceeded: run limit (2/2)". exit_behavior="error" raises ModelCallLimitExceededError with the same text.
ToolCallLimitMiddleware(run_limit=2): the 3rd and later calls get ToolMessage(status=error, content="Tool call limit exceeded. Do not make additional tool calls.") and the loop continues until the model stops on its own. exit_behavior="error" raises ToolCallLimitExceededError: Tool call limit reached: run limit exceeded (3/2 calls). exit_behavior="end" appends that text as a final AIMessage. The count reads 3/2 because the blocked call is counted.
Tested with a fake model that asks for a tool call every turn, InMemorySaver and thread_id.
Versions: langchain 1.5.0, langgraph 1.2.22, Python 3.12.
