Skip to content

Update and Modernization for Qwen3 Coder Next#2

Open
eleqtrizit wants to merge 13 commits intoflorath:masterfrom
eleqtrizit:master
Open

Update and Modernization for Qwen3 Coder Next#2
eleqtrizit wants to merge 13 commits intoflorath:masterfrom
eleqtrizit:master

Conversation

@eleqtrizit
Copy link
Copy Markdown

PR: Qwen3 Call Patch Proxy — Hardening, CLI, Observability & Test Coverage

Now Installable as a Tool

The proxy is now packaged and installable via uv, uvx, or pip — no manual setup required.

(change the URLs below if merged)

Run without installing (uvx):

uvx git+https://github.com/eleqtrizit/qwen3-call-patch-proxy

Install globally (uv):

uv tool install git+https://github.com/eleqtrizit/qwen3-call-patch-proxy

Install via pip:

pip install git+https://github.com/eleqtrizit/qwen3-call-patch-proxy

Once installed, run the proxy with:

qwen3-call-patch-proxy [--host HOST] [--port PORT] [--target-url URL] [--verbose]

Summary

This PR covers 12 commits of improvements since 3b411310, spanning build system modernization, CLI ergonomics, proxy robustness, observability, and a major test suite overhaul.


Changes

Build System Modernization

  • Removed legacy install.sh, requirements.txt, and setup.py.
  • Migrated entirely to Hatchling via pyproject.toml with uv lockfile (uv.lock).
  • Consolidated documentation: removed docs/detailed-guide.md, replaced with top-level DETAILED_GUIDE.md (340 lines covering architecture, configuration, fix rules, and installation).
  • Added pytest, pytest-asyncio, and pytest-cov as test dependencies in pyproject.toml.

CLI & Configuration

  • argparse support (ae6e03d): The main() function now accepts --target-url, --host, and --port arguments with sensible defaults, replacing hardcoded values.
  • DEFAULT_ prefix (dc02a89): All configuration constants renamed with DEFAULT_ prefix for clarity.
  • --verbose flag (eca6265): New CLI option to enable detailed SSE stream logging. Request/response details and elapsed time are logged when verbose mode is active.
  • __main__.py (751094d): Added module entry point enabling python -m qwen3_call_patch_proxy execution.

Proxy Robustness

  • Duplicate tool call detection (6d6d0fa): The proxy now detects and warns when the same tool call (by function name + arguments) is emitted more than once in a stream, preventing downstream double-execution.
  • Incomplete JSON buffering (6d6d0fa): Fragmented JSON content is merged into a shared buffer and retried, rather than being dropped.
  • Malformed trailing duplicate key recovery (38719e2): New helper function strips trailing duplicate keys (a pattern where a key appears again without a colon), added as an additional JSON recovery strategy.
  • Improved logging (dc02a89, eca6265): Console and file log formats updated for readability; request lifecycle (start, proxied, elapsed) is now traceable.

Documentation

  • DETAILED_GUIDE.md (bfa023d, 41b7546): Comprehensive guide covering proxy architecture, fix rule YAML schema, all configuration options, and step-by-step installation for both uv/uvx and pip workflows.
  • README.md (74ca95e, 41b7546, 7f623a1): Updated repository URL, reordered installation methods, added full CLI argument reference table, added Qwen/Qwen3-Coder-Next-GGUF:Q8_0 to the tested models list.

Test Suite

  • test_coverage_boost.py (983259d): 1,644-line new test file targeting previously uncovered code paths, pushing statement coverage toward 85%+.
  • Assertion migration (983259d): All existing test files refactored — print statements replaced with assert statements for proper test validation across 22 test files.
  • test_glob_debug.py (27b1fd8): Debug script simulating SSE tool call event streams (complete, fragmented, and malformed JSON cases) for manual and automated proxy validation.
  • Coverage baseline: coverage.json added tracking 52% statement coverage as the starting baseline before test_coverage_boost.py improvements.

Stats

Metric Value
Commits 12
Files changed 37
Insertions +4,529
Deletions -1,299
Test files added/updated 24
Coverage baseline (pre-boost) 52%

- Introduced DETAILED_GUIDE.md to provide comprehensive documentation on the proxy's functionality, architecture, installation, configuration, and fix rules.
- Removed the install.sh script and requirements.txt as part of the transition to a new installation method using Hatchling.
- Updated pyproject.toml to reflect changes in build system and dependencies.
- Refactored README.md to link to the new detailed guide and clarify installation instructions.

This commit enhances user experience by centralizing documentation and streamlining installation processes.
- Introduced argparse to allow configuration of target URL, host, and port for the Qwen3 Call Patch Proxy.
- Updated logging to reflect the specified host and port during server startup.

This enhancement improves flexibility in server configuration and usability.
- Updated configuration constants to use DEFAULT_ prefix for clarity.
- Improved logging format for console and file handlers for better readability.
- Added whitespace for improved code structure and readability.

These changes enhance the maintainability of the code and improve the clarity of log outputs.
- Introduced a `--verbose` command-line argument to enable detailed logging of SSE stream responses.
- Enhanced logging within the `handle_request` function to include request and response details, including elapsed time for requests.
- Updated application initialization to store the verbose setting for use in logging.

These changes improve the observability of the proxy's operations and provide better insights during debugging.
…tion clarity

- Revised the Table of Contents in DETAILED_GUIDE.md for better organization.
- Streamlined installation instructions in README.md, swapping the order of `uv` and `uvx` methods for clarity.
- Enhanced the configuration section in README.md to include detailed command-line arguments and their defaults.

These updates improve the documentation's usability and ensure users have clear guidance on installation and configuration options.
- Introduced a new `__main__.py` file to serve as the entry point for the application.
- The main function from the `qwen3_call_patch_proxy` module is called when the script is executed.

This addition enables direct execution of the proxy, improving usability for users running the application.
- Introduced a mechanism to detect and warn about duplicate tool calls based on function name and arguments.
- Enhanced the handling of incomplete JSON content by merging it into a shared buffer for later processing.
- Improved logging to provide clearer insights into tool call processing and recovery attempts.

These changes enhance the robustness of the tool call handling and improve observability during execution.
- Introduced `test_glob_debug.py` to simulate various scenarios of SSE tool call events, including complete, fragmented, and malformed JSON cases.
- Implemented multiple test scenarios to validate the behavior of the proxy when handling tool calls, ensuring robustness in processing and recovery.
- The script serves as a mock backend to facilitate testing and debugging of the Qwen3 Call Patch Proxy.

This addition enhances testing capabilities and improves the reliability of tool call handling in the application.
- Introduced a new helper function to strip malformed trailing duplicate keys from JSON strings, addressing cases where a key is followed by a value without a colon.
- Updated the recovery attempts list to include this new function, enhancing the robustness of JSON handling in the proxy.
- Added `Qwen/Qwen3-Coder-Next-GGUF:Q8_0` to the list of models in the README, enhancing the documentation by providing users with additional resources for tool calls.
- Introduced a new `coverage.json` file to track code coverage metrics, aiming to boost coverage from 52% to over 85%.
- Updated `pyproject.toml` to include necessary dependencies for testing, such as `pytest`, `pytest-asyncio`, and `pytest-cov`.
- Refactored existing test cases to utilize assertions for better clarity and reliability, replacing print statements with assert statements.
- Added comprehensive tests targeting previously uncovered code paths, enhancing the robustness of the test suite and ensuring better validation of tool call handling.

These changes significantly improve the testing framework and code quality, providing a solid foundation for future development and maintenance.
- Replaced specific model references with broader categories: `Qwen3 models` and `Qwen3.5 models`, simplifying the documentation and making it more inclusive for users exploring available models.
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