The agent was executing successfully but hitting the iteration limit before completing all tool calls and returning the Final Answer.
Error in logs:
"Invalid or incomplete response"
"No JSON object found in output: Agent stopped due to iteration limit or time limit."
The ReAct agent format counts each Thought-Action-Observation cycle as one iteration:
- Thought: I need to parse the resume
- Action: resume_parser (iteration 1)
- Observation: Resume data
- Thought: Now extract skills
- Action: skill_extractor (iteration 2)
- Observation: Skills data ... and so on
With 6 tools to call + final answer, the agent needs at least 12-15 iterations, but was limited to 10 iterations.
File: backend/app/services/agents/resume_agent_service.py
Method: _execute_agent_analysis()
Changes:
# BEFORE:
agent = ResumeIntelligenceAgent(
max_iterations=10, # Too low!
max_execution_time=20.0, # Too short!
verbose=True
)
# AFTER:
agent = ResumeIntelligenceAgent(
max_iterations=30, # Increased to allow all tools
max_execution_time=60.0, # Increased to 60 seconds
verbose=True
)- max_iterations=30: Allows for 6 tool calls × 2 iterations each + buffer for final answer
- max_execution_time=60.0: Gives LLM enough time to process each tool call (HuggingFace API can be slow)
- Agent executes all 6 tools without hitting iteration limit
- Agent calls analysis_formatter as final step
- Agent returns valid JSON in Final Answer
- JSON validation succeeds
- Analysis stored with status =
success - Frontend displays AI-generated analysis
- Restart backend
- Upload resume
- Check backend logs for:
- "Agent initialized with 6 tools, max_iterations=30, max_execution_time=60.0s"
- All 6 tools executing successfully
- "Agent output successfully validated and parsed"
- Check database: status should be
success - Frontend should display AI analysis (not loading spinner)
The frontend shows "Analysis in progress" for 2+ minutes because:
- Agent execution takes ~26 seconds (as seen in logs)
- Frontend polls for results every few seconds
- Until analysis is complete and stored, it returns 404
- Once analysis is stored, frontend displays it
This is normal behavior. The fix ensures the analysis completes successfully.
backend/app/services/agents/resume_agent_service.py_execute_agent_analysis()- Increased max_iterations and max_execution_time