From c807d8a6b381532ffb05cf57fde7fa01ac1a40cf Mon Sep 17 00:00:00 2001 From: Daniel Eder Date: Mon, 29 Sep 2025 06:47:41 +0200 Subject: [PATCH] feat: added a chance for the LLM to stop execution --- intelligent_agent.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/intelligent_agent.py b/intelligent_agent.py index 3904dc1..f7e7d03 100644 --- a/intelligent_agent.py +++ b/intelligent_agent.py @@ -148,6 +148,11 @@ class IntelligentAgent(Agent): print(f"[Agent] Sent command: {value}") self.history.append({"role": "assistant", "content": f"COMMAND {value}"}) self._trim_history() + elif action_type == "end": + print(f"[Agent] Execution ended by LLM.") + self.history.append({"role": "assistant", "content": f"END"}) + self._trim_history() + stop_event.set() else: print(f"[Agent] Unknown action type '{action_type}'", file=sys.stderr) return @@ -175,7 +180,7 @@ class IntelligentAgent(Agent): "role": "system", "content": ( "Respond with JSON only. Schema: {\n" - " \"type\": \"tool\" or \"command\",\n" + " \"type\": \"tool\" or \"command\" or \"end\",\n" " \"value\": string,\n" " \"notes\": optional string\n}""" ),