refactor(framework): make AgentRuntime.submit blocking and remove runBlocking from AgentInteractionAdapter

This commit is contained in:
2026-03-03 21:23:52 +08:00
parent b02f29b1b1
commit f8d90fbcee
2 changed files with 3 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
package work.slhaf.partner.api.agent.runtime.interaction
import kotlinx.coroutines.runBlocking
import work.slhaf.partner.api.agent.runtime.interaction.data.AgentInputData
import work.slhaf.partner.api.agent.runtime.interaction.data.AgentOutputData
import work.slhaf.partner.api.agent.runtime.interaction.flow.RunningFlowContext
@@ -16,9 +15,7 @@ abstract class AgentInteractionAdapter<
fun submit(inputData: I): O {
val ctx = parseInputData(inputData)
val result = runBlocking {
runtime.submit(ctx)
}
val result = runtime.submit(ctx)
return parseOutputData(result)
}

View File

@@ -32,11 +32,11 @@ object AgentRuntime {
runningModules = buildRunningModules()
}
suspend fun <C : RunningFlowContext> submit(context: C): C {
fun <C : RunningFlowContext> submit(context: C): C = runBlocking {
val deferred = CompletableDeferred<RunningFlowContext>()
channel.send(TurnRequest(context, deferred))
@Suppress("UNCHECKED_CAST")
return deferred.await() as C
(return@runBlocking deferred.await() as C)
}
private suspend fun executeTurn(