feat: support Jinja2 template expressions in agent model field#33
Merged
jrob5756 merged 1 commit intomicrosoft:mainfrom Mar 11, 2026
Merged
feat: support Jinja2 template expressions in agent model field#33jrob5756 merged 1 commit intomicrosoft:mainfrom
jrob5756 merged 1 commit intomicrosoft:mainfrom
Conversation
Add template rendering for the model: field in agent definitions,
enabling dynamic model selection via workflow inputs. Previously only
prompt, system_prompt, and when fields supported Jinja2; now
workflows can use expressions like:
model: "{{ workflow.input.selected_model }}"
The rendering is applied before provider execution using model_copy()
to avoid mutating the original AgentDef. Static model strings (without
template syntax) are passed through unchanged with zero overhead.
- Render model field in AgentExecutor.execute() when {{ or {% detected
- Update AgentDef.model docstring to document template support
- Add tests: template rendering, static passthrough, non-mutation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
=======================================
Coverage ? 86.63%
=======================================
Files ? 44
Lines ? 5905
Branches ? 0
=======================================
Hits ? 5116
Misses ? 789
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jrob5756
approved these changes
Mar 11, 2026
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.
Add Jinja2 template rendering for the model: field in agent definitions, enabling dynamic model selection via workflow inputs.
Previously only prompt, system_prompt, and when fields supported Jinja2 expressions. This extends that to model:, allowing workflows to parameterize which model each agent uses:
workflow:
inputs:
selected_model:
type: string
default: "claude-sonnet-4.6"
agents:
- name: reviewer
model: "{{ workflow.input.selected_model }}"
prompt: "Review this code..."
Changes
Motivation
Multi-agent workflows (e.g., PR review with multiple reviewer perspectives) benefit from letting users choose models at invocation time rather than hardcoding them. This enables A/B testing across models, cost optimization, and user preference without forking workflow
definitions.