Skip to content
docsv0.2.0

IntelligenceProviderInterface

Interface for Intelligence Providers. Intelligence Providers analyze tool execution context and generate enriched information (suggestions, warnings, next actions, etc.) that helps the LLM make better decisions. Providers can run in two phases: - Pre-execution: Before the tool runs (for warnings, would_block) - Post-execution: After the tool runs (for suggestions, next_actions)

IntelligenceProviderInterface::getName()

abstract public function getName(): string

Get provider name for identification and debugging.

Returns

Unique provider name (e.g., "entity_completeness", "next_actions")

IntelligenceProviderInterface::supports()

abstract public function supports(Milpa\ToolRuntime\Contracts\IntelligenceContext $context): bool

Check if this provider applies to the given context. Use this to filter providers by: - Tool name patterns (e.g., only for create_* tools) - Entity types (e.g., only for Note entities) - Execution phase (e.g., only post-execution)

Parameters

Parameters of supports()
NameTypeDescription
$contextIntelligenceContextThe execution context

Returns

True if this provider should run

IntelligenceProviderInterface::provide()

abstract public function provide(Milpa\ToolRuntime\Contracts\IntelligenceContext $context): Milpa\ToolRuntime\Contracts\ToolIntelligence

Generate intelligence for the given context. Called by the IntelligenceAggregator when supports() returns true. Should return a ToolIntelligence with relevant information.

Parameters

Parameters of provide()
NameTypeDescription
$contextIntelligenceContextThe execution context

Returns

The generated intelligence

IntelligenceProviderInterface::getPriority()

abstract public function getPriority(): int

Get provider priority. Higher priority providers run first and their output can influence later providers. Recommended ranges: - 100+: Core providers (completeness, business rules) - 50-99: Standard providers (next actions, suggestions) - 0-49: Custom/plugin providers

Returns

Priority value (higher = runs first)

IntelligenceProviderInterface::getPhase()

abstract public function getPhase(): string

Get the execution phase for this provider. - "pre": Runs before tool execution (for warnings, would_block) - "post": Runs after tool execution (for suggestions, next_actions, context) - "both": Runs in both phases

Returns

One of: "pre", "post", "both"