Skip to content

feat: support Jinja2 template expressions in agent model field#33

Merged
jrob5756 merged 1 commit intomicrosoft:mainfrom
Shazwazza:feat/template-model
Mar 11, 2026
Merged

feat: support Jinja2 template expressions in agent model field#33
jrob5756 merged 1 commit intomicrosoft:mainfrom
Shazwazza:feat/template-model

Conversation

@Shazwazza
Copy link
Copy Markdown
Contributor

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

  • src/conductor/executor/agent.py — Render model field in AgentExecutor.execute() when {{ or {% is detected. Uses model_copy() to avoid mutating the original AgentDef.
  • src/conductor/config/schema.py — Update AgentDef.model docstring to document template support.
  • tests/test_executor/test_agent.py — Add 3 tests: template rendering, static passthrough, non-mutation of original.

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.

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-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@99b09ba). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrob5756 jrob5756 merged commit 391ddaf into microsoft:main Mar 11, 2026
7 checks passed
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.

3 participants