Skip to content

Commit 80aedf6

Browse files
authored
Fix RegexSearchTool (#1273)
Fix after #1226
1 parent 2aef6c3 commit 80aedf6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

agents/agents-ext/src/commonMain/kotlin/ai/koog/agents/ext/tool/search/RegexSearchTool.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import kotlinx.coroutines.flow.mapNotNull
2020
import kotlinx.coroutines.flow.take
2121
import kotlinx.coroutines.flow.toList
2222
import kotlinx.io.IOException
23-
import kotlinx.serialization.KSerializer
2423
import kotlinx.serialization.SerialName
2524
import kotlinx.serialization.Serializable
2625

@@ -31,14 +30,16 @@ import kotlinx.serialization.Serializable
3130
*/
3231
public class RegexSearchTool<Path>(
3332
private val fs: FileSystemProvider.ReadOnly<Path>,
34-
) : Tool<RegexSearchTool.Args, RegexSearchTool.Result>() {
35-
36-
override val name: String = "__search_contents_by_regex__"
37-
override val description: String = text {
33+
) : Tool<RegexSearchTool.Args, RegexSearchTool.Result>(
34+
argsSerializer = Args.serializer(),
35+
resultSerializer = Result.serializer(),
36+
name = "__search_contents_by_regex__",
37+
description = text {
3838
+"Executes a regular expression search on folder or file contents within the specified path."
3939
+"The tool returns structured results with file paths, line numbers, positions, and excerpts where the text was found."
4040
+"The tool will solely return search results and does not modify any files."
4141
}
42+
) {
4243

4344
/**
4445
* Parameters for a regex content search.
@@ -73,9 +74,6 @@ public class RegexSearchTool<Path>(
7374
@Serializable
7475
public data class Result(val entries: List<FileSystemEntry.File>, val original: String)
7576

76-
override val argsSerializer: KSerializer<Args> = Args.serializer()
77-
override val resultSerializer: KSerializer<Result> = Result.serializer()
78-
7977
override suspend fun execute(args: Args): Result {
8078
val path = fs.fromAbsolutePathString(args.path)
8179
val matches = search(path, args.regex, args.limit, args.skip, args.caseSensitive).toList()

0 commit comments

Comments
 (0)