Description
_coerce_value (agent_framework/_settings.py) only runs its per-arm union coercion when None is one of the arms. For any other union, e.g. int | float, it falls through to return value. The raw string is returned unchanged, and invalid input is accepted without error.
This contradicts the documented contract in packages/core/AGENTS.md: "Invalid supplied numeric and boolean environment or .env values raise ValueError identifying the field and source".
Suggested fix: handle any Union / types.UnionType origin with the same try-each-arm loop, treating the None arm as optional, and raise when no arm matches.
Code Sample
from agent_framework._settings import _coerce_value
_coerce_value("5", int | None) # 5 (correct)
_coerce_value("5", int | float) # '5' (str, expected 5)
_coerce_value("abc", int | float) # 'abc' (expected ValueError)
Error Messages / Stack Traces
Package Versions
agent-framework-core 1.19.0 (main @ 853c456)
Python Version
Python 3.11
Additional Context
Found during a code review of main @ 853c456 (2026-09-30); the repro above was run against that commit.
Description
_coerce_value(agent_framework/_settings.py) only runs its per-arm union coercion whenNoneis one of the arms. For any other union, e.g.int | float, it falls through toreturn value. The raw string is returned unchanged, and invalid input is accepted without error.This contradicts the documented contract in
packages/core/AGENTS.md: "Invalid supplied numeric and boolean environment or.envvalues raiseValueErroridentifying the field and source".Suggested fix: handle any
Union/types.UnionTypeorigin with the same try-each-arm loop, treating theNonearm as optional, and raise when no arm matches.Code Sample
Error Messages / Stack Traces
Package Versions
agent-framework-core 1.19.0 (main @ 853c456)
Python Version
Python 3.11
Additional Context
Found during a code review of
main@853c456(2026-09-30); the repro above was run against that commit.