Skip to content

Python: chore(core): remove unused URI_PATTERN and correct add_chain cycle docstring - #10105

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:chore/remove-unused-uri-pattern-fix-add-chain-docstring
Nov 6, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:chore/remove-unused-uri-pattern-fix-add-chain-docstring

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Motivation & Context

Two small, self-contained cleanup/documentation improvements in the core Python package. This is not a bug fix: no prior behavior was broken or incorrect, and this PR changes no runtime behavior.

  1. agent_framework/_types.py defines a module-level URI_PATTERN regex that is not referenced anywhere in the core package. A repo-wide grep confirms the only other URI_PATTERN/_DATA_URI_PATTERN definitions live in the separate a2a and purview packages and are unrelated. It is dead code, so this removes it.
  2. The add_chain docstring in _workflows/_workflow_builder.py stated that "cycles in the chain are not allowed, meaning an executor cannot appear more than once in the chain." That is not what the method does — it simply adds an edge between each consecutive pair, and the workflow graph intentionally supports cycles. add_chain([a, b, a]) builds without error today, exactly as add_edge(a, b).add_edge(b, a) does. This corrects the docstring to describe the actual, intended behavior. No runtime enforcement is added.

Description & Review Guide

  • What are the major changes?
    • Remove the unused URI_PATTERN regex from agent_framework/_types.py (dead-code removal). The re import is still used elsewhere in the file and is kept.
    • Reword the add_chain docstring in _workflows/_workflow_builder.py so it accurately describes that repeated executors are permitted and can form a cycle, consistent with the rest of the framework. Documentation-only change.
  • What is the impact of these changes?
    • No behavioral change. One unused symbol is removed and one docstring now matches actual behavior.
  • What do you want reviewers to focus on?
    • That the docstring wording accurately reflects the existing (intentional) cycle support.

Verification performed locally against the core package:

  • uv run poe syntax -P core — passed (Ruff format + check).
  • uv run poe test -P core — 9274 passed, 20 skipped, 2 xfailed.
  • Confirmed add_edge(a, b).add_edge(b, a) and add_chain([a, b, a]) both build without error.

Related Issue

N/A - trivial change. This is a dead-code removal plus a documentation correction with no runtime impact; it is not tied to an open issue.

Fixes #

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: The code edits and this PR description were drafted with AI assistance. The changes are limited to removing one unused regex constant and correcting one docstring. The author will review and verify before merge and select the appropriate attestation above.

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 links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • 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.

…cstring

Remove the URI_PATTERN regex in agent_framework/_types.py. It is not
referenced anywhere in the core package (confirmed by a repo-wide grep;
the a2a and purview packages define their own, separate patterns), so it
is dead code.

Correct the add_chain docstring in _workflows/_workflow_builder.py. The
docstring stated that an executor cannot appear more than once and that
cycles are not allowed, but the method simply adds an edge between each
consecutive pair, and the workflow graph supports cycles. Repeating an
executor (e.g. add_chain([a, b, a])) builds without error, just as
add_edge(a, b).add_edge(b, a) does. This only updates the doc text to
describe the existing behavior; no runtime behavior is changed.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:56
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 4, 2026
@github-actions github-actions Bot changed the title chore(core): remove unused URI_PATTERN and correct add_chain cycle docstring Python: chore(core): remove unused URI_PATTERN and correct add_chain cycle docstring Nov 4, 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.

🟢 Approval recommended

No active review issues remain for the unused-constant removal and workflow documentation update.

No open issues 🎉

What changed in this PR

This PR cleans up the core Python package by removing an unused constant and correcting documentation, without changing runtime behavior.

Changes:

  • Remove the unused URI_PATTERN regex while retaining the still-used re import.
  • Clarify that add_chain permits repeated executors and can create cycles, consistent with existing workflow behavior.
File Description
python/​packages/​core/​agent_framework/​_workflows/​_workflow_builder.py Correct the add_chain docstring to describe existing cycle support.
python/​packages/​core/​agent_framework/​_types.py Remove the unused URI_PATTERN constant.

Review effort: Balanced

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
Merged via the queue into microsoft:main with commit 4ffc820 Nov 6, 2026
55 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 27ea290a Deployed Nov 4, 2026 by PratikDhanave via team_check #8769
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.

3 participants