You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: Executor type checking fails when using __future__ annotations in Python 3.12 #1
When using from __future__ import annotations, type annotations are stored as strings. Type checking in _executor.py will get a str not a class object. This is passed to _workflow_context.py, which uses typing.get_origin and returns None.
This was mentioned in microsoft#1808 and fixed in microsoft#2308 for FunctionExecutor not the regular Executor. That fix uses typing.get_type_hints before the call to validate_workflow_context_annotation.
Code Sample
from __future__ import annotations
from pydantic import BaseModel
from agent_framework import Executor, WorkflowContext, handler
class MyTypeA(BaseModel):
pass
class MyTypeB(BaseModel):
pass
class MyExecutor(Executor):
@handler
async def example(self, input: str, ctx: WorkflowContext[MyTypeA, MyTypeB]) -> None:
pass
Error Messages / Stack Traces
/usr/bin/python3.12 /IdeaProjects/problem.py
Traceback (most recent call last):
File "/IdeaProjects/problem.py", line 12, in <module>
class MyExecutor(Executor):
File "/IdeaProjects/problem.py", line 13, in MyExecutor
@handler
^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/agent_framework/_workflows/_executor.py", line 584, in handler
return decorator(func)
^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/agent_framework/_workflows/_executor.py", line 558, in decorator
_validate_handler_signature(func)
File "/home/ubuntu/.local/lib/python3.12/site-packages/agent_framework/_workflows/_executor.py", line 619, in _validate_handler_signature
output_types, workflow_output_types = validate_workflow_context_annotation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.12/site-packages/agent_framework/_workflows/_workflow_context.py", line 154, in validate_workflow_context_annotation
raise ValueError(
ValueError: Handler parameter 'ctx' must be annotated as WorkflowContext, WorkflowContext[T], or WorkflowContext[T, U], got WorkflowContext[MyTypeA, MyTypeB]
Process finished with exit code 1
Activity
Smoke: validate PR authoring path (1771196655)
Smoke: validate PR authoring pipeline (1771198711)
Resolve Executor future-annotation types and avoid nested uv workspaces
Resolve future annotations during Executor handler validation
Resolve postponed handler annotations safely
Resolve postponed handler annotations and add root pyproject
Resolve postponed WorkflowContext annotations in handler validation
Resolve postponed annotations in handler validation
Resolve Executor handler annotations with get_type_hints
Resolve postponed annotations for class-based executor handlers
Resolve postponed handler annotations during executor validation
Resolve postponed handler annotations during validation
Fix handler signature validation for future annotations
Fix handler signature validation for future annotations
40 remaining items
Fix Executor @handler validation for postponed (__future__) annotations
Fix Executor @handler validation with postponed (future) annotations
Fix Executor @handler validation with postponed (future) annotations …
Fix Executor handler validation for postponed annotations (future ann…
Fix Executor @handler validation with postponed annotations (future a…
Fix Executor @handler introspection with future annotations
Address review feedback for #1
Fix Executor @handler validation with postponed (string) annotations
Address review feedback for #1
Fix verification regression after review for #1
Address PR microsoft#4941 review comments: fix docstring position and…
Python: Fix GitHubCopilotAgent to invoke context provider before_run/…
Python: Restrict persisted checkpoint deserialization by default (mic…
.NET: Feat/dotnet shell tool (microsoft#5604)
.NET: fix parallel tool call rendering in AGUI translation layer (mic…