Concept 5Typed contracts (input_schema & output_schema)
03a & 05a · Art #3a & #5a

If Agent A passes 500 words of conversational text to Agent B, you pay extra token costs and risk parsing errors. Schemas enforce strict data contracts:

1

input_schema=MyInputModelForces callers (or AgentTool supervisors) to pass a validated Pydantic payload.

2

output_schema=MyOutputModelForces the agent's decoding layer to emit guaranteed JSON matching your Pydantic class.

3

output_key='state_var'Automatically writes that validated JSON into session.state['state_var'] for downstream agents!

session.state, ready for the next agent
["planned_route"] = { highway_corridor, candidate_stops }
adk_agent_app/schemas/suggeritore_schemas.py
from pydantic import BaseModel, Field
class SuggeritoreInput(BaseModel):
origin: str = Field(description="Departure city")
destination: str = Field(description="Arrival city")
fuel_type: str = Field(description="EV, Petrol, Diesel, LPG")
dietary_preferences: list[str] = Field(default_factory=list)
class RouteCandidateStopsOutput(BaseModel):
highway_corridor: str
candidate_stops: list[str]
route_planner_agent = LlmAgent(
name="RoutePlannerAgent",
input_schema=SuggeritoreInput,
output_schema=RouteCandidateStopsOutput,
output_key="planned_route",
)