Skip to content

Claude API

Claude Minions use Anthropic's native beta tool runners for complete hosted and local tool workflows.

claude


Assembly: minions Filename: claude.py Author: Terry D. Eppler Created: 09-05-2026

Last Modified By: Terry D. Eppler Last Modified On: 09-06-2026


 claude.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

Anthropic Claude Minion implementations.

SyncAdapter(tool: BetaFunctionTool)

Bases: BetaFunctionTool

Native synchronous tool adapter.

Purpose

Uses the original Anthropic tool's validated call and declaration, converting only its return value at the provider result boundary.

Attributes:

Name Type Description
tool BetaFunctionTool

Original native synchronous tool.

Initialize the native synchronous adapter.

Purpose

Retains the original callable and schema without modifying the supplied tool.

Parameters:

Name Type Description Default
tool BetaFunctionTool

Original native synchronous tool.

required
Source code in claude.py
def __init__( self, tool: BetaFunctionTool ) -> None:
	"""Initialize the native synchronous adapter.

	Purpose:
		Retains the original callable and schema without modifying the supplied tool.

	Args:
		tool (BetaFunctionTool): Original native synchronous tool.
	"""
	self.tool = tool
	super( ).__init__( func=self.tool.func, name=self.tool.name, description=self.tool.description,
		input_schema=self.tool.input_schema )

to_dict() -> BetaToolParam

Return the original provider declaration.

Purpose

Preserves native schema and additional provider declaration metadata.

Returns:

Name Type Description
BetaToolParam BetaToolParam

Original native tool declaration.

Source code in claude.py
def to_dict( self ) -> BetaToolParam:
	"""Return the original provider declaration.

	Purpose:
		Preserves native schema and additional provider declaration metadata.

	Returns:
		BetaToolParam: Original native tool declaration.
	"""
	return self.tool.to_dict( )

call(input: object) -> str | list[Content]

Execute the original validated tool.

Purpose

Delegates input validation and execution to the original native tool and converts the result. Tool failures propagate to the native runner for error-result handling.

Parameters:

Name Type Description Default
input object

Model-generated tool arguments; an empty dictionary is valid.

required

Returns:

Type Description
str | list[Content]

str | list[Content]: Provider-compatible result content.

Source code in claude.py
def call( self, input: object ) -> str | list[ Content ]:
	"""Execute the original validated tool.

	Purpose:
		Delegates input validation and execution to the original native tool and converts
		the result. Tool failures propagate to the native runner for error-result handling.

	Args:
		input (object): Model-generated tool arguments; an empty dictionary is valid.

	Returns:
		str | list[Content]: Provider-compatible result content.
	"""
	return serialize_result( self.tool.call( input ) )

AsyncAdapter(tool: BetaFunctionTool)

Bases: BetaAsyncFunctionTool

Native asynchronous adapter for synchronous Anthropic tools.

Purpose

Executes the original validated tool in a worker thread without defining a variadic callback or changing the original tool declaration.

Attributes:

Name Type Description
tool BetaFunctionTool

Original native synchronous tool.

Initialize the native asynchronous adapter.

Purpose

Binds the explicit async call interface and retains the original schema.

Parameters:

Name Type Description Default
tool BetaFunctionTool

Original native synchronous tool.

required
Source code in claude.py
def __init__( self, tool: BetaFunctionTool ) -> None:
	"""Initialize the native asynchronous adapter.

	Purpose:
		Binds the explicit async call interface and retains the original schema.

	Args:
		tool (BetaFunctionTool): Original native synchronous tool.
	"""
	self.tool = tool
	super( ).__init__( func=self.call, name=self.tool.name, description=self.tool.description,
		input_schema=self.tool.input_schema )

to_dict() -> BetaToolParam

Return the original provider declaration.

Purpose

Preserves native schema and additional provider declaration metadata.

Returns:

Name Type Description
BetaToolParam BetaToolParam

Original native tool declaration.

Source code in claude.py
def to_dict( self ) -> BetaToolParam:
	"""Return the original provider declaration.

	Purpose:
		Preserves native schema and additional provider declaration metadata.

	Returns:
		BetaToolParam: Original native tool declaration.
	"""
	return self.tool.to_dict( )

call(input: object) -> str | list[Content] async

Execute the original validated tool asynchronously.

Purpose

Delegates validation and execution to the original native tool without blocking the event loop. Tool failures propagate to the native runner.

Parameters:

Name Type Description Default
input object

Model-generated tool arguments; an empty dictionary is valid.

required

Returns:

Type Description
str | list[Content]

str | list[Content]: Provider-compatible result content.

Source code in claude.py
async def call( self, input: object ) -> str | list[ Content ]:
	"""Execute the original validated tool asynchronously.

	Purpose:
		Delegates validation and execution to the original native tool without blocking
		the event loop. Tool failures propagate to the native runner.

	Args:
		input (object): Model-generated tool arguments; an empty dictionary is valid.

	Returns:
		str | list[Content]: Provider-compatible result content.
	"""
	result = await asyncio.to_thread( self.tool.call, input )
	return serialize_result( result )

Minion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Claude workflow agent backed by Anthropic's native Tool Runner.

Purpose

Executes synchronous, asynchronous and streamed Claude workflows with caller-selected native tools, centralized credentials and the provider-managed tool lifecycle.

Attributes:

Name Type Description
minion_name str

Default specialization name.

name str

Agent display name.

model str

Claude model identifier.

instructions str

System instructions.

tools list[ClaudeTool]

Original caller-selected tools.

sync_tools list[ClaudeTool]

Native synchronous runner tools.

async_tools list[ClaudeAsyncTool]

Native asynchronous runner tools.

max_turns int

Maximum model iterations per execution.

max_tokens int

Maximum output tokens per iteration.

api_key str

Centralized Anthropic credential.

client Anthropic

Native synchronous client.

async_client AsyncAnthropic

Native asynchronous client.

prompt str

Most recently accepted user prompt.

tool BetaFunctionTool | None

Most recently accepted public adapter argument.

result BetaMessage | BetaAsyncStreamingToolRunner[object] | None

Native execution result.

Initialize a Claude Minion.

Purpose

Stores configuration, initializes native clients and adapts local tools for the respective runner without modifying the original tool objects.

Parameters:

Name Type Description Default
model str

Nonblank Claude model identifier.

required
instructions str

Nonblank system instructions.

required
tools Sequence[ClaudeTool] | None

Optional native local or hosted tools.

None
max_turns int

Positive iteration limit; defaults to 10.

10
max_tokens int

Positive output token limit; defaults to 4096.

4096
name str | None

Optional nonblank display name overriding the specialization.

None

Raises:

Type Description
ValueError

If required strings, credentials or positive limits are invalid.

TypeError

If tools is not an appropriate sequence.

Source code in claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

create_async_tool(tool: BetaFunctionTool) -> BetaAsyncFunctionTool

Create a native asynchronous adapter.

Purpose

Retains the original tool schema and validated execution contract.

Parameters:

Name Type Description Default
tool BetaFunctionTool

Synchronous native Anthropic tool.

required

Returns:

Name Type Description
BetaAsyncFunctionTool BetaAsyncFunctionTool

Native asynchronous tool adapter.

Raises:

Type Description
Error

If argument validation or adapter construction fails.

Source code in claude.py
def create_async_tool( self, tool: BetaFunctionTool ) -> BetaAsyncFunctionTool:
	"""Create a native asynchronous adapter.

	Purpose:
		Retains the original tool schema and validated execution contract.

	Args:
		tool (BetaFunctionTool): Synchronous native Anthropic tool.

	Returns:
		BetaAsyncFunctionTool: Native asynchronous tool adapter.

	Raises:
		Error: If argument validation or adapter construction fails.
	"""
	try:
		throw_if( 'tool', tool )
		self.tool = tool
		return AsyncAdapter( self.tool )
	except Exception as e:
		exception = Error( e )
		exception.module = 'claude'
		exception.cause = 'Minion'
		exception.method = 'create_async_tool( self, tool: BetaFunctionTool ) -> BetaAsyncFunctionTool'
		Logger( ).write( exception )
		raise exception

run(prompt: str) -> BetaMessage

Execute the complete Claude workflow synchronously.

Purpose

Delegates the complete model and local tool execution loop to Anthropic.

Parameters:

Name Type Description Default
prompt str

Nonblank user input for the workflow.

required

Returns:

Name Type Description
BetaMessage BetaMessage

Native completed message.

Raises:

Type Description
Error

If validation or the native runner execution fails.

Source code in claude.py
def run( self, prompt: str ) -> BetaMessage:
	"""Execute the complete Claude workflow synchronously.

	Purpose:
		Delegates the complete model and local tool execution loop to Anthropic.

	Args:
		prompt (str): Nonblank user input for the workflow.

	Returns:
		BetaMessage: Native completed message.

	Raises:
		Error: If validation or the 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.sync_tools = [ SyncAdapter( tool ) for tool in self.tools ]
		runner = self.client.beta.messages.tool_runner( model=self.model,
			max_tokens=self.max_tokens, max_iterations=self.max_turns, system=self.instructions,
			tools=self.sync_tools, messages=[ { 'role': 'user', 'content': self.prompt } ], )
		self.result = runner.until_done( )
		return self.result
	except Exception as e:
		exception = Error( e )
		exception.module = 'claude'
		exception.cause = 'Minion'
		exception.method = 'run( self, prompt: str ) -> BetaMessage'
		Logger( ).write( exception )
		raise exception

run_async(prompt: str) -> BetaMessage async

Execute the complete Claude workflow asynchronously.

Purpose

Delegates the complete model and local tool execution loop to Anthropic.

Parameters:

Name Type Description Default
prompt str

Nonblank user input for the workflow.

required

Returns:

Name Type Description
BetaMessage BetaMessage

Native completed message.

Raises:

Type Description
Error

If validation or the native runner execution fails.

Source code in claude.py
async def run_async( self, prompt: str ) -> BetaMessage:
	"""Execute the complete Claude workflow asynchronously.

	Purpose:
		Delegates the complete model and local tool execution loop to Anthropic.

	Args:
		prompt (str): Nonblank user input for the workflow.

	Returns:
		BetaMessage: Native completed message.

	Raises:
		Error: If validation or the native runner execution fails.
	"""
	try:
		throw_if( 'prompt', prompt )
		self.prompt = prompt
		self.result = None
		runner = self.async_client.beta.messages.tool_runner( model=self.model,
			max_tokens=self.max_tokens, max_iterations=self.max_turns, system=self.instructions,
			tools=self.async_tools, messages=[ { 'role': 'user', 'content': self.prompt } ], )
		self.result = await runner.until_done( )
		return self.result
	except Exception as e:
		exception = Error( e )
		exception.module = 'claude'
		exception.cause = 'Minion'
		exception.method = 'run_async( self, prompt: str ) -> BetaMessage'
		Logger( ).write( exception )
		raise exception

stream(prompt: str) -> BetaAsyncStreamingToolRunner[object]

Start the native async streaming runner.

Purpose

Returns the native streaming runner for caller-managed consumption.

Parameters:

Name Type Description Default
prompt str

Nonblank user input for the workflow.

required

Returns:

Type Description
BetaAsyncStreamingToolRunner[object]

BetaAsyncStreamingToolRunner[ object ]: Native streaming runner.

Raises:

Type Description
Error

If validation or the native runner creation fails.

Source code in claude.py
def stream( self, prompt: str ) -> BetaAsyncStreamingToolRunner[ object ]:
	"""Start the native async streaming runner.

	Purpose:
		Returns the native streaming runner for caller-managed consumption.

	Args:
		prompt (str): Nonblank user input for the workflow.

	Returns:
		BetaAsyncStreamingToolRunner[ object ]: Native streaming runner.

	Raises:
		Error: If validation or the native runner creation fails.
	"""
	try:
		throw_if( 'prompt', prompt )
		self.prompt = prompt
		self.result = None
		runner = self.async_client.beta.messages.tool_runner( model=self.model,
			max_tokens=self.max_tokens, max_iterations=self.max_turns, system=self.instructions,
			tools=self.async_tools, messages=[ { 'role': 'user', 'content': self.prompt } ], stream=True, )
		self.result = runner
		return self.result
	except Exception as e:
		exception = Error( e )
		exception.module = 'claude'
		exception.cause = 'Minion'
		exception.method = 'stream( self, prompt: str ) -> BetaAsyncStreamingToolRunner[ object ]'
		Logger( ).write( exception )
		raise exception

DataMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

GovernanceMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

ResearchMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

CodingMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

WritingMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

PlanningMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

ComplianceMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

BusinessMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

ImageGenerationMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

ImageAnalysisMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

ImageEditingMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

TranslationMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

TranscriptionMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

SpeechMinion(model: str, instructions: str, tools: Sequence[ClaudeTool] | None = None, max_turns: int = 10, max_tokens: int = 4096, name: str | None = None)

Bases: Minion

Claude 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 claude.py
def __init__( self, model: str, instructions: str, tools: Sequence[ ClaudeTool ] | None=None,
	max_turns: int=10, max_tokens: int=4096, name: str | None=None ) -> None:
	"""Initialize a Claude Minion.

	Purpose:
		Stores configuration, initializes native clients and adapts local tools for
		the respective runner without modifying the original tool objects.

	Args:
		model (str): Nonblank Claude model identifier.
		instructions (str): Nonblank system instructions.
		tools (Sequence[ClaudeTool] | None): Optional native local or hosted tools.
		max_turns (int): Positive iteration limit; defaults to 10.
		max_tokens (int): Positive output token limit; defaults to 4096.
		name (str | None): Optional nonblank display name overriding the specialization.

	Raises:
		ValueError: If required strings, credentials or positive limits are invalid.
		TypeError: If tools is not an appropriate sequence.
	"""
	self.name = name
	self.model = model
	self.instructions = instructions
	self.tools = list( tools ) if tools is not None else [ ]
	self.max_turns = max_turns
	self.max_tokens = max_tokens
	self.api_key = cfg.ANTHROPIC_API_KEY
	self.sync_tools = [ ]
	self.async_tools = [ AsyncAdapter( tool ) for tool in self.tools ]
	self.client = Anthropic( api_key=self.api_key )
	self.async_client = AsyncAnthropic( api_key=self.api_key )
	self.prompt = ''
	self.tool = None
	self.result = None

serialize_result(result: object) -> str | list[Content]

Convert a local tool result for the Anthropic Tool Runner.

Purpose

Preserves native text and content-block collections and serializes structured Python values as JSON text. Null, false, zero and empty collections remain legitimate results.

Parameters:

Name Type Description Default
result object

Value returned by the selected local tool, including None.

required

Returns:

Type Description
str | list[Content]

str | list[Content]: Anthropic-compatible tool-result content.

Raises:

Type Description
TypeError

If an unsupported structured value is returned.

ValueError

If the value cannot be encoded as valid JSON.

Source code in claude.py
def serialize_result( result: object ) -> str | list[ Content ]:
	"""Convert a local tool result for the Anthropic Tool Runner.

	Purpose:
		Preserves native text and content-block collections and serializes structured Python
		values as JSON text. Null, false, zero and empty collections remain legitimate results.

	Args:
		result (object): Value returned by the selected local tool, including None.

	Returns:
		str | list[Content]: Anthropic-compatible tool-result content.

	Raises:
		TypeError: If an unsupported structured value is returned.
		ValueError: If the value cannot be encoded as valid JSON.
	"""
	if isinstance( result, str ):
		return result
	if isinstance( result, Iterator ):
		result = list( result )
	if isinstance( result, (list, tuple) ) and result and all(
			isinstance( block, dict ) and block.get( 'type' ) in ('text', 'image', 'search_result',
				'document', 'tool_reference', 'browser_state') for block in result ):
		try:
			TypeAdapter( list[ Content ] ).validate_python( result )
		except ValidationError:
			pass
		else:
			return list( result )
	return json.dumps( serialize_value( result ), ensure_ascii=False, allow_nan=False )