Skip to content

Commit 4a41910

Browse files
Add Step-03 example agent: add observability using tracing feature and LangFuse (#967)
<!-- Thank you for opening a pull request! Please add a brief description of the proposed change here. Also, please tick the appropriate points in the checklist below. --> ## Motivation and Context Third step of the code agent example. ## Breaking Changes <!-- Will users need to update their code or configurations? --> --- #### 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 - [x] 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 - [ ] Docs have been added / updated
1 parent 0054d4a commit 4a41910

File tree

12 files changed

+545
-0
lines changed

12 files changed

+545
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Module Code Agent (Step 3)
2+
3+
Code Agent example.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Code Agent - Step 03: Add Observability
2+
3+
> Code from the blog post: [TBA]()
4+
5+
This example extends our Code Agent from Step 2 with OpenTelemetry observability through LangFuse.
6+
7+
## Prerequisites
8+
9+
- Java 17+
10+
- OpenAI API key
11+
12+
## Setup
13+
14+
```bash
15+
export OPENAI_API_KEY="your-openai-key"
16+
export LANGFUSE_HOST="https://cloud.langfuse.com"
17+
export LANGFUSE_PUBLIC_KEY="your-public-key"
18+
export LANGFUSE_SECRET_KEY="your-secret-key"
19+
```
20+
21+
## Run
22+
23+
Navigate to this example:
24+
```
25+
cd examples/code-agent/step-03-add-observability
26+
```
27+
28+
Run the agent on any project:
29+
```
30+
./gradlew run --args="/absolute/path/to/project 'Task description'"
31+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.shadow)
4+
application
5+
}
6+
7+
application.mainClass.set("ai.koog.agents.examples.codeagent.step03.MainKt")
8+
9+
dependencies {
10+
implementation("ai.koog:koog-agents")
11+
implementation(libs.kotlinx.coroutines.core)
12+
implementation(libs.logback.classic)
13+
}
14+
15+
tasks.test {
16+
useJUnitPlatform()
17+
}
18+
19+
tasks.shadowJar {
20+
archiveBaseName.set("code-agent")
21+
mergeServiceFiles()
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Kotlin
2+
kotlin.code.style=official
3+
kotlin.daemon.jvmargs=-Xmx4096M
4+
5+
#Gradle
6+
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
7+
org.gradle.parallel=true
8+
org.gradle.caching=true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[versions]
2+
kotlin = "2.2.20"
3+
kotlinx-coroutines = "1.10.2"
4+
kotlinx-serialization = "1.8.1"
5+
logback = "1.5.13"
6+
shadow = "9.1.0"
7+
8+
[libraries]
9+
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
10+
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
11+
12+
[plugins]
13+
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
14+
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
15+
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

examples/code-agent/step-03-add-observability/gradlew

Lines changed: 251 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)