-
Notifications
You must be signed in to change notification settings - Fork 310
New example: basic code-agent #808
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fa6a5a3
KG-232: Add step-01-basic-agent example project setup
denis-domanskii e0b27da
KG-232: step-01-basic-agent example implemented + other examples move…
denis-domanskii 5056ec3
KG-232: Update `step-01-basic-agent` with event handling and logging …
denis-domanskii 886274d
KG-232: Update `main` to accept task as CLI argument with validation
denis-domanskii 0a975d3
Revert "KG-232: step-01-basic-agent example implemented + other examp…
denis-domanskii 4564fdb
KG-232: Include `step-01-basic-agent` in Gradle settings and build sc…
denis-domanskii c25f0e9
KG-232: Update `step-01-basic-agent` with `.gitignore` cleanup and ma…
denis-domanskii 9607b3e
Merge remote-tracking branch 'origin/develop' into codeagent/step-01-…
denis-domanskii f132c89
KG-232: Simplify dependencies and update module files for `step-01-ba…
denis-domanskii c2baf17
KG-232: Update `step-01-basic-agent` prompt and integrate Shadow plug…
denis-domanskii a223ce4
KG-232: Update `main` to require project path and task as CLI arguments
denis-domanskii 76ae4fb
KG-232: Update `main` to require project path and task as CLI arguments
denis-domanskii ce5e218
KG-232: Migrate from the deprecated shadowJar version to the relevant…
denis-domanskii 306c36d
:alembic: GPT5
BLannoo 3c10830
:alembic: remove temperature for GPT5
BLannoo 265d8a5
Merge remote-tracking branch 'origin/develop' into codeagent/step-01-…
denis-domanskii 961de52
KG-232: Add Gradle wrapper and configuration for `step-01-basic-agent…
denis-domanskii ea51f79
KG-232: Remove example projects from Gradle settings to streamline co…
denis-domanskii 7067161
KG-232: Remove `:examples` module from `koog-agents` dependencies to …
denis-domanskii d7557a2
KG-232: Add custom tracing attributes in `step-01-basic-agent`
denis-domanskii 91ba5aa
KG-427: Add support for trace-level attributes in Langfuse integration
denis-domanskii a71ece8
Clarify span type in Langfuse OpenTelemetry documentation
denis-domanskii 9b02940
Merge branch 'domanskii/KG-427-Support-LangFuse-trace-level-attribute…
denis-domanskii 62a291c
Merge remote-tracking branch 'origin/develop' into codeagent/step-01-…
denis-domanskii a8d0262
Merge remote-tracking branch 'origin/develop' into codeagent/step-01-…
denis-domanskii b6d908f
Refactor event handling in `step-01-basic-agent`: replace `onToolCall…
denis-domanskii 7a2c5a0
Simplify logging in `step-01-basic-agent` by removing tool arguments …
denis-domanskii 156b8f6
Merge remote-tracking branch 'origin/develop' into codeagent/step-01-…
denis-domanskii 0c8e257
Remove unused OpenTelemetry imports and rename `onToolExecutionStarti…
denis-domanskii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Module Code Agent (Step 1) | ||
|
|
||
| Code Agent example. |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| plugins { | ||
| id("ai.kotlin.jvm") | ||
| alias(libs.plugins.shadow) | ||
| application | ||
| } | ||
|
|
||
| application.mainClass.set("ai.koog.agents.examples.codeagent.step01.MainKt") | ||
|
|
||
| dependencies { | ||
| implementation(project(":agents:agents-core")) | ||
| implementation(project(":agents:agents-ext")) | ||
| implementation(project(":prompt:prompt-executor:prompt-executor-llms-all")) | ||
|
|
||
| implementation(libs.kotlinx.coroutines.core) | ||
|
|
||
| implementation(libs.logback.classic) | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| tasks.shadowJar { | ||
| archiveBaseName.set("code-agent") | ||
| mergeServiceFiles() | ||
| } |
51 changes: 51 additions & 0 deletions
51
examples/code-agent/step-01-basic-agent/src/main/kotlin/Main.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package ai.koog.agents.examples.codeagent.step01 | ||
|
|
||
| import ai.koog.agents.core.agent.AIAgent | ||
| import ai.koog.agents.core.agent.singleRunStrategy | ||
| import ai.koog.agents.core.tools.ToolRegistry | ||
| import ai.koog.agents.ext.tool.file.EditFileTool | ||
| import ai.koog.agents.ext.tool.file.ListDirectoryTool | ||
| import ai.koog.agents.ext.tool.file.ReadFileTool | ||
| import ai.koog.agents.ext.tool.file.WriteFileTool | ||
| import ai.koog.agents.features.eventHandler.feature.handleEvents | ||
| import ai.koog.prompt.executor.clients.openai.OpenAIModels | ||
| import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor | ||
| import ai.koog.rag.base.files.JVMFileSystemProvider | ||
| import kotlinx.coroutines.runBlocking | ||
|
|
||
| val agent = AIAgent( | ||
| promptExecutor = simpleOpenAIExecutor(System.getenv("OPENAI_API_KEY")), | ||
| strategy = singleRunStrategy(), | ||
| systemPrompt = """ | ||
| You are a highly skilled programmer tasked with updating the provided codebase according to the given task. | ||
| Your goal is to deliver production-ready code changes that integrate seamlessly with the existing codebase and solve given task. | ||
| """.trimIndent(), | ||
| llmModel = OpenAIModels.Chat.GPT4_1, | ||
| temperature = 0.0, | ||
| toolRegistry = ToolRegistry { | ||
| tool(ListDirectoryTool(JVMFileSystemProvider.ReadOnly)) | ||
| tool(ReadFileTool(JVMFileSystemProvider.ReadOnly)) | ||
| tool(WriteFileTool(JVMFileSystemProvider.ReadWrite)) | ||
| tool(EditFileTool(JVMFileSystemProvider.ReadWrite)) | ||
| }, | ||
| maxIterations = 100 | ||
| ) { | ||
| handleEvents { | ||
| onToolCall { ctx -> | ||
| println("Tool called: ${ctx.tool.name}, args=${ctx.toolArgs}") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun main(args: Array<String>) = runBlocking { | ||
| if (args.size < 2) { | ||
| println("Error: Please provide the project absolute path and a task as arguments") | ||
| println("Usage: <absolute_path> <task>") | ||
| return@runBlocking | ||
| } | ||
|
|
||
| val (path, task) = args | ||
| val input = "Project path: $path\n\n$task" | ||
| val result = agent.run(input) | ||
| println(result) | ||
| } |
11 changes: 11 additions & 0 deletions
11
examples/code-agent/step-01-basic-agent/src/main/resources/logback.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <configuration> | ||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder> | ||
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <root level="ERROR"> | ||
| <appender-ref ref="STDOUT" /> | ||
| </root> | ||
| </configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.