From cd5febf03d91e55f85f0c0fa52d82b8eded23559 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 7 May 2026 12:08:12 -0700 Subject: [PATCH] fix(v2 managed agents): satisfy pyright on _row_to_agent_response config access Use getattr with a None default and isinstance narrowing instead of hasattr to unwrap prisma.Json-style configs. Pyright was flagging .data access on the dict branch of the union; this rewrites the path so the type narrows cleanly without an Any cast. --- litellm/managed_agents/endpoints/agents.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/litellm/managed_agents/endpoints/agents.py b/litellm/managed_agents/endpoints/agents.py index e1f200ea4bf..1ee1d52008a 100644 --- a/litellm/managed_agents/endpoints/agents.py +++ b/litellm/managed_agents/endpoints/agents.py @@ -118,12 +118,17 @@ def _row_to_agent_response(row: Dict[str, Any]) -> AgentRow: Handles both raw-dict configs (Prisma JSON column) and `prisma.Json`-wrapped configs (mock-style with a ``.data`` attribute). """ - raw_config = row.get("config") or {} - if hasattr(raw_config, "data"): - # prisma.Json wrapper used by some test fakes - config_dict: Dict[str, Any] = dict(raw_config.data) - else: + raw_config: Any = row.get("config") or {} + # prisma.Json wrapper used by some test fakes exposes the dict via ``.data``; + # use ``getattr`` so static type checkers don't flag attribute access on the + # ``dict`` branch of the union. + wrapped = getattr(raw_config, "data", None) + if isinstance(wrapped, dict): + config_dict: Dict[str, Any] = dict(wrapped) + elif isinstance(raw_config, dict): config_dict = dict(raw_config) + else: + config_dict = {} masked_config = { **config_dict,