Interface ContextProvider
- All Known Implementing Classes:
AbstractBrowser, AbstractProjectContextProvider, AbstractProjectContextProvider, AnahataToolkit, AsiContainer, Audio, BasicContextProvider, BatchCodeRefiner, BatchCodeRefiner, Benchmarks, Chrome, CodeModel, CodeModel, CodeRefiner, CodeRefiner, CoreContextProvider, Editor, Editor, Firefox, Hints, Hints, History, Host, IDE, IDE, IntellijJava, Java, Maven, Maven, NbJava, NbTerminal, OpenToolWindowsContextProvider, OpenTopComponentsContextProvider, OutputTabsContextProvider, ProjectAlertsContextProvider, ProjectAlertsContextProvider, ProjectContextProvider, ProjectContextProvider, ProjectFilesContextProvider, Projects, Projects, ProjectStructureContextProvider, ProjectStructureContextProvider, Radio, Refactor, Refactor, Resource, ResourceManager, Resources, RunConfigurations, Screens, Session, Shell, Speech, SwingJava, Terminals, TerminalTab, ToolManager, Vcs, YouTube
public interface ContextProvider
Defines the contract for providers that inject just-in-time context into an
AI request. Context providers can contribute system instructions or augment
the user's prompt through a hierarchical tree structure.
- Author:
- anahata-ai
-
Method Summary
Modifier and TypeMethodDescriptiongetAgi()Gets the parent AGI session this context provider is registered under.default List<ContextProvider> Gets the list of immediate child context providers.default ContextPositionGets the designated position of this provider's content in the AI prompt.Gets a detailed description of what this context provider does.default List<ContextProvider> getFlattenedHierarchy(boolean providingOnly) Gets a flattened list of this provider and all its descendants in the hierarchy.default StringGets the fully qualified ID of this provider, reflecting its position in the hierarchy.default StringGenerates a machine-readable header string for this context provider, used to identify the source of injected context in the final prompt.default StringGets an optional icon identifier for this provider.getId()Gets the unique identifier for this context provider.default intCalculates the token count for the system instructions provided by this instance using the active model.getName()Gets the human-readable name of this context provider.default ContextProviderGets the parent context provider in the hierarchy, if any.default intCalculates the token count for the RAG content provided by this instance using the active model.Gets a list of system instruction strings provided by this context provider.default booleanChecks if this provider is effectively providing context, meaning it is enabled AND all its ancestors in the hierarchy are also enabled.booleanChecks if this context provider is currently active and providing context.default voidpopulateMessage(RagMessage ragMessage) Populates the givenRagMessagewith dynamic, just-in-time context parts.default voidsetParentProvider(ContextProvider parent) Sets the parent context provider for this instance.default voidsetProviding(boolean enabled) Sets whether this context provider is enabled.
-
Method Details
-
getId
-
getName
String getName()Gets the human-readable name of this context provider.- Returns:
- The provider's name.
-
getDescription
String getDescription()Gets a detailed description of what this context provider does.- Returns:
- The provider's description.
-
isProviding
boolean isProviding()Checks if this context provider is currently active and providing context.- Returns:
trueif providing,falseotherwise.
-
isEffectivelyProviding
default boolean isEffectivelyProviding()Checks if this provider is effectively providing context, meaning it is enabled AND all its ancestors in the hierarchy are also enabled.- Returns:
trueif effectively providing,falseotherwise.
-
setProviding
default void setProviding(boolean enabled) Sets whether this context provider is enabled.- Parameters:
enabled-trueto enable,falseto disable.
-
getParentProvider
Gets the parent context provider in the hierarchy, if any.- Returns:
- The parent provider, or null if this is a root provider.
-
setParentProvider
Sets the parent context provider for this instance.- Parameters:
parent- The parent provider.
-
getChildrenProviders
Gets the list of immediate child context providers.- Returns:
- The list of children, or an empty list if none.
-
getFullyQualifiedId
Gets the fully qualified ID of this provider, reflecting its position in the hierarchy. The format is typically 'parent.child.id'.- Returns:
- The dot-separated fully qualified ID.
-
getFlattenedHierarchy
Gets a flattened list of this provider and all its descendants in the hierarchy.If
providingOnlyis true, the search stops at any provider that is not providing, effectively excluding its entire subtree from the result.- Parameters:
providingOnly- if true, only providers whereisProviding()is true are included.- Returns:
- A flat list of the provider hierarchy.
-
getContextPosition
Gets the designated position of this provider's content in the AI prompt.- Returns:
- The context position. Defaults to
ContextPosition.PROMPT_AUGMENTATION.
-
getSystemInstructions
Gets a list of system instruction strings provided by this context provider. These are typically prepended to the conversation as high-level guidance.- Returns:
- A list of system instruction strings.
- Throws:
Exception- if an error occurs during instruction generation.
-
populateMessage
Populates the givenRagMessagewith dynamic, just-in-time context parts. These parts are appended to the end of the user's prompt (RAG).- Parameters:
ragMessage- The message to be augmented with context.- Throws:
Exception- if an error occurs during context generation.
-
getHeader
Generates a machine-readable header string for this context provider, used to identify the source of injected context in the final prompt.- Returns:
- A formatted header string.
-
getIconId
Gets an optional icon identifier for this provider. This ID can be used by the UI to look up a specialized icon.- Returns:
- The provider's icon ID, or null if none.
-
getAgi
Agi getAgi()Gets the parent AGI session this context provider is registered under.- Returns:
- The active parent AGI session, or null if it cannot be resolved.
-
getInstructionsTokenCount
default int getInstructionsTokenCount()Calculates the token count for the system instructions provided by this instance using the active model.- Returns:
- The estimated token count.
-
getRagTokenCount
default int getRagTokenCount()Calculates the token count for the RAG content provided by this instance using the active model.- Returns:
- The estimated token count.
-

