From 27ea290ad82b741b328386a46c28f667118f8698 Mon Sep 17 00:00:00 2001 From: Pratik Dhanave Date: Wed, 4 Nov 2026 22:24:03 +0530 Subject: [PATCH] chore(core): remove unused URI_PATTERN and correct add_chain cycle docstring 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. --- python/packages/core/agent_framework/_types.py | 2 -- .../core/agent_framework/_workflows/_workflow_builder.py | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/packages/core/agent_framework/_types.py b/python/packages/core/agent_framework/_types.py index 00edbaa937a..3ec0d045048 100644 --- a/python/packages/core/agent_framework/_types.py +++ b/python/packages/core/agent_framework/_types.py @@ -424,8 +424,6 @@ def _restore_compaction_annotation_in_additional_properties( CreatedAtT = str # Use a datetimeoffset type? Or a more specific type like datetime.datetime? -URI_PATTERN = re.compile(r"^data:(?P[^;]+);base64,(?P[A-Za-z0-9+/=]+)$") - KNOWN_MEDIA_TYPES = [ "application/json", "application/octet-stream", diff --git a/python/packages/core/agent_framework/_workflows/_workflow_builder.py b/python/packages/core/agent_framework/_workflows/_workflow_builder.py index 3eed9ca800a..4f2861bd906 100644 --- a/python/packages/core/agent_framework/_workflows/_workflow_builder.py +++ b/python/packages/core/agent_framework/_workflows/_workflow_builder.py @@ -569,7 +569,11 @@ def add_chain(self, executors: Sequence[Executor | SupportsAgentRun]) -> Self: The output of each executor in the chain will be sent to the next executor in the chain. The input types of each executor must be compatible with the output types of the previous executor. - Cycles in the chain are not allowed, meaning an executor cannot appear more than once in the chain. + An edge is added between each consecutive pair of executors in the sequence. If an executor + appears more than once, the corresponding edges are still added, which can introduce a cycle + (for example, ``add_chain([a, b, a])`` adds the edges ``a -> b`` and ``b -> a``). This is + permitted: the workflow graph supports cycles, just as calling ``add_edge(a, b)`` followed by + ``add_edge(b, a)`` does. Args: executors: A list of executors or agents to chain together.