|
1 | 1 | # Module agents:agents-features |
2 | 2 |
|
3 | | -Provides implementations of useful features of AI agents, such as Tracing, Debugger, EventHandler, Memory, OpenTelemetry, Snapshot, and more. |
| 3 | +A collection of plug-and-play features for Koog AI agents. These features hook into the agent execution pipeline to observe, enrich, and extend behavior. |
4 | 4 |
|
5 | | -### Overview |
| 5 | +## What is inside |
6 | 6 |
|
7 | | -Features integrate with the agent pipeline via interceptor hooks and consume standardized Feature Events emitted during agent execution. These events are defined in the agents-core module under `ai.koog.agents.core.feature.model.events`. After the 0afb32b refactor, event and interceptor names are unified across the system. |
| 7 | +Each feature lives in its own submodule, you only depend on what you need. Commonly used features include: |
| 8 | +- Tracing: End-to-end spans for agent runs and LLM, or Tool calls. Great for local dev and production observability; |
| 9 | +- Debugger: Step-through style inspection of the agent pipeline; |
| 10 | +- EventHandler: Subscribe to standardized agent events and react (log, metrics, custom side effects); |
| 11 | +- Memory: Pluggable memory interfaces for storing and retrieving agent context; |
| 12 | +- OpenTelemetry: OTel exporters and wiring for spans emitted by the agent pipeline; |
| 13 | +- Snapshot: Persist and restore agent snapshots for reproducibility and time-travel debugging. |
8 | 14 |
|
9 | | -### Standard Feature Events |
| 15 | +Check each feature’s own README/Module docs for details and advanced configuration. |
10 | 16 |
|
11 | | -The canonical description and definitions of Feature Events now live in the agents-core module. See: |
| 17 | +## How features integrate |
12 | 18 |
|
13 | | -- agents-core module docs: ../agents-core/Module.md (section "Standard Feature Events") |
14 | | -- Kotlin definitions: package `ai.koog.agents.core.feature.model.events` |
| 19 | +Features integrate via interceptor hooks and consume standardized events emitted during an agent execution. These events are defined in the agents-core module under: |
| 20 | +- ai.koog.agents.core.feature.model.events |
15 | 21 |
|
16 | | -Features in this module (Tracing, Debugger, EventHandler, etc.) consume these events to provide logging, tracing, monitoring, and remote inspection. |
| 22 | +Typical events include: |
| 23 | +- AgentStarting/Completed |
| 24 | +- LLMCallStarting/Completed |
| 25 | +- ToolCallStarting/Completed |
17 | 26 |
|
18 | | -### Using in your project |
| 27 | +Features can listen to these events, mutate context when appropriate, and publish additional events for downstream consumers. |
19 | 28 |
|
20 | | -Add the desired feature dependency, for example: |
| 29 | +## Installing features |
21 | 30 |
|
22 | | -```kotlin |
23 | | -dependencies { |
24 | | - implementation("ai.koog.agents:agents-features-trace:$version") |
25 | | - implementation("ai.koog.agents:agents-features-debugger:$version") |
26 | | -} |
27 | | -``` |
28 | | - |
29 | | -Install a feature in the agent builder: |
| 31 | +Install features when constructing your agent. Multiple features can be installed together; they remain decoupled and communicate via events. |
30 | 32 |
|
31 | 33 | ```kotlin |
32 | 34 | val agent = createAgent(/* ... */) { |
33 | | - install(Tracing) |
34 | | - install(Debugger) |
| 35 | + install(Tracing) { |
| 36 | + // Tracing configuration |
| 37 | + } |
| 38 | + install(OpenTelemetry) { |
| 39 | + // OTel configuration |
| 40 | + } |
35 | 41 | } |
36 | 42 | ``` |
37 | 43 |
|
38 | | -### Using in unit tests |
| 44 | +Consult each feature’s README for exact configuration options and defaults. |
39 | 45 |
|
40 | | -Most features can be installed in tests; they honor testing configuration and can be pointed to test writers/ports. |
| 46 | +## Using in unit tests |
41 | 47 |
|
42 | | -### Example of usage |
| 48 | +Features are test-friendly. They honor testing configurations and can be directed to in-memory writers/ports. |
| 49 | +- Install the same feature in tests to capture events deterministically. |
| 50 | +- Point outputs to test stubs to assert behavior (e.g., assert a specific sequence of Feature Events). |
| 51 | +- Prefer higher sampling in tests so important transitions are recorded. |
| 52 | + |
| 53 | +Example (pseudo): |
| 54 | +```kotlin |
| 55 | +@Test |
| 56 | +fun testAgentEmitsExpectedEvents() { |
| 57 | + val events = MutableListWriter<FeatureEvent>() |
| 58 | + createAgent { |
| 59 | + install(EventHandler) { |
| 60 | + writer = events |
| 61 | + } |
| 62 | + }.use { agent -> |
| 63 | + agent.run("Hello") |
| 64 | + assertTrue(events.any { it is LlmCallRequested }) |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
43 | 68 |
|
44 | | -See each feature's Module/README in its submodule for concrete examples (Tracing, Debugger, EventHandler, Memory, OpenTelemetry, Snapshot). |
| 69 | +## Where to learn more |
| 70 | +See each feature’s Module/README in its submodule for concrete examples and advanced setup: |
| 71 | +- Tracing |
| 72 | +- Debugger |
| 73 | +- EventHandler |
| 74 | +- Memory |
| 75 | +- OpenTelemetry |
| 76 | +- Snapshot |
0 commit comments