Description
The introspection mode of @response_handler reads raw values from inspect.signature(func). When a module uses from __future__ import annotations, valid request, response, and WorkflowContext[...] annotations are stored as strings, but the response-handler validation path does not resolve them before validating the context annotation.
This causes a valid executor definition to fail while the class body is being evaluated, so the executor cannot be imported or instantiated.
Reproduction
from __future__ import annotations
from agent_framework import Executor, WorkflowContext, handler, response_handler
class FutureAnnotationsExecutor(Executor):
@handler
async def handle(self, message: str, ctx: WorkflowContext) -> None:
pass
@response_handler
async def handle_response(
self, original_request: str, response: int, ctx: WorkflowContext[str]
) -> None:
pass
On the current upstream main, defining the class raises:
ValueError: Response handler parameter 'ctx' must be annotated as WorkflowContext, WorkflowContext[T], or WorkflowContext[T, U], got WorkflowContext[str]
Expected behavior
The introspection path should resolve postponed annotations in the same way as the existing @handler path, then register the response handler with str as the request type, int as the response type, and str as the workflow output type.
Scope
This affects introspection mode only. Explicit @response_handler(request=..., response=...) parameters already resolve string references and should remain unchanged.
The corresponding @handler future-annotation behavior is covered by test_executor_future.py (issue #3898); this issue tracks the missing response-handler counterpart.
Description
The introspection mode of
@response_handlerreads raw values frominspect.signature(func). When a module usesfrom __future__ import annotations, valid request, response, andWorkflowContext[...]annotations are stored as strings, but the response-handler validation path does not resolve them before validating the context annotation.This causes a valid executor definition to fail while the class body is being evaluated, so the executor cannot be imported or instantiated.
Reproduction
On the current upstream
main, defining the class raises:Expected behavior
The introspection path should resolve postponed annotations in the same way as the existing
@handlerpath, then register the response handler withstras the request type,intas the response type, andstras the workflow output type.Scope
This affects introspection mode only. Explicit
@response_handler(request=..., response=...)parameters already resolve string references and should remain unchanged.The corresponding
@handlerfuture-annotation behavior is covered bytest_executor_future.py(issue #3898); this issue tracks the missing response-handler counterpart.