Multi-Agent Architecture
This guide covers agent configuration and delegation in the OpenAI Agents runtime.
Core Concepts
AgentConfig
AgentConfig defines one agent type:
name,display_name,descriptionsystem_promptallowed_toolsmax_turnssubagents(optional)
SubAgentConfig
Subagents are represented as handoff targets:
descriptionprompttoolsmodel(default delegated model isgpt-4.1-mini)
OpenAIAgentExecutor
The default executor builds an OpenAI Agent and executes with Runner.run(...).
Built-in Agent Types
default: general-purpose runtimemarketing: marketing/copy workflowsresearch: coordinator with handoffs to:researcherdata-analystreport-writer
Handoffs
build_agent_options(...) creates handoffs using handoff(...) with deterministic tool names:
transfer_to_researchertransfer_to_data_analysttransfer_to_report_writer
Lead model default: gpt-4.1.
Delegated model default: gpt-4.1-mini.
Tool Access
Tool allowlists are translated by modal_backend/mcp_tools/registry.py into concrete OpenAI tools, including:
- Local parity tools:
Read,Write,Glob,Bash,WebFetch - Hosted web search when
WebSearch(*)is present - Session tools:
mcp__sessions__spawn_sessionmcp__sessions__check_session_statusmcp__sessions__get_session_resultmcp__sessions__list_child_sessions
Session Behavior
- Resume by
session_idthroughSQLiteSession - Branch by
fork_session=true(new session ID, inherited history)
Adding a Custom Agent Type
- Add a config in
modal_backend/agent_runtime/types/. - Register it in
modal_backend/agent_runtime/registry.py. - Use via
agent_typein/query,/query_stream, orrun_agent_remote.
CLI Examples
modal run -m modal_backend.main::run_agent_remote --question "Explain decorators"
modal run -m modal_backend.main::run_agent_remote --question "Write tagline" --agent-type marketing
modal run -m modal_backend.main::run_agent_remote --question "Research AI trends" --agent-type research