mod plugin#

module plugin#

Provider plugin trait and input/output types for the ACG system.

The ProviderPlugin trait defines the contract between ACG’s provider-agnostic optimization pipeline and backend-specific translation logic. Plugins receive a PluginInput containing the original request, Prompt IR, intent bundle, and agent identity, and produce a PluginOutput with the translated request and a TranslationReport.

Design

  • Synchronous: translate is a pure data transform (JSON restructuring), not an I/O operation. This matches the LlmCodec pattern in crates/core/src/codec/traits.rs.

  • Compatibility facade: provider plugins keep their existing synchronous trait surface, but can internally split translation into semantic hint planning plus request-surface application.

  • Send + Sync: Required for storage as Arc<dyn ProviderPlugin> in concurrent contexts.

  • Object-safe: The trait is designed to be used as a trait object.

Traits

trait ProviderPlugin#

Provider plugin trait for backend-specific translation.

Plugins are stateless on the forward path. They translate provider-agnostic intents into backend-native API parameters.

Object Safety

This trait is object-safe and can be stored as Arc<dyn ProviderPlugin>.

Thread Safety

The Send + Sync bounds allow plugins to be shared across async tasks and threads.

Functions

fn capabilities(&self) -> BackendCapabilities#

Report the capabilities of the backend this plugin targets.

fn plugin_id(&self) -> &str#

Unique identifier for this plugin (e.g., “anthropic”, “openai”, “passthrough”).

fn plugin_name(&self) -> &str#

Human-readable name for this plugin.

fn translate(&self, input: &PluginInput<'_>) -> crate::acg::error::Result<PluginOutput>#

Translate intents into backend-native API parameters.

Structs and Unions

struct PluginInput<'a>#

Input data provided to a plugin for translation.

All fields are borrowed references to avoid unnecessary cloning. The lifetime 'a ties the input to the caller’s data.

original_request: &'a LlmRequest#

The original (pre-rewrite) request.

rewritten_request: &'a LlmRequest#

The rewritten request (may be identical to original in early phases).

prompt_ir: &'a PromptIR#

The Prompt IR decomposition of the request.

intent_bundle: &'a OptimizationIntentBundle#

The optimization intent bundle from the policy engine.

agent_identity: &'a AgentIdentity#

The agent identity for context.

struct PluginOutput#

Output produced by a plugin after translation.

Contains the translated request in the backend’s native API format and a TranslationReport describing what happened to each intent.

translated_request: LlmRequest#

The final request in the backend’s native API format.

translation_report: TranslationReport#

Report describing what happened to each intent.