Fine-Tuned Gemini Adapters: Deploying Custom Tuned Models in ADK
Supervised tuning end to end: preparing a JSONL dataset, launching and monitoring a tuning job with the Gen AI SDK, pointing an ADK agent at the tuned endpoint, and judging whether tuning beat prompting and retrieval.
Published on • November 27, 2026
AI Assistant

Fine-tuning is the most over-prescribed technique in applied LLM work. Nine times out of ten the fix for a poorly behaving agent is a better prompt, better examples, or better retrieval — and then the tenth time, when the model needs a house style, a domain vocabulary, or a consistent output shape it will not pick up from context, tuning genuinely wins.
This tutorial assumes you have already done that ninth case honestly. It covers the mechanics: preparing a supervised tuning dataset, launching and monitoring the job, wiring the resulting endpoint into an ADK agent, and evaluating tuned against base so you know what you bought.
What tuning actually changes
Supervised fine-tuning adjusts the model’s weights (via a learned adapter on top of the base model) on your input/output pairs. It does not add knowledge in the way a document store does — it biases behaviour: tone, format, vocabulary, task focus. That has three consequences:
- The tuned model has a cutoff. It will not know about the customer you signed yesterday; retrieval still owns freshness.
- Regression is possible. Tuning for one skill can erode another. You must re-run your broader eval set, not just your tuning metric.
- The artifact is versioned and endpoint-bound. It deploys like a model, not like a config file.
Preparing the dataset
Training data is JSONL: one example per line, each with an input and an output.
{"input": "Summarise ticket 48219 for the weekly digest", "output": "Weekly digest summary: ticket 48219 (payment retries) was resolved by rolling back the gateway config at 14:02; no customer data was affected; follow-up filed to add a canary check."}
{"input": "Rewrite this changelog entry for enterprise readers", "output": "Enterprise release note: session storage now supports regional pinning. Action required: set your session region explicitly before the March rollout."}
Guidelines that matter more than dataset size:
- Represent the distribution of real turns, including the boring ones. A dataset of only hard cases produces a model that overcomplicates easy ones.
- Match the response format exactly — this is where tuning helps most, because the format is reinforced on every gradient step.
- Hold out an eval split you never train on. 10–20% is enough to detect overfitting.
- Keep it clean and de-duplicated. Secret-bearing or contradictory examples are learned too.
Upload the file to a bucket the tuning job can read:
from google import genai
from google.genai import types
client = genai.Client() # project/location from env
training_dataset = types.TuningDataset(
gcs_uri='gs://acme-ml/tuning/support-style-v3.jsonl',
)
Launching and monitoring the job
tuning_job = client.tunings.tune(
base_model='gemini-3.8-flash',
training_dataset=training_dataset,
config=types.CreateTuningJobConfig(
epoch_count=3,
tuned_model_display_name='support-style-v3',
),
)
completed = {'JOB_STATE_SUCCEEDED', 'JOB_STATE_FAILED', 'JOB_STATE_CANCELLED'}
while tuning_job.state not in completed:
print(tuning_job.state)
tuning_job = client.tunings.get(name=tuning_job.name)
time.sleep(10)
assert tuning_job.state == 'JOB_STATE_SUCCEEDED', tuning_job.state
endpoint = tuning_job.tuned_model.endpoint
Notes from the field:
- Tuning is asynchronous and long-running. Poll with backoff, or drive the job from CI rather than a laptop shell that closes.
- Track cost before you start. Training tokens are billed; a small, high-quality dataset with a few epochs usually beats a large noisy one.
- Keep the base model choice aligned with production. Tuning a Flash model for latency-sensitive agents, then deploying a Pro-tier endpoint, gives you the wrong cost/latency profile.
Using the tuned model in an ADK agent
The tuned endpoint behaves like any other model identifier. Because an ADK agent takes a model, the change is one line — but keep the tuned model’s name in configuration, not scattered through code:
from google.adk import Agent
support_agent = Agent(
name='support_agent',
model=os.environ['SUPPORT_TUNED_ENDPOINT'], # e.g. tuned model endpoint resource
instruction=SYSTEM_INSTRUCTION,
tools=[lookup_ticket, search_kb],
)
Two operational points:
- The tuned model is a deployment dependency. If the endpoint is deleted, mis-scoped, or fails over, your agent fails. Put a startup check in place: fail fast with a clear message instead of a confusing model-not-found at the first user turn.
- Tuned models and tool calling are not guaranteed to be identical to the base. Re-run your tool-selection evals after every tuning job — a model that became better at house style can become worse at choosing between eleven tools.
List and manage tuned artifacts rather than letting them accumulate:
# tuned models, not base models
for model in client.models.list(config={'query_base': False}):
print(model.name, model.display_name)
Did it win? The evaluation you owe yourself
Tuning without a before/after eval is a leap of faith. Build the comparison as a paired test:
| Slice | Metric | Base | Tuned | Gate |
|---|---|---|---|---|
| Format conformance | parseable output rate | 84% | 98% | tuned ≥ base − 1pp |
| Domain tone | LLM-judge preference | 51% | 88% | tuned wins |
| Tool selection accuracy | exact match | 92% | 89% | tuned ≥ base − 3pp |
| General reasoning (regression set) | accuracy | 90% | 91% | no drop > 2pp |
| p95 TTFT / cost per turn | ms / $ | baseline | measured | within budget |
The gates in the last column are the point: tuning ships only if it improves the target without breaching a regression limit elsewhere.
Also test distribution shift — the dataset was last month’s tickets; run the tuned model against this week’s traffic sample (offline replay is fine) to catch drift early.
When not to tune
Reach for something cheaper first:
- Prompting — a clearer instruction or a few-shot example, if the behaviour is a formatting or tone issue.
- Retrieval — if the gap is knowledge, tuning will not close it; agentic RAG will.
- Structured outputs — if the failure is schema conformance,
response_schemais instant and reversible. - Fine-tuning only after those, when the behaviour must be internalised: consistent domain register, compact prompts that no longer afford examples, or a latency budget that excludes long few-shot prefixes.
Takeaways
- Tune for behaviour, not knowledge; retrieval still owns freshness.
- Small, representative, clean datasets with a held-out split beat large noisy ones — and always keep an eval slice you never train on.
- The tuned endpoint is a deployment artifact: reference it from config, verify it at startup, and re-run tool-selection evals after every job.
- Ship behind paired before/after metrics with explicit regression gates.
- Prompting, structured outputs, and RAG are the first three things to try; tuning is the fourth.