AE Agent Errors
AE-AFGNRN1C

Agent with structured response format loops on a failing SQL tool until the recursion limit

RETRY LOOPseverity: MEDIUMcause: UNKNOWNoutcome: UNKNOWNconfidence: LOW

A tool-calling agent built with create_agent and a response_format kept calling its SQL tool after the tool returned errors, then stopped with the recursion-limit error instead of terminating on its own. The project could not confirm that the loop is caused by the framework.

Framework / agent
LangGraph / LangChain · tool-calling ReAct-style agent (text-to-SQL)
Remediation attempts
SUGGESTEDSUGGESTED
Recurrence
not documented
Source languages
en
Updated
2026-09-30

Sources

Public sample: the full evidence record is free.

Symptoms

  • The agent repeatedly calls the same SQL tool after it returns an error REPORTED CLAIM
  • The run ends with a recursion-limit error without reaching a stop condition REPORTED CLAIM

Error messages (verbatim)

Recursion limit of 20 reached without hitting a stop condition

Context and trigger

Agent type
tool-calling ReAct-style agent (text-to-SQL)
Component
prebuilt agent loop (create_agent with response_format)
Framework
LangGraph / LangChain (langgraph 1.0.6)
Model
not stated
Task
text-to-SQL question answering
Tools
SQL query tool, metadata catalog tool
  • A tool keeps returning an error (here a SQL namespace error) and the agent retries it REPORTED CLAIM
  • response_format is set on the agent REPORTED CLAIM

Open questions

  • Whether the loop is caused by the framework or by the agent's tools/prompt was not established by the maintainers.
  • The proposed missing-edge fix targets create_react_agent; the report uses create_agent.

Root cause UNKNOWN

Not established by the sources.

no verified evidence about the cause

Remediation attempts (2)

SUGGESTEDtool_call_limitby maintainer

Maintainer recommendation: cap tool calls with the built-in tool-call-limit middleware (or custom middleware) instead of relying on the recursion limit.

Status basis: proposed; no evidence it was applied. Verification: not verified.

You can use tool call limit: https://docs.langchain.com/oss/python/langchain/middleware/built-in#tool-call-limitmaintainer · github.com/langchain-ai/langgraph
SUGGESTEDtermination_conditionby third_party

Proposed code change: add an explicit edge from the generate_structured_response node to END so the graph terminates after the structured response. Not merged.

Status basis: proposed; no evidence it was applied. Verification: not verified.

Change: https://github.com/langchain-ai/langgraph/pull/6733 · not merged

Excerpt of the change (libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py, MIT):

@@ -898,6 +898,8 @@ def should_continue(state: StateSchema) -> str | list[Send]:
                 agenerate_structured_response,
             ),
         )
+        # After generating structured response, the graph should end
+        workflow.add_edge("generate_structured_response", END)
         if post_model_hook is not None:
             post_model_hook_paths.append("generate_structured_response")
         else:
the `generate_structured_response` node is added to the graph but no outgoing edge to `END` is defined. This causes the graph to not terminate properly after generating the structured responsethird_party · github.com/langchain-ai/langgraph

Outcome outcome: UNKNOWN

no applied remediation documented

Recurrence

Not documented in the sources (absence of reports is not evidence of absence).

Confidence LOW

Cause or remediation is reported, but not confirmed by the affected project.

FactorPresentMeaning
first_party_evidenceyesa quote from the affected project/vendor (or a controlled test)
fix_appliednoa fix was merged/released
regression_testnotests changed with the fix
independent_confirmationnoreporter/maintainer/vendor confirmed the failure is gone
root_cause_verifiednocause stated by the project and addressed by the fix
reproduction_documentednosteps or conditions to reproduce were quoted
multiple_independent_sourcesno1 independent source group(s)
failed_attempts_documentednounsuccessful remediation recorded

All evidence (6 verified quotes)

Agent processing error: Recursion limit of 20 reached without hitting a stop condition. You can increase the limit by setting the `recursion_limit` config key.reporter · github.com/langchain-ai/langgraph
Databricks SQL query error: [REQUIRES_SINGLE_PART_NAMESPACE] spark_catalog requires a single-part namespace, but got `atlas_data`.`retail`. SQLSTATE: 42K05reporter · github.com/langchain-ai/langgraph
response_format=DatabricksQueryGenerationResponse, ).with_config(recursion_limit=self.settings.agent_recursion_limit)reporter · github.com/langchain-ai/langgraph
You can use tool call limit: https://docs.langchain.com/oss/python/langchain/middleware/built-in#tool-call-limitmaintainer · github.com/langchain-ai/langgraph
the `generate_structured_response` node is added to the graph but no outgoing edge to `END` is defined. This causes the graph to not terminate properly after generating the structured responsethird_party · github.com/langchain-ai/langgraph
it's unclear which part of it if any is due to langgraphmaintainer · github.com/langchain-ai/langgraph

Categories: RETRY LOOP TOOL FAILURECOST FAILURE · extraction curated, gate-2026-09-29-v1

Similarity to your system is not implied. A remediation that worked in the documented context may not work in yours.