Skip to content

Clean up dead code and fragile variable reference in LlamafileClient#73

Open
hobostay wants to merge 1 commit into
antoinezambelli:mainfrom
hobostay:fix/dead-code-cleanup
Open

Clean up dead code and fragile variable reference in LlamafileClient#73
hobostay wants to merge 1 commit into
antoinezambelli:mainfrom
hobostay:fix/dead-code-cleanup

Conversation

@hobostay
Copy link
Copy Markdown

Summary

Two cleanups in LlamafileClient:

  1. Remove redundant or None: In _resolve_reasoning, line 241 has return accumulated_content or None inside a block already guarded by if accumulated_content:. Since accumulated_content is guaranteed truthy at this point, the or None is dead logic that can never evaluate to None.

  2. Replace fragile part reference with explicit bad_raw: In send_stream tool call parsing, the error fallback referenced part (the loop variable). This happened to be correct due to the break statement, but any future refactoring that removed or moved the break would silently reference the wrong tool call's arguments. Use an explicit bad_raw variable to capture the failing args at the point of failure.

Test plan

  • Verify LlamafileClient streaming still works correctly
  • Verify reasoning extraction still works
  • Run existing test suite

🤖 Generated with Claude Code

1. Remove redundant `or None` in _resolve_reasoning: the code is
   already inside `if accumulated_content:` so the value is guaranteed
   truthy — `or None` is dead logic that can never evaluate to None.

2. Replace fragile `part` reference with explicit `bad_raw` variable
   in send_stream tool call parsing. The `part` variable referenced
   the last iterated loop entry, which happened to be correct due to
   the `break` statement, but was fragile — any future refactoring
   of the loop body that removed or moved the break would silently
   reference the wrong tool call's arguments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant