The Role of RunConfig in Controlling Agent Execution and Modalities
RunConfig decides how every ADK run behaves — streaming mode, speech and response modalities, context loading, LLM call caps, and live-agent knobs. Here is how to set each one.
Published on • November 24, 2026
AI Assistant

An ADK agent’s definition (instruction, tools, sub-agents) says what it does; RunConfig says how a particular run behaves. It is the single object you hand to runner.run_async(...) or runner.run_live() to override streaming mode, speech settings, context loading, LLM call limits, and live-agent options — per run, without touching the agent itself.
In this tutorial we walk through each group of RunConfig fields with working Python snippets, from text streaming to audio modalities to the guardrails that keep a runaway loop from burning your quota.
A RunConfig in Five Lines
from google.adk.agents.run_config import RunConfig, StreamingMode
config = RunConfig(
streaming_mode=StreamingMode.SSE,
max_llm_calls=200,
)
async for event in runner.run_async(
..., run_config=config,
):
...
Everything below is just different fields on this object.
Streaming Modes
| Mode | Behavior | Use when |
|---|---|---|
StreamingMode.NONE (default) | One complete response per turn | CLI tools, batch jobs, synchronous workflows |
StreamingMode.SSE | Yields partial events as the LLM generates | Typewriter UIs, real-time chat |
Pair SSE with Compositional Function Calling (experimental, uses the Live API under the hood) by adding support_cfc=True:
config = RunConfig(
streaming_mode=StreamingMode.SSE,
support_cfc=True,
max_llm_calls=150,
)
Under the hood, partial events carry partial=True and are forwarded without committing state — the final event does the persistence (see adk-event-loop-deep-dive.md).
Loading Less Context
Long sessions don’t have to reload full history on every invocation:
from google.adk.agents.run_config import RunConfig
from google.adk.sessions.base_session_service import GetSessionConfig
config = RunConfig(
get_session_config=GetSessionConfig(num_recent_events=50),
)
get_session_configfilters loaded events withnum_recent_eventsorafter_timestamp; stored history is untouched.context_window_compressioncompresses LLM input as sessions approach context limits.model_input_contextinjects a list oftypes.Contentfor this invocation only — never persisted to the session.include_thoughts_from_other_agentscontrols whether other agents’ thought parts reach the LLM context (off by default).
Modalities and Speech
A session accepts exactly one modality: ["AUDIO"] for voice agents or ["TEXT"] for text-only. Want both? Set ["AUDIO"] and read the text from output audio transcription instead.
from google.adk.agents.run_config import RunConfig, StreamingMode
from google.genai import types
config = RunConfig(
speech_config=types.SpeechConfig(
language_code="en-US",
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Kore")
),
),
response_modalities=["AUDIO"],
streaming_mode=StreamingMode.SSE,
max_llm_calls=1000,
)
output_audio_transcription and input_audio_transcription both default to AudioTranscriptionConfig() in Python. The full live-agent reference (voice selection, VAD, proactive dialog) lives in the live configuration docs; here we only cover what RunConfig itself carries.
Live Agent Knobs
Live sessions are driven through runner.run_live() and add real-time parameters: realtime_input_config, session_resumption, save_live_blob, proactivity, enable_affective_dialog, and one genuinely runtime-level setting:
from google.adk.agents.run_config import RunConfig, ToolThreadPoolConfig
config = RunConfig(
save_live_blob=True,
tool_thread_pool_config=ToolThreadPoolConfig(max_workers=8),
)
The thread pool runs tool executions in the background so the event loop keeps answering user interruptions. It helps blocking I/O and C extensions that release the GIL — it does not parallelize pure Python CPU-bound work.
Limits, Tracing, and Debugging
max_llm_callscaps LLM calls per run (default: 500). Set0or a negative value for unlimited — not recommended in production. Passing your language’s largest integer (sys.maxsizein Python) raises an error.custom_metadata: an arbitrarydict[str, Any]attached to the invocation — ideal for tracing and logging correlation.service_tier: ADK Python only, Gemini models on the Interactions API.ServiceTier.DEFERREDqueues calls for off-peak capacity and cannot be combined withStreamingMode.SSE.save_input_blobs_as_artifacts: deprecated in Python in favor ofSaveFilesAsArtifactsPlugin; the runner still needs an artifact service for it to take effect.
Pitfalls
- Setting both
response_modalities=["AUDIO"]and expecting["TEXT"]in the same session — one modality per session, no exceptions. - Assuming SSE is free: deferred service tiers and CFC both constrain your streaming choices.
- Forgetting that
RunConfigis per-run:run_async(..., run_config=config)must receive it on every call, not once at Runner construction. - Leaving
max_llm_callsat its default while testing adversarial inputs — a stuck loop stops at 500 calls, but 500 calls is still a bill.
Takeaway: RunConfig is ADK’s per-run control surface — streaming mode and CFC for text, a single response modality plus speech_config for voice, GetSessionConfig and model_input_context for context budget, max_llm_calls for spend caps, and tool_thread_pool_config for keeping the loop responsive — and passing it explicitly on each run_async/run_live call is how you keep agent definitions reusable while run behavior varies by surface.