-
Notifications
You must be signed in to change notification settings - Fork 285
Add custom feature creation documentation #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Add custom feature creation documentation #1295
Conversation
Qodana for JVM1254 new problems were found
@@ Code coverage @@
+ 72% total lines covered
18063 lines analyzed, 13017 lines covered
# Calculated according to the filters of your coverage tool☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
| Features provide a way to extend and enhance the functionality of AI agents at runtime. They are designed to be modular | ||
| and composable, allowing you to mix and match them according to your needs. | ||
|
|
||
| In addition to features that are available in Koog out of the box, you can also implement your own features by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to features-overview and update that page to clearly list the predefined features and mention and link to this new page about custom features from there as well
|
|
||
| Koog provides two interfaces that you can extend to implement custom features: | ||
|
|
||
| - `AIAgentGraphFeature`: Represents a feature specific to [agents that have defined workflows](complex-workflow-agents.md) (graph-based agents). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| To implement a custom feature, you need to create a feature structure according to the following steps: | ||
|
|
||
| 1. Create a feature class. | ||
| 2. Define a configuration class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention that it's an extension of the FeatureConfig class with a link to the API?
| - `interceptSubgraphExecutionCompleted`: After a subgraph completes. | ||
| - `interceptSubgraphExecutionFailed`: When a subgraph execution fails. | ||
|
|
||
| Note that interceptors are feature-scoped: only the feature that registers a handler receives those events (subject to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a note?) Also, I am lost at this point. You never mentioned handlers before this point. Event handlers are a predefined feature, so I am not sure if that's what you mean. The FeatureConfig subclass in your example doesn't have setEventFilter overridden. If this is an important note, I'd expand on this, provide some context and links.
|
|
||
| ### Disabling event filtering for a feature | ||
|
|
||
| Some features, such as debugger and OpenTelemetry, must observe the entire event stream. If your feature depends on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link?
| ### Disabling event filtering for a feature | ||
|
|
||
| Some features, such as debugger and OpenTelemetry, must observe the entire event stream. If your feature depends on the | ||
| full event stream, disable event filtering by overriding `setEventFilter` in your feature configuration to ignore custom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you mention setEventFilter again, but it is not at all evident what it's for and why you need to make it always return true (disable events filtering) if the feature "depends on the full event stream". Are some events filtered by default?
|
|
||
| ## Example: A basic logging feature | ||
|
|
||
| The following example shows how to implement a basic logging feature that logs agent lifecycle events. The example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "The example" at the end here?)
| ```kotlin | ||
| class LoggingFeature(private val logger: KLogger) { | ||
| class Config : FeatureConfig() { | ||
| var loggerName: String = "agent-logs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this loggerName if it's not used anywhere?
| override fun createInitialConfig(): Config = Config() | ||
|
|
||
| override fun install(config: Config, pipeline: AIAgentGraphPipeline) : LoggingFeature { | ||
| val logging = LoggingFeature(logger = logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this logger come from that you pass as the logger argument in the constructor?
| } | ||
| } | ||
| ``` | ||
| <!--- KNIT example-custom-features-04.kt --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to show how to install the feature, or is it straightforward? In the first example, you pass a string to the property when installing the feature.
Add documentation on how to implement custom features.
Type of the changes
Checklist
developas the base branchAdditional steps for pull requests adding a new feature