Skip to content

feat(validate): catch template reference errors before runtime#125

Open
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
PolyphonyRequiem:feat/enhanced-validate
Open

feat(validate): catch template reference errors before runtime#125
PolyphonyRequiem wants to merge 1 commit intomicrosoft:mainfrom
PolyphonyRequiem:feat/enhanced-validate

Conversation

@PolyphonyRequiem
Copy link
Copy Markdown
Member

Summary

Enhanced conductor validate to catch Jinja2 template reference errors before runtime. Previously, conductor validate only checked YAML schema (Pydantic) — stale agent references, missing workflow inputs, and undeclared dependencies only surfaced at runtime after minutes of execution and real API costs.

What it catches

Errors (validation fails)

  • Stale agent references: {{ old_agent_name.output.field }} where old_agent_name doesn't exist
  • Missing workflow input references: {{ workflow.input.missing_field }} where missing_field isn't declared in input:
  • Stale references in script args, input_mapping, system_prompt: All template-bearing fields are scanned

Warnings (validation passes with notes)

  • Undeclared dependencies in explicit mode: Agent prompt references {{ a.output.val }} but doesn't declare a.output in its input: list

Example

agents:
  - name: writer
    prompt: |
      Based on {{ old_agent_name.output.findings }}
      Write about {{ workflow.input.nonexistent_field }}
$ conductor validate stale.yaml
╭─ Validation Failed ─╮
│ - agent 'writer' prompt references unknown agent 'old_agent_name'. Available: researcher, writer
│ - agent 'writer' prompt references unknown workflow input 'nonexistent_field'. Declared inputs: topic
╰──────────────────────╯

Changes

  • src/conductor/config/validator.py:
    • Added _TEMPLATE_REF_PATTERN and _WORKFLOW_INPUT_REF_PATTERN for scanning templates
    • Added _collect_template_strings() to gather all Jinja2 template strings from an agent
    • Added _validate_template_references() with agent name, workflow input, and explicit mode checks
    • Updated validate_workflow_config() signature to accept optional workflow_path
  • src/conductor/cli/validate.py:
    • Wired semantic validation (validate_workflow_config) into the CLI validate command — it previously only ran Pydantic schema validation
    • Displays warnings for non-fatal issues

Testing

  • 280 config tests pass (no regressions)
  • Tested manually with stale references, missing inputs, valid workflows, and explicit mode scenarios

@PolyphonyRequiem PolyphonyRequiem force-pushed the feat/enhanced-validate branch 3 times, most recently from 4744356 to c2b107f Compare April 25, 2026 03:26
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 83.83838% with 16 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@dbcf20f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/conductor/config/validator.py 85.39% 13 Missing ⚠️
src/conductor/cli/validate.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #125   +/-   ##
=======================================
  Coverage        ?   84.85%           
=======================================
  Files           ?       53           
  Lines           ?     7261           
  Branches        ?        0           
=======================================
  Hits            ?     6161           
  Misses          ?     1100           
  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.

Enhanced `conductor validate` to scan Jinja2 templates in agent prompts,
script args, input_mapping, and workflow output for reference errors:

Level 1 — Template reference resolution:
- {{ X.output.Y }} where X is not a valid agent name → error
- {{ workflow.input.X }} where X is not a declared input → error
- In explicit mode, LLM agents referencing agent outputs not in their
  input: list → warning

Also wires semantic validation (validate_workflow_config) into the CLI
`conductor validate` command, which previously only ran Pydantic schema
validation.

Catches errors like: stale agent name references after renames, missing
workflow input declarations, and undeclared dependencies in explicit mode
— all before runtime, at zero cost.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants