In-process plugin
Goal: add an in-process plugin that the engine discovers and resolves through a port.
Everything the engine talks to is a plugin: model providers, stores, sandboxes, forges, tools. The engine is a standalone component. It never imports a plugin: it discovers one and speaks through a port. Removing a plugin never breaks the engine build.
Prerequisites
- A Python package the engine's environment can import.
Steps
-
Add one entry point in the group
afe.pluginsto your Python package. The engine discovers every installed entry point at startup, and registers the ports the plugin declares.# pyproject.toml[project.entry-points."afe.plugins"]afe-models = "afe_plugins.models:PLUGIN" -
Implement the plugin.
describereturns aPluginDescriptor, andresolvereturns the implementation for a port and name.from afe_sdk.plugin import PLUGIN_API, PluginDescriptor, PortSpecclass MyPlugin:def describe(self):return PluginDescriptor(name="my-plugin",api_version=PLUGIN_API,ports=[PortSpec(port="models", name="my-provider")],)def resolve(self, port, name):return MyProvider()PLUGIN = MyPlugin() -
To ship a node type, declare it under the
nodesport.config_schemais the JSON Schema of the keys a manifest gives that node, and it is required. Return the spec fromdescribe, inports, so the engine registers the node type. Declare every key at the rootproperties, or as a rootpatternPropertiespattern. Constraints may live in$ref,allOfor a conditional branch, but a key not declared at the root is an unknown key.from afe_sdk.node import NodeReply, NodeRequestfrom afe_sdk.plugin import PortSpecclass TemplateNode:async def run(self, request: NodeRequest) -> NodeReply:return NodeReply(artifact={"text": request.options["template"]})SPEC = PortSpec(port="nodes",name="template",config_schema={"type": "object","properties": {"template": {"type": "string"}},"required": ["template"],},)The engine refuses a
nodesport without aconfig_schema, and names the plugin. It hands the node aNodeRequest: its own keys inoptions, and only the artifacts it declares inreadsinartifacts. The request also names the ticket, the flow, the node, the round and the activation.writesandoutput_schemaname the artifact the node must return, and its JSON Schema. The node returns that artifact inNodeReply.artifact. -
To ship tools, declare them under the
toolsetsport.resolvereturns aToolSet, whosetoolslists the tools the plugin offers.from afe_sdk.tool import Toolclass Words:async def tools(self) -> list[Tool]:return [Count()]toolsetsis not thetoolsport.toolslists the tools of an MCP server, and atoolsetssource is a plugin. In an agent, cite these tools asplugin:<source>.<tool>orplugin:<source>.*.
Notes
apiVersion is the manifest version (afe.dev/v1alpha1). A different major version is refused
with a clear error, and so are two plugins on the same (port, name).
Once the plugins are loaded, afe run, afe serve and afe worker check the configuration
against them. An unknown node type or plugin tool stops the command before any ticket starts. So
does an unknown key of a plugin node, or a value of the wrong type. The command lists every
problem it finds. afe validate loads no plugin, so it keeps a plugin node type as a warning.
A plugin node type cannot use the engine's own node field names. agent, run, message,
actions, requireComment, attachFiles, uses, with, over, lane, itemAs, maxItems
and maxParallel are filled by the engine. They never reach the plugin.
Troubleshooting
A message about a manifest starts with the manifest's location. For example:
config.yaml#8: spec.nodes.heading.tempalte: unknown key.
plugin 'my-plugin' speaks afe.dev/v2alpha1, the engine speaks afe.dev/v1alpha1
describe returned an api_version with a different major version than the engine's
PLUGIN_API. Match your plugin's major version to the engine you install it against.
port models/my-provider is provided by both 'afe-models' and 'my-plugin'
Two installed plugins declare the same (port, name). Rename your plugin's port name, or remove
the other plugin.
plugin 'my-plugin' has no 'describe' or has no 'resolve'
The class assigned to PLUGIN is missing one of the two required methods. Both describe and
resolve must exist on the object registered at the entry point.
spec.nodes.heading.type: no plugin provides the node type 'template'
No installed plugin provides a nodes port named template. Install the plugin that ships the
type, or correct the node's type.
spec.nodes.heading.tempalte: unknown key
tempalte is not a key the node type declares in the root properties of its config_schema.
The engine checks unknown keys there even when the plugin schema has no
additionalProperties: false. Correct the key, or add it to the root properties.
spec.nodes.heading.message: a built-in node key, not available to a plugin node type
message is one of the engine's node fields. The engine fills it and never passes it in
options. Rename the key in the node type's config_schema and in the flow.
spec.nodes.heading: plugin node type 'template': invalid config_schema: …
The schema the plugin declares is not valid JSON Schema. The text after the colon is the schema
library's own. Correct the config_schema the plugin returns in describe.
spec.nodes.heading.template: 3 is not of type 'string'
The value does not match the type the plugin declares for template. The text after the colon is
the schema's own. Correct the value.
plugin:words.count: no plugin provides toolsets/words (known: none)
No installed plugin provides a toolsets port named words. Install the plugin that ships the
toolset, or correct the reference. A plugin:<source>.<tool> also fails when the source exists
but its tools() list has no such tool.
See also
- Out-of-process plugin
- Architecture: the plugin contract
- The S7 third-party packages: the two example plugins this page mirrors.
- The S7 scenario: a flow that uses the node type and the tool.