adk-fluent · Data Flow Reference

Section A

## 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
Section B

## Data Flow Timeline

Context
Input
Output
Storage
Contract
Section C

## 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)`

Section D

## Decision Flowchart

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

Section E

## 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()
    )