feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · ValueError
Could not extract section name from the response.
Error message
Could not extract section name from the response.
What it means
answer_question_textual_wide_range asks the LLM which resume section a question belongs to, then regex-matches the reply against a fixed list (Personal Info, Skills, Education, Experience Details, Projects, Availability, Salary Expectations, Certifications, Languages, Interests, Cover letter). If the model's free-text answer contains none of these keywords, the section cannot be determined and a ValueError is raised.
Source
Thrown at src/libs/llm_manager.py:573
LANGUAGES: self._create_chain(prompts.languages_template),
INTERESTS: self._create_chain(prompts.interests_template),
COVER_LETTER: self._create_chain(prompts.coverletter_template),
}
prompt = ChatPromptTemplate.from_template(prompts.determine_section_template)
chain = prompt | self.llm_cheap | StrOutputParser()
raw_output = chain.invoke({QUESTION: question})
output = self._clean_llm_output(raw_output)
match = re.search(
r"(Personal information|Self Identification|Legal Authorization|Work Preferences|Education "
r"Details|Experience Details|Projects|Availability|Salary "
r"Expectations|Certifications|Languages|Interests|Cover letter)",
output,
re.IGNORECASE,
)
if not match:
raise ValueError("Could not extract section name from the response.")
section_name = match.group(1).lower().replace(" ", "_")
if section_name == "cover_letter":
chain = chains.get(section_name)
raw_output = chain.invoke(
{
RESUME: self.resume,
JOB_DESCRIPTION: self.job_description,
COMPANY: self.job.company,
}
)
output = self._clean_llm_output(raw_output)
logger.debug(f"Cover letter generated: {output}")
return output
resume_section = getattr(self.resume, section_name, None) or getattr(
self.job_application_profile, section_name, None
)View on GitHub (pinned to 79155b52fa)
Solutions
- Retry the call: non-deterministic LLM output often matches on a second attempt.
- Use a more instruction-following model (or lower temperature) for this chain so the reply names a valid section.
- Extend the regex alternation in the prompt/validation to cover additional section names your resumes use.
Example fix
// before
answer = llm_manager.answer_question_textual_wide_range(q)
// after
for _ in range(3):
try:
answer = llm_manager.answer_question_textual_wide_range(q)
break
except ValueError:
continue # LLM reply didn't name a recognizable section Defensive patterns
Strategy: retry
Try / catch
for attempt in range(3):
try:
return llm_manager.answer_question_textual_wide_range(question)
except ValueError as e:
if 'Could not extract section' not in str(e):
raise
logger.warning('Section classification failed for: %s', question) Prevention
- Use an instruction-following model for the classification chain and keep temperature low.
- Pre-test your model choice against the fixed section list with sample screening questions.
When it happens
Trigger: The LLM answers a screening question with wording that does not include any of the recognized section names (hallucinated or off-script reply), or the question is about something outside the enumerated sections.
Common situations: Flaky/creative LLM outputs, changing to a cheaper or different model that ignores instructions, prompt template changes, or non-English model responses.
Related errors
- No numbers found in the string
- Unsupported model type: {llm_model_type}
- Section '{section_name}' not found in either resume or job_a
- Chain not defined for section '{section_name}'
- Failed to get a response from the model after multiple attem
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/65746c2ae15927d8.
Report an issue: GitHub.