Assembly: minions
Filename: gemini.py
Author: Terry D. Eppler
Created: 09-05-2026
Last Modified By: Terry D. Eppler
Last Modified On: 09-06-2026
gemini.py
Copyright © 2026 Terry D. Eppler
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov
Google Agent Development Kit Minion implementations.
Minion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Agent
Provider-native Gemini workflow agent.
Purpose
Configures and executes a Google ADK agent with caller-selected native tools,
instructions, and a bounded number of model calls. Each execution creates an
isolated in-memory session and delegates tool orchestration to ADK.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default human-readable name of the Minion.
|
name |
str
|
Inherited provider-compatible agent identifier.
|
display_name |
str
|
Human-readable agent name.
|
model |
str | Gemini
|
Inherited native model identifier or configured Gemini model.
|
instruction |
str
|
Inherited system instructions for the workflow.
|
tools |
list[GeminiTool]
|
Inherited native tools selected by the caller.
|
api_key |
str
|
Configured Google or Gemini API key, excluded from model serialization.
|
max_turns |
int
|
Maximum model calls per execution.
|
prompt |
str
|
Most recently accepted workflow prompt.
|
events |
list[Event]
|
Events retained for the current or most recent invocation.
|
result |
Event | None
|
Final-response event or last available event for that invocation.
|
Initialize a Gemini Minion.
Purpose
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Parameters:
| Name |
Type |
Description |
Default |
model
|
str
|
Nonblank Gemini model identifier.
|
required
|
instructions
|
str
|
Nonblank system instructions for the agent.
|
required
|
tools
|
Sequence[GeminiTool] | None
|
Optional native tools; defaults to no tools.
|
None
|
max_turns
|
int
|
Maximum model calls per execution; defaults to 10 and must be positive.
|
10
|
name
|
str | None
|
Optional nonblank name overriding the implementation default.
|
None
|
Returns:
| Name | Type |
Description |
None |
None
|
Initializes the native agent and its execution configuration.
|
Raises:
| Type |
Description |
ValueError
|
If a required string, normalized identifier, or model-call limit is invalid.
|
TypeError
|
If tools is supplied as an invalid sequence.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
normalize_name(name: str) -> str
staticmethod
Create a valid Google ADK agent identifier.
Purpose
Converts a human-readable name to the established lowercase identifier format,
replacing unsupported characters and prefixing identifiers beginning with a digit.
Parameters:
| Name |
Type |
Description |
Default |
name
|
str
|
Nonblank human-readable agent name.
|
required
|
Returns:
| Name | Type |
Description |
str |
str
|
Normalized ADK identifier.
|
Raises:
| Type |
Description |
Error
|
If the name is invalid or cannot produce a usable identifier.
|
Source code in gemini.py
| @staticmethod
def normalize_name( name: str ) -> str:
"""Create a valid Google ADK agent identifier.
Purpose:
Converts a human-readable name to the established lowercase identifier format,
replacing unsupported characters and prefixing identifiers beginning with a digit.
Args:
name (str): Nonblank human-readable agent name.
Returns:
str: Normalized ADK identifier.
Raises:
Error: If the name is invalid or cannot produce a usable identifier.
"""
try:
throw_if( 'name', name )
if not isinstance( name, str ):
raise TypeError( 'Argument "name" must be a string!' )
value = re.sub( r'[^A-Za-z0-9_]+', '_', name.strip( ) ).strip( '_' ).lower( )
if not value:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
return f'agent_{value}' if value[ 0 ].isdigit( ) else value
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'normalize_name( name: str ) -> str'
Logger( ).write( exception )
raise exception
|
create_runner() -> Runner
Create an isolated provider runner.
Purpose
Creates a native ADK runner with an independent in-memory session service and
automatic session creation for an invocation.
Returns:
| Name | Type |
Description |
Runner |
Runner
|
Google ADK runner configured for this agent.
|
Raises:
| Type |
Description |
Error
|
If runner construction fails.
|
Source code in gemini.py
| def create_runner( self ) -> Runner:
"""Create an isolated provider runner.
Purpose:
Creates a native ADK runner with an independent in-memory session service and
automatic session creation for an invocation.
Returns:
Runner: Google ADK runner configured for this agent.
Raises:
Error: If runner construction fails.
"""
try:
return Runner( agent=self, app_name=f'minions_{self.name}',
session_service=InMemorySessionService( ), auto_create_session=True, )
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'create_runner( self ) -> Runner'
Logger( ).write( exception )
raise exception
|
create_content(prompt: str) -> types.Content
Create provider-native user content.
Purpose
Validates and stores a public caller's prompt and constructs a native Gemini user
content object for that prompt.
Parameters:
| Name |
Type |
Description |
Default |
prompt
|
str
|
Nonblank user input for the workflow.
|
required
|
Returns:
| Type |
Description |
Content
|
types.Content: Google Gen AI user content object.
|
Raises:
| Type |
Description |
Error
|
If the prompt is invalid or content construction fails.
|
Source code in gemini.py
| def create_content( self, prompt: str ) -> types.Content:
"""Create provider-native user content.
Purpose:
Validates and stores a public caller's prompt and constructs a native Gemini user
content object for that prompt.
Args:
prompt (str): Nonblank user input for the workflow.
Returns:
types.Content: Google Gen AI user content object.
Raises:
Error: If the prompt is invalid or content construction fails.
"""
try:
throw_if( 'prompt', prompt )
if not isinstance( prompt, str ):
raise TypeError( 'Argument "prompt" must be a string!' )
self.prompt = prompt
return types.Content( role='user', parts=[ types.Part.from_text( text=self.prompt ) ] )
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'create_content( self, prompt: str ) -> types.Content'
Logger( ).write( exception )
raise exception
|
select_result(events: Sequence[Event]) -> Event
Select the final event from an invocation.
Purpose
Selects the last event marked as a final response, falling back to the last event
when the invocation emitted events but no final response.
Parameters:
| Name |
Type |
Description |
Default |
events
|
Sequence[Event]
|
Nonempty sequence of events emitted by Google ADK.
|
required
|
Returns:
| Name | Type |
Description |
Event |
Event
|
Final-response event or the last emitted event.
|
Raises:
| Type |
Description |
Error
|
If no events are supplied, the sequence is invalid, or selection fails.
|
Source code in gemini.py
| def select_result( self, events: Sequence[ Event ] ) -> Event:
"""Select the final event from an invocation.
Purpose:
Selects the last event marked as a final response, falling back to the last event
when the invocation emitted events but no final response.
Args:
events (Sequence[Event]): Nonempty sequence of events emitted by Google ADK.
Returns:
Event: Final-response event or the last emitted event.
Raises:
Error: If no events are supplied, the sequence is invalid, or selection fails.
"""
try:
throw_if( 'events', events )
if not isinstance( events, Sequence ) or isinstance( events, (str, bytes, bytearray) ):
raise TypeError( 'Argument "events" must be a sequence of ADK events!' )
if len( events ) == 0:
raise ValueError( 'Argument "events" cannot be empty!' )
final_events = [ event for event in events if event.is_final_response( ) ]
return final_events[ -1 ] if final_events else events[ -1 ]
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'select_result( self, events: Sequence[ Event ] ) -> Event'
Logger( ).write( exception )
raise exception
|
run(prompt: str) -> Event
Execute the complete Gemini workflow synchronously.
Purpose
Runs the native agent in a new isolated session, collecting its events and selecting
the final response without changing the native return type.
Parameters:
| Name |
Type |
Description |
Default |
prompt
|
str
|
Nonblank user input for the workflow.
|
required
|
Returns:
| Name | Type |
Description |
Event |
Event
|
Final provider-native event, or the last event when no final event is emitted.
|
Raises:
| Type |
Description |
Error
|
If validation, content construction, or native runner execution fails.
|
Source code in gemini.py
| def run( self, prompt: str ) -> Event:
"""Execute the complete Gemini workflow synchronously.
Purpose:
Runs the native agent in a new isolated session, collecting its events and selecting
the final response without changing the native return type.
Args:
prompt (str): Nonblank user input for the workflow.
Returns:
Event: Final provider-native event, or the last event when no final event is emitted.
Raises:
Error: If validation, content construction, or native runner execution fails.
"""
try:
throw_if( 'prompt', prompt )
if not isinstance( prompt, str ):
raise TypeError( 'Argument "prompt" must be a string!' )
self.prompt = prompt
self.result = None
self.events = [ ]
content = types.Content( role='user', parts=[ types.Part.from_text( text=self.prompt ) ] )
runner = self.create_runner( )
events = list( runner.run( user_id=self.name, session_id=uuid4( ).hex,
new_message=content, run_config=RunConfig( max_llm_calls=self.max_turns ), ) )
self.events = events
self.result = self.select_result( self.events )
return self.result
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'run( self, prompt: str ) -> Event'
Logger( ).write( exception )
raise exception
|
run_async(prompt: str) -> Event
async
Execute the complete Gemini workflow asynchronously.
Purpose
Runs the native agent in a new isolated session, collecting its events and selecting
the final response without changing the native return type.
Parameters:
| Name |
Type |
Description |
Default |
prompt
|
str
|
Nonblank user input for the workflow.
|
required
|
Returns:
| Name | Type |
Description |
Event |
Event
|
Final provider-native event, or the last event when no final event is emitted.
|
Raises:
| Type |
Description |
Error
|
If validation, content construction, or native runner execution fails.
|
Source code in gemini.py
| async def run_async( self, prompt: str ) -> Event:
"""Execute the complete Gemini workflow asynchronously.
Purpose:
Runs the native agent in a new isolated session, collecting its events and selecting
the final response without changing the native return type.
Args:
prompt (str): Nonblank user input for the workflow.
Returns:
Event: Final provider-native event, or the last event when no final event is emitted.
Raises:
Error: If validation, content construction, or native runner execution fails.
"""
try:
throw_if( 'prompt', prompt )
if not isinstance( prompt, str ):
raise TypeError( 'Argument "prompt" must be a string!' )
self.prompt = prompt
self.result = None
self.events = [ ]
content = types.Content( role='user', parts=[ types.Part.from_text( text=self.prompt ) ] )
runner = self.create_runner( )
events = [ event async for event in runner.run_async( user_id=self.name,
session_id=uuid4( ).hex, new_message=content,
run_config=RunConfig( max_llm_calls=self.max_turns ), ) ]
self.events = events
self.result = self.select_result( self.events )
return self.result
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'run_async( self, prompt: str ) -> Event'
Logger( ).write( exception )
raise exception
|
stream(prompt: str) -> AsyncIterator[Event]
async
Stream a complete Gemini workflow with automatic tool handling.
Purpose
Runs a new isolated invocation using SSE and yields native events while retaining
its final response or most recent available event.
Parameters:
| Name |
Type |
Description |
Default |
prompt
|
str
|
Nonblank user input for the workflow.
|
required
|
Yields:
| Name | Type |
Description |
Event |
AsyncIterator[Event]
|
Provider-native streamed ADK event.
|
Raises:
| Type |
Description |
Error
|
If validation, content construction, or native runner execution fails.
|
Source code in gemini.py
| async def stream( self, prompt: str ) -> AsyncIterator[ Event ]:
"""Stream a complete Gemini workflow with automatic tool handling.
Purpose:
Runs a new isolated invocation using SSE and yields native events while retaining
its final response or most recent available event.
Args:
prompt (str): Nonblank user input for the workflow.
Yields:
Event: Provider-native streamed ADK event.
Raises:
Error: If validation, content construction, or native runner execution fails.
"""
try:
throw_if( 'prompt', prompt )
if not isinstance( prompt, str ):
raise TypeError( 'Argument "prompt" must be a string!' )
self.prompt = prompt
self.result = None
self.events = [ ]
content = types.Content( role='user', parts=[ types.Part.from_text( text=self.prompt ) ] )
runner = self.create_runner( )
events = self.events
result: Event | None = None
async for event in runner.run_async( user_id=self.name, session_id=uuid4( ).hex,
new_message=content, run_config=RunConfig( max_llm_calls=self.max_turns,
streaming_mode=StreamingMode.SSE, ) ):
events.append( event )
if event.is_final_response( ):
result = event
if self.events is events:
self.result = result
yield event
if self.events is events:
self.result = result if result is not None else (events[ -1 ] if events else None)
except Error:
raise
except Exception as e:
exception = Error( e )
exception.module = 'gemini'
exception.cause = 'Minion'
exception.method = 'stream( self, prompt: str ) -> AsyncIterator[ Event ]'
Logger( ).write( exception )
raise exception
|
DataMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for data workflows.
Purpose
Provides the named data agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
GovernanceMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for governance workflows.
Purpose
Provides the named governance agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
ResearchMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for research workflows.
Purpose
Provides the named research agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
CodingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for software workflows.
Purpose
Provides the named software agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
WritingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for writing workflows.
Purpose
Provides the named writing agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
PlanningMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for planning workflows.
Purpose
Provides the named planning agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
ComplianceMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for compliance, legal, and budget workflows.
Purpose
Provides the named compliance, legal, and budget agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
BusinessMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for business, finance, and marketing workflows.
Purpose
Provides the named business, finance, and marketing agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
ImageGenerationMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for image-generation workflows.
Purpose
Provides the named image-generation agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
ImageAnalysisMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for image-analysis workflows.
Purpose
Provides the named image-analysis agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
ImageEditingMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for image-editing workflows.
Purpose
Provides the named image-editing agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
TranslationMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for translation workflows.
Purpose
Provides the named translation agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
TranscriptionMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for transcription workflows.
Purpose
Provides the named transcription agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|
SpeechMinion(model: str, instructions: str, tools: Sequence[GeminiTool] | None = None, max_turns: int = 10, name: str | None = None)
Bases: Minion
Gemini Minion specialized for speech workflows.
Purpose
Provides the named speech agent specialization while inheriting the native
provider execution contract and caller-selected tools from Minion.
Attributes:
| Name |
Type |
Description |
minion_name |
str
|
Default display name for this specialization.
|
Source code in gemini.py
| def __init__( self, model: str, instructions: str, tools: Sequence[ GeminiTool ] | None=None, max_turns: int=10, name: str | None=None ) -> None:
"""Initialize a Gemini Minion.
Purpose:
Initializes the native ADK agent and its Pydantic fields without making a model
request. Converts the display name to a valid ADK identifier and configures
explicit API-key authentication when a key is available; otherwise retains native
SDK authentication and model resolution.
Args:
model (str): Nonblank Gemini model identifier.
instructions (str): Nonblank system instructions for the agent.
tools (Sequence[GeminiTool] | None): Optional native tools; defaults to no tools.
max_turns (int): Maximum model calls per execution; defaults to 10 and must be positive.
name (str | None): Optional nonblank name overriding the implementation default.
Returns:
None: Initializes the native agent and its execution configuration.
Raises:
ValueError: If a required string, normalized identifier, or model-call limit is invalid.
TypeError: If tools is supplied as an invalid sequence.
"""
if not isinstance( model, str ) or not model.strip( ):
raise ValueError( 'Argument "model" must be a nonblank string!' )
if not isinstance( instructions, str ) or not instructions.strip( ):
raise ValueError( 'Argument "instructions" must be a nonblank string!' )
if type( max_turns ) is not int or max_turns < 1:
raise ValueError( 'Argument "max_turns" must be a positive integer!' )
default_name = type( self ).model_fields[ 'minion_name' ].default
display_name = default_name if name is None else name
if not isinstance( display_name, str ) or not display_name.strip( ):
raise ValueError( 'Argument "name" must be a nonblank string!' )
if tools is not None and (not isinstance( tools, Sequence ) or isinstance( tools, (str, bytes, bytearray) )):
raise TypeError( 'Argument "tools" must be a sequence of native tools!' )
provider_name = re.sub( r'[^A-Za-z0-9_]+', '_', display_name.strip( ) ).strip( '_' ).lower( )
if not provider_name:
raise ValueError( 'Argument "name" must produce a valid agent identifier!' )
if provider_name[ 0 ].isdigit( ):
provider_name = f'agent_{provider_name}'
super( ).__init__( name=provider_name, display_name=display_name, model=model,
instruction=instructions, tools=list( tools ) if tools is not None else [ ], max_turns=max_turns, )
self.api_key = cfg.GOOGLE_API_KEY or cfg.GEMINI_API_KEY
if self.api_key:
self.model = Gemini( model=self.model, client_kwargs={ 'api_key': self.api_key } )
|