symfonic.core.plugins.dispatcher¶
dispatcher ¶
Dispatcher for inject_contributions / inject_system_prompt hooks.
Item 14 (7.4) plugin-API redesign: this module is the bridge between
legacy inject_system_prompt plugins and the new
inject_contributions API. The engine calls
:func:dispatch_plugin_contributions once per turn; the returned list
is grouped by position and rendered into the L1/L2 prompt slots.
Design note: .claude/docs/2026-05-26-plugin-api-redesign-design.md.
dispatch_plugin_contributions
async
¶
dispatch_plugin_contributions(
plugins: list[Any],
state: PromptState,
*,
short_circuit_warned: set[str] | None = None,
kernel_warned: set[str] | None = None,
) -> list[PluginContribution]
Collect contributions from every plugin, applying hybrid dispatch.
Per the design's §4 / Q1 decision (Hybrid, Option C):
- If
hasattr(plugin, "inject_contributions"), that method is called and its returned list is used.inject_system_promptis NOT called for this plugin (no double-emit). - Otherwise,
inject_system_promptis called; the returned string is wrapped in a syntheticPluginContribution(content=..., position="cached", header="")so downstream rendering uses one code path.header=""skips the auto-header here because the engine renders legacy plugins via :func:render_position_groupand we want byte-identical output to the historicalPluginPromptSection.render(the legacy path builds its own### {plugin.name}\n{body}header — see theheader_for_legacyargument below).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugins
|
list[Any]
|
Plugin instances in registration order. |
required |
state
|
PromptState
|
|
required |
short_circuit_warned
|
set[str] | None
|
Set of plugin origins that have already received the "defines both methods" INFO log (Q-C default). The caller (engine) maintains the set across turns so the log fires at most once per (plugin, agent-instance) pair. |
None
|
kernel_warned
|
set[str] | None
|
Set of plugin origins that have already received
the "position=kernel reserved" WARNING log. Same lifecycle
as |
None
|
Returns:
| Type | Description |
|---|---|
list[PluginContribution]
|
Ordered list of |
list[PluginContribution]
|
populated and |
list[PluginContribution]
|
|
list[PluginContribution]
|
|
list[PluginContribution]
|
Python's stable sort preserves registration order and intra- |
list[PluginContribution]
|
plugin emission order on ties. |