symfonic.core.plugins.section¶
section ¶
PluginPromptSection -- PromptSection adapter that renders plugin prompts.
Aggregates contributions from all registered domain plugins into a single prompt section. Plugin errors are non-fatal; a failing plugin is skipped and the remaining plugins continue rendering.
7.4+: gains :meth:render_contributions which returns the new
list[PluginContribution] surface. The legacy :meth:render method
stays for external callers (and is itself implemented on top of the new
dispatcher so behaviour stays in lockstep).
PluginPromptSection
dataclass
¶
PluginPromptSection(
name: str = "Domain Plugin",
required: bool = False,
priority: int = 15,
cache_breakpoint: bool = True,
cache_ttl: Literal["5m", "1h"] | None = None,
_last_contribs: list[PluginContribution] = list(),
_plugins: list[BaseDomainPlugin] = list(),
_short_circuit_warned: set[str] = set(),
_kernel_warned: set[str] = set(),
)
PromptSection that renders content from all loaded domain plugins.
Satisfies the PromptSection protocol so it can be added to a PromptBuilder pipeline or rendered directly from the agent.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Section label shown in the composed prompt. |
required |
bool
|
Whether a render failure is fatal (always False here). |
priority |
int
|
Render order — 15 places it after core system context but before memory sections. |
cache_breakpoint |
bool
|
Marks the section for Anthropic prompt caching. Domain rules are stable within a session so caching is safe. |
add_plugin ¶
Register a plugin to contribute its prompt content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
BaseDomainPlugin
|
Any object satisfying BaseDomainPlugin protocol. |
required |
render
async
¶
Render all plugin contributions into a single string.
Each plugin's output is prefixed with a ### <name> heading.
Plugins that return empty strings are silently skipped.
Plugins that raise exceptions are logged at DEBUG level and skipped.
7.4+: implemented on top of :meth:render_contributions so the
legacy single-string surface and the new contribution surface
agree byte-for-byte for plugins that only define
inject_system_prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
PromptState
|
Current prompt state forwarded to each plugin. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Combined plugin content, or empty string if no plugins produced |
str
|
non-empty output. |
Source code in src/symfonic/core/plugins/section.py
render_contributions
async
¶
Collect every plugin's contributions into a flat ordered list.
Wraps :func:dispatch_plugin_contributions and threads the
section's per-instance latches so observability logs (legacy
short-circuit INFO, kernel-position WARNING) fire at most once
per (plugin, section-instance) pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
PromptState
|
PromptState forwarded to each plugin. |
required |
Returns:
| Type | Description |
|---|---|
list[PluginContribution]
|
Ordered list of |
list[PluginContribution]
|
|
list[PluginContribution]
|
( |
Source code in src/symfonic/core/plugins/section.py
resolve_cache_ttl ¶
Compute the effective cache TTL hint for this section.
v7.24.0 precedence rule (architect-fixed):
- Section-level :attr:
cache_ttlwins when set. One section maps to one wire cache breakpoint, so the section's value is authoritative for the marker on its terminal block. - When section-level is
None, the strongest contribution- level TTL from the LAST rendered contribution list bubbles up:"1h">"5m">None. Lets adopters declare TTL intent at the contribution granularity without splitting a section.
Callers MUST invoke this AFTER render(state) /
render_contributions(state) has populated _last_contribs;
otherwise the bubble-up step sees no contributions and falls
back to None. This is the contract :class:PromptBuilder
relies on.