Skip to content

feat: add plugin architecture (amico-plugin crate)#126

Merged
takasaki404 merged 2 commits intomainfrom
copilot/add-plugin-architecture-support
Feb 6, 2026
Merged

feat: add plugin architecture (amico-plugin crate)#126
takasaki404 merged 2 commits intomainfrom
copilot/add-plugin-architecture-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

The framework lacks an extensibility mechanism for third-party capabilities (e.g., A2A connectors, platform integrations). Agent developers shouldn't have to rewrite protocol-level infrastructure — a plugin should provide it.

New amico-plugin crate

Sits between runtime and application layers. Depends on amico-system + amico-runtime, no circular deps.

  • Plugin — core trait with lifecycle hooks (on_start/on_shutdown), config, and identity
  • ToolPlugin — plugins that provide Tool implementations to the agent
  • PluginSet — composable plugin collections with unified lifecycle (start_all/shutdown_all); impls for () and single-plugin tuples
  • PluginRuntime — extends Runtime with plugin management
  • PluginError — error enum for plugin operations

Event-related plugin traits (in amico crate)

These live in amico because they depend on the Event trait defined there:

  • EventSourcePlugin — introduces new event streams into the runtime (the A2A use case)
  • EventInterceptor — before/after middleware for event dispatch (logging, auth, metrics)

Usage pattern

impl Plugin for A2APlugin {
    type Config = A2AConfig;
    type Error = A2AError;

    fn name(&self) -> &str { "a2a-connector" }
    fn version(&self) -> &str { "1.0.0" }

    fn build(config: A2AConfig) -> Result<Self, A2AError> {
        Ok(Self { endpoint: config.endpoint })
    }

    async fn on_start(&mut self) -> Result<(), A2AError> { /* connect */ Ok(()) }
    async fn on_shutdown(&mut self) -> Result<(), A2AError> { /* disconnect */ Ok(()) }
}

// Agent developer just handles the event:
impl EventHandler<A2ARequestEvent> for MyHandler {
    async fn handle(&self, event: A2ARequestEvent, ctx: &AgentContext)
        -> Result<A2AResponse, HandlerError>
    {
        let response = self.agent.execute(ctx, event.payload).await?;
        Ok(A2AResponse::from(response))
    }
}

Follows existing conventions: traits + generics, no Box<dyn>, impl Future returns, zero-cost abstractions. ARCHITECTURE.md updated with the new plugin layer section.

Original prompt

Consider a plugin architecture.

For example, enabling an agent to handle A2A events from an agent collaboration platform. The agent don't need to re-write the full A2A event handler. A plugin provides A2A connector to that platform. The agent developer just focus on how to handle the A2A request event.

The plugin system should cover all aspects of the agent lifecycle. I have no idea how to integrate that. Help me inject the plugin architecture into the current design.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Introduces a plugin system covering all aspects of the agent lifecycle:
- Plugin trait: core lifecycle hooks (on_start, on_shutdown)
- ToolPlugin: plugins that provide tools
- EventSourcePlugin: plugins that provide event streams
- EventInterceptor: middleware for event handling
- PluginSet: composable plugin collections
- PluginRuntime: runtime with plugin support

Co-authored-by: takasaki404 <193405421+takasaki404@users.noreply.github.com>
Copilot AI changed the title [WIP] Add plugin architecture for handling A2A events feat: add plugin architecture (amico-plugin crate) Feb 6, 2026
Copilot AI requested a review from takasaki404 February 6, 2026 12:09
@takasaki404 takasaki404 marked this pull request as ready for review February 6, 2026 12:17
@takasaki404 takasaki404 merged commit fc3f6f6 into main Feb 6, 2026
0 of 4 checks passed
@takasaki404 takasaki404 deleted the copilot/add-plugin-architecture-support branch February 6, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants