Skip to content

Python: Preserve substituted values in declarative templates - #9096

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ktz03:fix/declarative-literal-interpolation
Oct 13, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ktz03:fix/declarative-literal-interpolation

Conversation

@ktz03

Copy link
Copy Markdown
Contributor

Motivation & Context

A SendActivity template can rewrite substituted values and leave authored placeholders unresolved. With Local.first = "{Local.second}" and Local.second = "B", {Local.first}|{Local.second} currently produces B|{Local.second} instead of {Local.second}|B. Each replacement searches an already-modified string, so it can consume text inserted by an earlier substitution.

Description & Review Guide

  • What are the major changes?

    Replace the sequential string-replacement loop with a regex callback over the original template. Keep the existing matcher, state-path resolution, string conversion, and missing-value behavior. Document that substituted values remain literal.

  • What is the impact of these changes?

    Only authored template occurrences are substituted. Repeated and overlapping placeholder values, including references inside lists or dictionaries, remain intact. Thirty-two regression tests cover string and mapping activities, with both ordinary and streaming execution in each test. They change from twelve failures and twenty passing controls to thirty-two passing tests. The complete declarative package suite passes 1,379 tests with no skips and 93% coverage on Windows/Python 3.12.14. Formatting/lint, strict source Pyright, all five test type checkers, applicable prek hooks, and wheel/sdist builds pass. No external service, model, other platform, or performance test was run.

  • What do you want reviewers to focus on?

    Preservation of original template positions and literal substituted values, including backslashes, while retaining ordinary interpolation and guarded state-path lookup. Expression evaluation and the expression-result behavior from Python: [BREAKING] preserve expression results in SendActivity output #8509 are unchanged.

Related Issue

Fixes #9095

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 23:48
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused implementation preserves existing behavior while comprehensively testing the reported edge cases.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes declarative template interpolation so substitutions apply only to authored placeholders.

Changes:

  • Uses a regex callback over the original template.
  • Documents literal substituted values.
  • Adds regression coverage for string/mapping and streaming workflows.
File Description
_declarative_base.py Corrects interpolation behavior.
test_graph_executors.py Adds comprehensive regression tests.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into microsoft:main with commit ce83eab Oct 13, 2026
53 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 4cb1bd72 Deployed Oct 12, 2026 by ktz03 via team_check #6569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Template interpolation rewrites substituted placeholder text

3 participants