File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
embabel-agent-api/src/main/kotlin/com/embabel/agent/api Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ enum class TerminationScope(val value: String) {
3232}
3333
3434/* *
35- * Signal for graceful termination. When placed on the blackboard ,
35+ * Signal for graceful termination. When set on the agent process ,
3636 * the agent or action will terminate at the next natural checkpoint.
3737 *
3838 * For agent termination: checked before each tick() in AbstractAgentProcess.
Original file line number Diff line number Diff line change @@ -37,9 +37,10 @@ import com.embabel.agent.core.support.AbstractAgentProcess
3737 * @see com.embabel.agent.api.tool.TerminateAgentException for immediate termination
3838 */
3939fun ProcessContext.terminateAgent (reason : String ) {
40- (agentProcess as AbstractAgentProcess ).setTerminationRequest(
41- TerminationSignal (TerminationScope .AGENT , reason)
42- )
40+ check(agentProcess is AbstractAgentProcess ) {
41+ " Termination signals require AbstractAgentProcess (found: ${agentProcess::class .simpleName} )"
42+ }
43+ agentProcess.setTerminationRequest(TerminationSignal (TerminationScope .AGENT , reason))
4344}
4445
4546/* *
@@ -58,9 +59,10 @@ fun ProcessContext.terminateAgent(reason: String) {
5859 * @see com.embabel.agent.api.tool.TerminateActionException for immediate termination
5960 */
6061fun ProcessContext.terminateAction (reason : String ) {
61- (agentProcess as AbstractAgentProcess ).setTerminationRequest(
62- TerminationSignal (TerminationScope .ACTION , reason)
63- )
62+ check(agentProcess is AbstractAgentProcess ) {
63+ " Termination signals require AbstractAgentProcess (found: ${agentProcess::class .simpleName} )"
64+ }
65+ agentProcess.setTerminationRequest(TerminationSignal (TerminationScope .ACTION , reason))
6466}
6567
6668/* *
You can’t perform that action at this time.
0 commit comments