Skip to content

Python: [Bug]: Functional workflow accepts HITL responses that violate response_type #8308

Closed

Description

@CoralGarden52

Summary

Functional workflows accept a response whose runtime type does not match the response_type declared in RunContext.request_info() during response-only HITL resume.

Reproduction

from agent_framework import RunContext, workflow


@workflow
async def typed_review(data: str, ctx: RunContext) -> str:
    answer = await ctx.request_info("number", response_type=int, request_id="typed")
    return f"{answer}:{type(answer).__name__}"


caller = typed_review.build()
await caller.run("input")
resumed = await caller.run(responses={"typed": "not-an-int"})
print(resumed.get_outputs())

On current main, the response is accepted and the output is:

['not-an-int:str']

Expected behavior

A response that violates the declared response_type should be validated consistently with the graph workflow runtime: valid values may be coerced according to the existing workflow typing rules, while incompatible values should raise a clear type-mismatch error before the workflow produces output.

Impact

A malformed or incorrectly deserialized HITL response can silently enter a functional workflow as the wrong Python type. This makes the declared response_type ineffective and can produce incorrect downstream decisions, formatting, or persistence without an error at the response boundary.

Related context

The review discussion on the original functional workflow implementation in #4238 identified that response-only resumes accept responses without the type/request validation enforced by the existing workflow runtime. This issue tracks that unresolved follow-up. It is separate from #8299, which concerns user state being lost during the same response-only resume path, and from #8292, which concerns concurrent cached-step result ordering.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 11, 2026
  2. CoralGarden52 commented on Sep 11, 2026

    @CoralGarden52
    ContributorAuthor

    Clarification: existing functional workflow behavior and regression tests intentionally allow a None response (with a warning), even when response_type is non-optional. The proposed validation will preserve that compatibility behavior and reject only non-None values that cannot be coerced to the declared response type.

  3. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Sep 11, 2026
  4. github-actions commented on Sep 11, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    Repro: python/packages/core/agent_framework/_workflows/_functional.py::RunContext.request_info at lines 244-247 returns the raw value populated by _set_responses without checking the declared response type. It triggers after request_info(..., response_type=int, request_id="typed") pauses a functional workflow and run(responses={"typed": "not-an-int"}) resumes it; the minimal test expects ValueError but observes ['not-an-int:str'].

    • Failing test: python/packages/core/tests/workflow/test_functional_workflow.py
    • Files examined: python/AGENTS.md, python/packages/core/AGENTS.md, python/packages/core/agent_framework/_workflows/_functional.py, python/packages/core/agent_framework/_workflows/_workflow.py, python/packages/core/tests/workflow/test_functional_workflow.py, python/packages/core/pyproject.toml, python/pyproject.toml
    • Tests run: test_step_with_run_context_injection (passed), test_responses_mismatched_key_raises (passed), test_incompatible_response_type_is_rejected (failed as expected)
    • Current version: 1.18.0
  5. added
    workflowsUsage: [Issues, PRs], Target: Workflows
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowworkflowsUsage: [Issues, PRs], Target: Workflows

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions