docs: add custom feature creation documentation#1295
docs: add custom feature creation documentation#1295marinkovicmarko merged 4 commits intodevelopfrom
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
|
| - `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.
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 | ||
| full event stream, disable event filtering by overriding `setEventFilter` in your feature configuration to ignore custom |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I don't think there are default filters, but you should be able to set your own ones when installing a feature in an agent. As some features, such as OpenTelemetry, may depend on receiving all events as they are, this is a way to prevent any filtering or processing that would interfere with the functioning of the feature. @sdubov can confirm whether my understanding here is correct.
I agree we can make this more explicit, though.
5ed6ed3 to
61dd236
Compare
azhebel
left a comment
There was a problem hiding this comment.
Looks good! Just a couple more minor comments.
| 1. Create a feature class. | ||
| 2. Define a configuration class. The configuration class is an extension of the [FeatureConfig](https://api.koog.ai/agents/agents-core/ai.koog.agents.core.feature.config/-feature-config/index.html) class. | ||
| 3. Create a companion object that implements `AIAgentGraphFeature`, `AIAgentFunctionalFeature`, or both. | ||
| 4. Give your feature a stable storage key so it can be retrieved in contexts. |
There was a problem hiding this comment.
It is not very obvious what "can be retrieved in contexts" refers to. It doesn't look like you mention it anywhere on this page. And if it's important enough to mention, maybe it needs its own separate chapter or page? As an altrnative, just an example, when would I need to use this key, for what?
sdubov
left a comment
There was a problem hiding this comment.
@marinkovicmarko , thank you a bunch for the amazing article! I really liked the easy and strict structure. I've left several comments that we can discuss if you find those topics useful.
| Koog provides two interfaces that you can extend to implement custom features: | ||
|
|
||
| - [AIAgentGraphFeature](https://api.koog.ai/agents/agents-core/ai.koog.agents.core.feature/-a-i-agent-graph-feature/index.html): Represents a feature specific to [agents that have defined workflows](complex-workflow-agents.md) (graph-based agents). | ||
| - [AIAgentFunctionalFeature](https://api.koog.ai/agents/agents-core/ai.koog.agents.core.feature/-a-i-agent-functional-feature/index.html): Represents a feature that can be used with [functional agents](functional-agents.md). |
There was a problem hiding this comment.
I'm afraid we have three now: two you mentioned + AIAgentPlannerFeature. But I do not see this in the doc (https://api.koog.ai). So, maybe update this when this planner is available in the docs as well. cc @antoniibelyshev.
There was a problem hiding this comment.
Not sure if a more recent version of API docs was deployed in the meantime, I see this: https://api.koog.ai/agents/agents-planner/ai.koog.agents.planner/-a-i-agent-planner-feature/index.html
|
|
||
| For a feature to receive a specific type of event, it needs to register the corresponding pipeline interceptor. | ||
|
|
||
| ### Filtering agent events |
There was a problem hiding this comment.
This is not actually a part of feature implementation, it is rather a part of agent configuration. Do we went to keep it in this MD file as well?
| ``` | ||
| <!--- KNIT example-custom-features-03.kt --> | ||
|
|
||
| #### Disabling event filtering for a feature |
There was a problem hiding this comment.
Oh, I see, the section about filtering is pre-requisite for describing this pattern.
820e092 to
c213fe5
Compare
Add documentation on how to implement custom features. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Tests improvement - [ ] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated
Add documentation on how to implement custom features. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Tests improvement - [ ] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated
Add documentation on how to implement custom features. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Tests improvement - [ ] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated
Add documentation on how to implement custom features. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Tests improvement - [ ] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated
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