Files
agents/sdk/python/tests/test_pydantic_utils.py
zeekayandGitHub 5b5cf9e9db feat: merge AgentField control plane + SDKs as Hanzo Agents (#1)
Transforms hanzoai/agents from a marketplace config repo into a full
agent orchestration platform by merging the AgentField infrastructure:

- Go control plane (K8s-like agent orchestration, service mesh, DAG workflows)
- Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC)
- TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows)
- Go SDK (idiomatic agent builder + client)
- React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI)
- Docker/K8s/Helm deployment configs
- Examples: hello world, deep research, RAG, simulation, benchmarks
- Functional test suite across Python/Go/TypeScript

All references rebranded: AgentField → Hanzo Agents
- Module: github.com/hanzoai/agents/control-plane
- Python: hanzo_agents
- TypeScript: @hanzo/agents
- Go: github.com/hanzoai/agents/sdk/go
- Env vars: HANZO_AGENTS_*
- Config: hanzo-agents.yaml

Previous marketplace configs moved to config/ directory.
2026-02-09 18:53:09 -08:00

54 lines
1.3 KiB
Python

from pydantic import BaseModel
from hanzo_agents.pydantic_utils import (
is_pydantic_model,
is_optional_type,
get_optional_inner_type,
convert_dict_to_model,
convert_function_args,
should_convert_args,
)
class Inner(BaseModel):
x: int
def test_is_pydantic_and_optional_helpers():
assert is_pydantic_model(Inner) is True
from typing import Optional
opt = Optional[Inner]
assert is_optional_type(opt) is True
assert get_optional_inner_type(opt) is Inner
def test_convert_dict_to_model_success_and_error():
out = convert_dict_to_model({"x": 5}, Inner)
assert isinstance(out, Inner)
assert out.x == 5
# Should raise some validation-related exception from conversion
raised = False
try:
convert_dict_to_model({"x": "bad"}, Inner)
except Exception:
raised = True
assert raised
class WithModel(BaseModel):
inner: Inner
def func_with_model(inner: Inner, y: int):
return inner.x + y
def test_convert_function_args_and_should_convert():
assert should_convert_args(func_with_model) is True
# Provide dict for inner; expect conversion
args, kwargs = convert_function_args(
func_with_model, tuple(), {"inner": {"x": 2}, "y": 3}
)
assert isinstance(kwargs["inner"], Inner)
assert kwargs["inner"].x == 2