fix(llm): remove duplicated _appears_truncated stub#782
Open
NightingaleCen wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a backend-breaking regression in apps/backend/app/llm.py where an incomplete duplicate _appears_truncated definition caused an IndentationError at import time, preventing the backend from starting.
Changes:
- Remove the stray
_appears_truncated(...)stub that leftFALLBACK_MAX_TOKENS = 4096incorrectly positioned and triggeredIndentationError. - Update the actual
_appears_truncatedimplementation to acceptschema_type: str = "resume"to match its internal logic and call sites.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Regression introduced by #775 (
fix(llm): resolve DeepSeek 500 / Failed to analyze resume (#706), commit4dda99f). No dedicated issue tracks this — the symptom isuv run appfailing immediately at import time with anIndentationError, so anyone onmaincannot start the backend at all.Description
app/llm.pyends up with two definitions of_appears_truncated, both broken, so the entire backend crashes at import time:Root cause (introduced by #775)
git blame upstream/main -- apps/backend/app/llm.pyshows the refactor in #775 was only partially applied:4dda99f, PR fix(llm): resolve DeepSeek 500 / Failed to analyze resume #775): a new schema-aware signaturedef _appears_truncated(data: dict, schema_type: str = "resume") -> bool:was inserted, immediately followed byFALLBACK_MAX_TOKENS = 4096->IndentationErrorat module load.d2567520, original): the original implementationdef _appears_truncated(data: dict) -> bool:was left in place. Its docstring was updated by fix(llm): resolve DeepSeek 500 / Failed to analyze resume #775, but its signature was not — soschema_typeis referenced inside the body without being a parameter, and the only call site_appears_truncated(result, schema_type)at L1098 (also added by fix(llm): resolve DeepSeek 500 / Failed to analyze resume #775) would have raisedNameError/TypeErroreven after fixing theIndentationError.In other words: the new signature was pasted on top, the function body was never moved, and the old definition was never deleted.
Type
Proposed Changes
app/llm.py:734(keepFALLBACK_MAX_TOKENS = 4096, whichget_safe_max_tokensdepends on).app/llm.py:782to use the schema-aware signaturedef _appears_truncated(data: dict, schema_type: str = "resume") -> bool:so it matches both its body and its callers.Screenshots / Code Snippets (if applicable)
Reproducer on
main:How to Test
uv run python -c "from app.llm import _appears_truncated; print('ok')"-> printsok(noIndentationError).uv run pytest tests/unit/test_llm.py::TestAppearsTruncated -q-> 13/13 passinguv run pytest -q-> 179 passing. One pre-existing failure unrelated to this PR remains.uv run app-> backend boots withoutIndentationError.Checklist
Additional Information
While verifying this fix locally I had to pin
python-dotenvback to1.0.1because1.2.2(the currentpyproject.tomlpin from #761) conflicts withlitellm's==1.0.1requirement, souv syncitself fails. The dependency fix is in #780.Summary by cubic
Fixes backend import crash by removing a duplicate
_appears_truncatedstub and aligning the function signature with callers. Restoresuv run appstartup by resolving the IndentationError._appears_truncateddefinition; keptFALLBACK_MAX_TOKENS = 4096._appears_truncatedtodef _appears_truncated(data: dict, schema_type: str = "resume") -> bool:to match usage.Written for commit 820dc37. Summary will update on new commits.