adk-fluent / data-flow

Data Flow Reference

The five orthogonal data-flow concerns in adk-fluent — how data enters, exits, and flows through every agent turn.

Quick-Reference Grid

C

Context

.reads(*keys)
.context(C.xxx())

Injects state values into the agent's prompt as additional context. Values appear in LLM input at runtime.

HAS RUNTIME EFFECT
I

Input

.accepts(Schema)

Defines structured input schema when the agent is used as an AgentTool. Validates incoming data from the parent agent.

HAS RUNTIME EFFECT
O

Output

.returns(Schema)

Constrains LLM response to structured JSON matching a Pydantic schema. Forces output_schema on generate_content_config.

HAS RUNTIME EFFECT
S

Storage

.writes(key)

Stores the agent's text response in session state[key] after execution. Downstream agents can read the stored value.

HAS RUNTIME EFFECT
K

Contract

.produces(Schema)
.consumes(Schema)

Static type annotations for pipeline validation and documentation. No runtime effect — tooling and introspection only.

NO RUNTIME EFFECT

Data Flow Timeline

Context
Input
Output
Storage
Contract
Session state[...] .accepts(Schema) .reads() .context() Agent Prompt + injected context LLM generate() Response structured JSON .returns(Schema) .writes() Session State state[key] = resp .produces(Schema) .consumes(Schema) static annotations only — no runtime effect

Confusion Matrix

Concern When Direction Runtime? Sets on ADK Example
Context Before LLM call State → Prompt Yes include_contents / instruction injection .reads("article")
Input When called as AgentTool Parent → Agent Yes input_schema on AgentTool .accepts(SummarizeInput)
Output LLM generation Agent → Caller Yes output_schema on generate_content_config .returns(SummaryOutput)
Storage After execution Response → State Yes output_key on LlmAgent .writes("summary")
Contract Build time / static analysis N/A (annotation) No Nothing — metadata only .produces(SummaryContract)

Decision Flowchart

"Which method do I use?" — follow the questions to find the right data-flow method.

Need to pass data TO the LLM? yes no .reads() / .context() inject state into prompt Need structured JSON output? yes no .returns(Schema) constrain LLM output Need to save response for later? yes no .writes(key) store in session state Agent used as an AgentTool? yes no .accepts(Schema) validate AgentTool input .produces() / .consumes() documentation annotations only

All Five Concerns in One Agent

example.py
from adk_fluent import Agent
from pydantic import BaseModel

class SummarizeInput(BaseModel):
    article_url: str
    max_length: int = 500

class SummaryOutput(BaseModel):
    title: str
    summary: str
    key_points: list[str]

class SummaryContract(BaseModel):
    summary: str

agent = (
    Agent("summarizer", "gemini-2.5-flash")
    .reads("article")           # CONTEXT  -- inject article text into prompt
    .accepts(SummarizeInput)    # INPUT    -- structured input schema for AgentTool
    .instruct("Summarize the article in {article}.")
    .returns(SummaryOutput)     # OUTPUT   -- structured JSON response from LLM
    .writes("summary")          # STORAGE  -- save response to state["summary"]
    .produces(SummaryContract)  # CONTRACT -- static annotation (no runtime effect)
    .build()
)