agent_loop_malformed_promptTier 1 · 70% confidence
ai-agents-agent-loop-malformed-agent-runs-indefinitely-with-invalid-format-missin-58b82c43
agent: ai_agents
When does this happen?
IF Agent runs indefinitely with 'Invalid Format: Missing Action:' after 'Thought:' when using custom format instructions in LangChain's zero-shot-react-description agent.
How others solved it
THEN Adjust the custom format instructions to include the standard tokens: 'Action:' for tool calls and 'Final Answer:' for the final response. For the zero-shot-react-description agent, the required format is: 'Thought: ... \nAction: <tool_name>\nAction Input: <input>' followed by 'Observation:' and then 'Thought: I now know the final answer\nFinal Answer: <answer>'. Avoid using non‑standard action names like 'Action: return AgentFinish.' as they are not recognized by the parser.
Use the default format_instructions from the agent class or replicate the standard template:
```
Answer the following questions as best you can. You have access to the following tools:
{tools}
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
```Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.