mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(framework): make AgentRuntime.submit blocking and remove runBlocking from AgentInteractionAdapter
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user