OSSS.ai.agents.protocols¶
OSSS.ai.agents.protocols
¶
Agent constructor protocols for type-safe agent registration and creation.
This module defines protocols that specify the expected constructor signatures
for different types of agents, enabling static type checking while eliminating
runtime introspection. These protocols replace the need for inspect.signature()
calls and associated # type: ignore[call-arg] usage.
AgentConstructorPattern
¶
Bases: Enum
Enumeration of agent constructor patterns for type-safe instantiation.
LLMRequiredAgentProtocol
¶
Bases: Protocol
Protocol for agents that require an LLM interface as the first parameter.
This protocol covers agents like RefinerAgent, CriticAgent that have: init(self, llm: LLMInterface, config: Optional[ConfigType] = None)
__init__(llm, config=None, **kwargs)
¶
Initialize agent with required LLM interface.
LLMOptionalAgentProtocol
¶
Bases: Protocol
Protocol for agents that accept an optional LLM interface.
This protocol covers agents like HistorianAgent, SynthesisAgent that have: init(self, llm: Optional[Union[LLMInterface, str]] = "default", ...)
__init__(llm='default', **kwargs)
¶
Initialize agent with optional LLM interface.
StandardAgentProtocol
¶
Bases: Protocol
Protocol for agents that follow the standard BaseAgent pattern.
This protocol covers BaseAgent and potential future agents that have: init(self, name: str, **kwargs: Any)
__init__(name, **kwargs)
¶
Initialize agent with name and optional parameters.
FlexibleAgentProtocol
¶
Bases: Protocol
Protocol for agents with completely flexible constructor signatures.
This is a fallback protocol for any agent that doesn't fit the other patterns.
__init__(*args, **kwargs)
¶
Initialize agent with flexible parameters.
RefinerAgentProtocol
¶
Bases: Protocol
Specific protocol for RefinerAgent constructor.
__init__(llm, config=None)
¶
Initialize RefinerAgent with LLM and optional config.
CriticAgentProtocol
¶
Bases: Protocol
Specific protocol for CriticAgent constructor.
__init__(llm, config=None)
¶
Initialize CriticAgent with LLM and optional config.
HistorianAgentProtocol
¶
Bases: Protocol
Specific protocol for HistorianAgent constructor.
__init__(llm='default', search_type='hybrid', config=None)
¶
Initialize HistorianAgent with optional LLM and search config.
SynthesisAgentProtocol
¶
Bases: Protocol
Specific protocol for SynthesisAgent constructor.
__init__(llm='default', config=None)
¶
Initialize SynthesisAgent with optional LLM and config.
AgentWithLLMProtocol
¶
Bases: Protocol
Protocol for agents that have an 'llm' attribute.
This protocol enables type checking for tests and code that accesses the 'llm' attribute on agents without requiring casting to specific types.
Covers RefinerAgent, CriticAgent, HistorianAgent, and SynthesisAgent.
__init__(*args, **kwargs)
¶
Initialize agent.