Skip to content

Commit 5dccdc2

Browse files
alliscodeCopilot
andcommitted
fix: CI failures — pyupgrade, evaluator overloads, sample API, reset attr
- Apply pyupgrade: Sequence from collections.abc, remove forward-ref quotes - Add @overload signatures to evaluator() for proper @evaluator usage - Fix evaluate_workflow sample to use WorkflowBuilder(start_executor=) API - Fix _workflow.py executor.reset() to use getattr pattern for pyright - Remove unused EvalResults forward-ref string in default_factory lambda Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 39415c2 commit 5dccdc2

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

python/packages/azure-ai/agent_framework_azure_ai/_foundry_evals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
import asyncio
2727
import logging
28-
from typing import TYPE_CHECKING, Any, Sequence, cast
28+
from collections.abc import Sequence
29+
from typing import TYPE_CHECKING, Any, cast
2930

3031
from agent_framework._evaluation import (
3132
ConversationSplit,

python/packages/core/agent_framework/_evaluation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
import inspect
3636
import json
3737
import logging
38-
from collections.abc import Callable
38+
from collections.abc import Callable, Sequence
3939
from dataclasses import dataclass, field
4040
from enum import Enum
4141
from typing import (
4242
TYPE_CHECKING,
4343
Any,
4444
Literal,
4545
Protocol,
46-
Sequence,
4746
TypedDict,
4847
Union,
4948
cast,
49+
overload,
5050
runtime_checkable,
5151
)
5252

@@ -425,7 +425,7 @@ class EvalResults:
425425
error: str | None = None
426426
per_evaluator: dict[str, dict[str, int]] = field(default_factory=lambda: dict[str, dict[str, int]]())
427427
items: list[EvalItemResult] = field(default_factory=lambda: list[EvalItemResult]())
428-
sub_results: dict[str, "EvalResults"] = field(default_factory=lambda: dict[str, "EvalResults"]())
428+
sub_results: dict[str, EvalResults] = field(default_factory=lambda: dict[str, EvalResults]())
429429

430430
@property
431431
def passed(self) -> int:
@@ -1154,6 +1154,14 @@ def _coerce_result(value: Any, check_name: str) -> CheckResult:
11541154
raise TypeError(msg)
11551155

11561156

1157+
@overload
1158+
def evaluator(fn: Callable[..., Any], /) -> EvalCheck: ...
1159+
1160+
1161+
@overload
1162+
def evaluator(*, name: str | None = None) -> Callable[[Callable[..., Any]], EvalCheck]: ...
1163+
1164+
11571165
def evaluator(
11581166
fn: Callable[..., Any] | None = None,
11591167
*,

python/packages/core/agent_framework/_workflows/_workflow.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,9 @@ async def _run_workflow_with_tracing(
347347
self._state.clear()
348348
# Reset all executors (clears cached messages, sessions, etc.)
349349
for executor in self.executors.values():
350-
if hasattr(executor, "reset"):
351-
executor.reset()
350+
reset_fn = getattr(executor, "reset", None)
351+
if reset_fn is not None:
352+
reset_fn()
352353

353354
# Store run kwargs in State so executors can access them.
354355
# Only overwrite when new kwargs are explicitly provided or state was

python/samples/03-workflows/evaluation/evaluate_workflow.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from agent_framework import (
1717
Agent,
18-
AgentExecutor,
1918
LocalEvaluator,
2019
WorkflowBuilder,
2120
evaluate_workflow,
@@ -35,11 +34,7 @@ async def main():
3534
planner = Agent(model="gpt-4o-mini", instructions="You plan trips. Output a bullet-point plan.")
3635
executor_agent = Agent(model="gpt-4o-mini", instructions="You execute travel plans. Book the items listed.")
3736

38-
builder = WorkflowBuilder()
39-
builder.add_executor(AgentExecutor("planner", planner))
40-
builder.add_executor(AgentExecutor("booker", executor_agent))
41-
builder.add_edge("planner", "booker")
42-
workflow = builder.build()
37+
workflow = WorkflowBuilder(start_executor=planner).add_edge(planner, executor_agent).build()
4338

4439
# Evaluate with per-agent breakdown
4540
local = LocalEvaluator(is_nonempty, keyword_check("plan", "trip"))

0 commit comments

Comments
 (0)