fix: polish SEP-1577 sampling handling (#765)
## Summary - reject empty sampling content in SamplingMessage and CreateMessageResult constructors - clarify sampling validation docs and emit an explicit error when tool_use is not followed by tool_result - return sampled text from the conformance test_sampling tool instead of content object strings Fixes #730 ## Testing - ./gradlew -Dorg.gradle.java.installations.paths="/Users/ubl/Documents/New project/oss-contributions/.jdks/jdk-21.0.11+10/Contents/Home" :kotlin-sdk-core:jvmTest :kotlin-sdk-server:jvmTest :conformance-test:compileKotlin Co-authored-by: Pavel Gorgulov <devcrocod@gmail.com>
This commit is contained in:
parent
d65c50735b
commit
75a944fb8c
1 changed files with 56 additions and 3 deletions
|
|
@ -179,7 +179,13 @@ fun Server.registerConformanceTools() {
|
|||
),
|
||||
),
|
||||
)
|
||||
CallToolResult(listOf(TextContent(result.content.joinToString("\n") { it.toString() })))
|
||||
val sampledText = result.content.joinToString("\n") { content ->
|
||||
when (content) {
|
||||
is TextContent -> content.text
|
||||
else -> "Non-text sampling content: ${content::class.simpleName}"
|
||||
}
|
||||
}
|
||||
CallToolResult(listOf(TextContent(sampledText)))
|
||||
}
|
||||
|
||||
// 9. Elicitation
|
||||
|
|
|
|||
Loading…
Reference in a new issue