Class ProcessProviderAdapter
- All Implemented Interfaces:
ProcessProvider
- Direct Known Subclasses:
CodeMieProvider
ProcessProvider implementation.
This adapter forwards all ProcessProvider calls to an underlying provider
instance configured via setProvider(ProcessProvider).
Intended use cases include decorating providers (for example, adding
cross-cutting concerns like logging, metrics, retries, or request shaping)
while preserving the ProcessProvider contract.
Thread-safety: Instances are not thread-safe unless the delegated provider is thread-safe and access is externally synchronized.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPrompts(FunctionTools functionTool) Scans the providedFunctionToolsinstance for methods annotated withPromptand registers each prompt for use during a run.voidaddResources(FunctionTools tools) Scans the providedFunctionToolsinstance for methods annotated withResource, and registers each resource for use during a run.voidaddTools(FunctionTools tools, String[] enabledTools) Registers the tools exposed by the givenFunctionToolsimplementation, optionally restricting registration to a filtered subset of tools.voidclear()Clears any stored files and session/provider state.Returns the names of tools currently registered with the provider.voidinit(String model, Configurator conf) Initializes the provider with application configuration.voidinstructions(String instructions) Sets system/session instructions for the current conversation.perform()Executes the provider to produce a response based on the accumulated prompts, instructions, files, and registered capabilities.voidAdds a user prompt to the current session.voidsetErrorHandling(boolean errorHandling) Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions.voidsetProjectDir(File projectDir) Sets the working directory for the provider, which may be supplied to tool, prompt, and resource handlers.voidsetProvider(ProcessProvider provider) Sets the delegate provider.
-
Field Details
-
provider
Delegate provider.Subclasses typically set this value during construction or initialization using
setProvider(ProcessProvider).
-
-
Constructor Details
-
ProcessProviderAdapter
public ProcessProviderAdapter()Creates an adapter without a delegate.Call
setProvider(ProcessProvider)before invoking any other methods.
-
-
Method Details
-
setProvider
Sets the delegate provider.- Parameters:
provider- the provider to delegate to- Throws:
IllegalArgumentException- ifproviderisnull
-
init
Initializes the provider with application configuration.- Specified by:
initin interfaceProcessProvider- Parameters:
model- the model identifier or name to useconf- configuration source used to initialize the provider
-
prompt
Adds a user prompt to the current session.Prompts are accumulated until
ProcessProvider.perform()orProcessProvider.clear()is called. The exact message format sent to the provider is implementation specific.- Specified by:
promptin interfaceProcessProvider- Parameters:
text- the prompt text
-
clear
public void clear()Clears any stored files and session/provider state.This resets the conversation and any accumulated context.
- Specified by:
clearin interfaceProcessProvider
-
instructions
Sets system/session instructions for the current conversation.Calling this method replaces any previously configured instructions. A
nullvalue may be used to clear them when supported by the implementation.- Specified by:
instructionsin interfaceProcessProvider- Parameters:
instructions- instruction text
-
perform
Executes the provider to produce a response based on the accumulated prompts, instructions, files, and registered capabilities.Whether the accumulated session is retained after execution is provider specific. Call
ProcessProvider.clear()when a new independent conversation is required.- Specified by:
performin interfaceProcessProvider- Returns:
- the provider response as a string
-
setProjectDir
Sets the working directory for the provider, which may be supplied to tool, prompt, and resource handlers.- Specified by:
setProjectDirin interfaceProcessProvider- Parameters:
projectDir- the project directory, ornullto clear the current directory
-
addTools
Registers the tools exposed by the givenFunctionToolsimplementation, optionally restricting registration to a filtered subset of tools.Implementations are expected to discover tool definitions on the provided
toolsinstance (typically via annotated methods) and make them available for use, applying the enablement filter described below.- Specified by:
addToolsin interfaceProcessProvider- Parameters:
tools- theFunctionToolsimplementation containing the tool definitions to register; must not benull.enabledTools- an optional array of regular expression patterns controlling which tools are registered.Each tool is identified internally by a fully qualified name built in the format
<ClassName>:<toolName>, where:<ClassName>is the fully qualified class name of thetoolsimplementation, and<toolName>is the tool's declared name (or the method name if no explicit name is provided).
enabledToolsisnull, all available tools are registered without filtering.
-
addPrompts
Scans the providedFunctionToolsinstance for methods annotated withPromptand registers each prompt for use during a run.The prompt name, description, role, and parameters are obtained from the annotation and the method signature.
- Specified by:
addPromptsin interfaceProcessProvider- Parameters:
functionTool- theFunctionToolsinstance whose methods will be scanned forPromptannotations
-
addResources
Scans the providedFunctionToolsinstance for methods annotated withResource, and registers each resource for use during a run.This method inspects the given class instance to register resource utilities that can be dynamically called by the AI model during generation processes.
- Specified by:
addResourcesin interfaceProcessProvider- Parameters:
tools- theFunctionToolsinstance whose methods will be scanned for resource annotations
-
setErrorHandling
public void setErrorHandling(boolean errorHandling) Configures whether tool invocation errors should be returned to the model for conversational recovery or propagated as exceptions. This setting does not suppress provider or configuration errors unrelated to tool invocation.- Specified by:
setErrorHandlingin interfaceProcessProvider- Parameters:
errorHandling-trueto return tool errors as response text;falseto propagate them immediately
-
getToolNames
Description copied from interface:ProcessProviderReturns the names of tools currently registered with the provider.The returned names may be used for diagnostics, filtering, request construction, or tool-invocation processing. The ordering and mutability of the returned list are provider-specific.
- Specified by:
getToolNamesin interfaceProcessProvider- Returns:
- the names of registered tools, or an empty list when no tools are registered
-