Skip to content

Commit 360eb12

Browse files
Add Step-02 example agent: add a shell execution tool (#966)
<!-- 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 Second 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 --------- Co-authored-by: Bruno Lannoo <BLannoo@users.noreply.github.com>
1 parent f3e0aa1 commit 360eb12

12 files changed

Lines changed: 539 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Module Code Agent (Step 2)
2+
3+
Code Agent example.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Code Agent - Step 01: Minimal Agent
2+
3+
> Code from the blog post: [Building AI Agents in Kotlin – Part 2: A Deeper Dive Into Tools]()
4+
5+
A minimal code agent with three tools that can navigate codebases and make targeted changes.
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+
```
17+
18+
## Run
19+
20+
Navigate to this example:
21+
```
22+
cd examples/code-agent/step-01-minimal-agent
23+
```
24+
25+
Run the agent on any project:
26+
```
27+
./gradlew run --args="/absolute/path/to/project 'Task description'"
28+
```
29+
30+
Example:
31+
```
32+
./gradlew run --args="/Users/yourname/my-project 'Add error handling'"
33+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.step02.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+
}
23+
24+
tasks.named<JavaExec>("run") {
25+
standardInput = System.`in`
26+
}
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-02-add-execution-tool/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)