Enforce explicit chat-template kwarg allowlists - #126
Merged
Conversation
hallerite
marked this pull request as ready for review
August 11, 2026 22:23
ApprovabilityVerdict: Approved 82bff80 This PR adds explicit kwarg validation and field classification to renderer configs - a guardrails/type-safety improvement that makes the system more restrictive rather than enabling new behavior. Changes are self-contained, well-tested, and the author has prior contributions to these files. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
hallerite
force-pushed
the
codex/template-kwarg-contract
branch
from
August 12, 2026 18:10
82bff80 to
fd260d5
Compare
stack merge was automatically disabled
August 12, 2026 18:34
Pull Request is not mergeable
stack merge was automatically disabled
August 12, 2026 18:45
Pull Request is not mergeable
hallerite
force-pushed
the
codex/template-kwarg-contract
branch
from
August 12, 2026 18:46
fd260d5 to
8d5965a
Compare
hallerite
force-pushed
the
codex/template-kwarg-contract
branch
from
August 12, 2026 18:46
8d5965a to
635d351
Compare
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.
Summary
Introduces an explicit, positive allowlist for the chat-template kwargs accepted by every model-specific renderer.
This PR is stacked on #103. Merge #123, then #103, then this PR.
Changes
chat_template_kwargsrejects unknown, shared, and renderer-internal fields with an error that lists the allowed names.DefaultRendererremains open to opaque Jinja kwargs while reserving its typed config fields.Impact
This closes a validation hole where fields such as
image_cache_maxcould be supplied throughchat_template_kwargseven though they are not Jinja template inputs.Verification
644 passed, 4 skippedin the config and chat-template kwarg parity suitesNote
Enforce explicit chat-template kwarg allowlists and add InklingRenderer with multimodal support
_template_fieldsand_allow_opaque_template_kwargstoBaseRendererConfig, requiring every renderer config subclass to explicitly classify its fields; unclassified fields raiseTypeErrorat import time._merge_chat_template_kwargsin renderers/base.py to validatechat_template_kwargsagainst each config's declared allowlist, raisingValueErrorfor unknown or renderer-internal keys.InklingRendererandInklingRendererConfigin renderers/inkling.py supporting image and audio multimodal content, tool declaration/invocation,reasoning_effortcontrol, thinking retention, andbridge_to_next_turn.parse_inklingin renderers/parsing.py to decode Inkling model outputs into structuredParsedResponseobjects including reasoning content and tool calls.chat_template_kwargsto typed renderers now raisesValueErrorinstead of silently merging.Macroscope summarized 8d5965a.
Note
Medium Risk
Changes how invalid
chat_template_kwargsfail (oftenValueErrorat merge time instead of pydanticValidationError), which may break callers that relied on passing internal fields through kwargs; behavior for valid configs is stricter and more explicit.Overview
Enforces explicit allowlists for
chat_template_kwargsso renderer-internal options (e.g.image_cache_max,tool_parser) can’t be smuggled in as if they were Jinja template knobs.Each renderer config now declares
_template_fieldsand_internal_fields;template_field_names()returns only the template set.__pydantic_init_subclass__fails at class definition time if any field is missing, duplicated, or unknown in that split._merge_chat_template_kwargschecks incoming keys against that allowlist and raisesValueErrorwith allowed names; renderer-only fields must go on the typed config.DefaultRendererConfigkeeps_allow_opaque_template_kwargsfor arbitrary Jinja extras but still blocks typed fields liketool_parserfrom the kwargs map.README and
docs/renderer-config.mddescribe the new contract; tests cover allowlist validation, internal-field rejection, and default-renderer open-ended vs reserved behavior.Reviewed by Cursor Bugbot for commit 635d351. Bugbot is set up for automated code reviews on this repo. Configure here.