Skip to content

Address waybarrios review on PR #132#1

Open
janhilgard wants to merge 1 commit into0age:mainfrom
janhilgard:fix/pr132-review-fixes
Open

Address waybarrios review on PR #132#1
janhilgard wants to merge 1 commit into0age:mainfrom
janhilgard:fix/pr132-review-fixes

Conversation

@janhilgard
Copy link
Copy Markdown

Summary

Implements the 6 review fixes requested by @waybarrios on waybarrios#132:

  • Fix 1 (BUG): Cap carry buffer at MAX_TAG * 2 to prevent unbounded growth when > never arrives for a prefix tag like <function=...>
  • Fix 2 (BUG): Strip partial prefix tags (<function=name, <parameter=name) at end of stream in flush() using $-anchored regex
  • Fix 3 (CODE QUALITY): Move import re to module level, remove both inline imports from flush() methods
  • Fix 4 (DEAD CODE): Remove unused _implicit_think attribute from _AnthropicStreamRouter.__init__()
  • Fix 5 (DESIGN): Add IN_PARAMETER state so standalone <parameter=name> closes on </parameter> instead of swallowing text until </function>
  • Fix 6 (DESIGN): Add comment explaining why start_in_thinking=True is correct for current models (Qwen3/3.5 chat templates inject <think>)

Test plan

  • All 128 existing + new tests pass (pytest tests/test_anthropic_stream_scrubber.py -v)
  • New tests cover: unbounded carry buffer, partial prefix flush, standalone <parameter=...>, dead code removal
  • black formatting verified

🤖 Generated with Claude Code

…code

- Fix 1: Cap carry buffer at MAX_TAG*2 to prevent unbounded growth when
  '>' never arrives for a prefix tag like <function=...>.
- Fix 2: Strip partial prefix tags (<function=name, <parameter=name)
  at end of stream in flush() using regex anchored to $.
- Fix 3: Move `import re` to module level, remove inline imports.
- Fix 4: Remove dead `_implicit_think` attribute from Router.__init__().
- Fix 5: Add IN_PARAMETER state so standalone <parameter=name> closes
  on </parameter> instead of swallowing text until </function>.
- Fix 6: Add comment explaining why start_in_thinking=True is correct
  for current models (Qwen3/3.5 chat templates inject <think>).

Co-Authored-By: Claude Opus 4.6 <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