Skip to content

Add renderer chat template kwargs passthrough#60

Open
eligotts wants to merge 5 commits into
mainfrom
feat/chat-template-kwargs-renderers
Open

Add renderer chat template kwargs passthrough#60
eligotts wants to merge 5 commits into
mainfrom
feat/chat-template-kwargs-renderers

Conversation

@eligotts
Copy link
Copy Markdown
Contributor

@eligotts eligotts commented May 23, 2026

Summary

  • Add chat_template_kwargs to create_renderer and create_renderer_pool.
  • Let DefaultRenderer forward arbitrary template kwargs, while model-specific renderers declare the kwargs they support and fail fast on unsupported keys.
  • Wire enable_thinking and reasoning_effort for the renderers that model those template controls.

We are extracting renderer template controls from chat_template_kwargs for now. Longer term, we should move this toward typed pydantic config models with explicit renderer-specific template args, so users cannot dump arbitrary keys into config. Until then, unsupported kwargs fail at renderer construction.

Companion PRs

Validation

  • uvx ruff check renderers/base.py renderers/qwen3.py renderers/qwen35.py renderers/nemotron3.py renderers/gpt_oss.py renderers/glm5.py renderers/glm45.py renderers/deepseek_v3.py renderers/kimi_k2.py renderers/kimi_k25.py renderers/laguna_xs2.py tests/test_chat_template_kwargs.py
  • PYTHONPATH=. uvx --with pytest --with transformers --with openai-harmony --with tiktoken --with numpy --with jinja2 --with fastokens --with openai pytest tests/test_chat_template_kwargs.py

Note

Add chat_template_kwargs passthrough to renderer constructors

  • Adds a chat_template_kwargs: dict[str, Any] | None parameter to create_renderer and create_renderer_pool in base.py, forwarding fixed template toggles (e.g. enable_thinking, reasoning_effort) directly to renderer constructors.
  • Each renderer class now declares a CHAT_TEMPLATE_KWARGS class attribute listing its supported keys; create_renderer validates against this set and raises ValueError for unsupported or reserved constructor kwargs.
  • Supported renderers updated: Qwen3, Qwen35, DeepSeekV3, GLM4.5, GLM5, GptOss, KimiK25, LagunaXS2, Nemotron3.
  • Behavioral Change: passing a key that overlaps with renderer constructor kwargs (e.g. tool_parser) inside chat_template_kwargs now raises ValueError instead of silently overriding constructor behavior.

Macroscope summarized b543277.


Note

Medium Risk
Moderate risk because it changes renderer construction and argument validation, which can break existing integrations that pass unexpected kwargs or rely on permissive behavior.

Overview
Adds a new chat_template_kwargs parameter to create_renderer and create_renderer_pool, binding chat-template controls at renderer construction time and forwarding them into DefaultRenderer/model-specific renderer constructors.

Introduces validation that (1) rejects reserved constructor kwargs inside chat_template_kwargs and (2) enforces per-renderer allowlists via each renderer’s new CHAT_TEMPLATE_KWARGS attribute (e.g. enable_thinking for several model renderers, reasoning_effort for gpt-oss), raising ValueError on unsupported keys; includes new unit tests and README documentation for the behavior.

Reviewed by Cursor Bugbot for commit b543277. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread renderers/base.py
@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented May 23, 2026

Approvability

Verdict: Approved

Additive feature adding an optional chat_template_kwargs parameter with proper validation to prevent misuse. Backwards compatible, well-tested, and self-contained with no impact to existing behavior.

You can customize Macroscope's approvability policy. Learn more.

Comment thread renderers/kimi_k2.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7fbf390. Configure here.

Comment thread tests/test_chat_template_kwargs.py
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