From af403c831367953510119e2201e3b99765cb14a0 Mon Sep 17 00:00:00 2001 From: kosumi Date: Tue, 23 Sep 2025 09:49:16 -0400 Subject: [PATCH 1/2] Add response format validation --- aiopslab/orchestrator/parser.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/aiopslab/orchestrator/parser.py b/aiopslab/orchestrator/parser.py index 0e81a39a..14af65d5 100644 --- a/aiopslab/orchestrator/parser.py +++ b/aiopslab/orchestrator/parser.py @@ -13,6 +13,24 @@ class ResponseParser: def __init__(self): pass + def validate(self, response: str): + actions = re.findall(r"```\s*\n(.*?)\n```", response, re.DOTALL) + if len(actions) != 1: + raise ResponseParsingError(""" +Format validation failure. Only have one pair of three ticks in your block and check the ticks. +Correct example 1: +I should run: +``` +ls +``` + +Correct example 2: +Check k8s info +``` +kubectl get services --all-namespaces +``` + """) + def parse(self, response: str) -> dict: """Parses the response string to extract the API name and arguments. @@ -22,6 +40,7 @@ def parse(self, response: str) -> dict: Returns: dict: The parsed API name and arguments. """ + self.validate(response) code_block = self.extract_codeblock(response) context = self.extract_context(response) api_name = self.parse_api_name(code_block) From cec1499551168ac8fb1bf39b8ac1d036d2183758 Mon Sep 17 00:00:00 2001 From: kosumi Date: Wed, 1 Oct 2025 15:48:58 -0400 Subject: [PATCH 2/2] Fix the prompt --- aiopslab/orchestrator/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiopslab/orchestrator/parser.py b/aiopslab/orchestrator/parser.py index 14af65d5..b93b41ef 100644 --- a/aiopslab/orchestrator/parser.py +++ b/aiopslab/orchestrator/parser.py @@ -21,13 +21,13 @@ def validate(self, response: str): Correct example 1: I should run: ``` -ls +exec_shell("ls") ``` Correct example 2: Check k8s info ``` -kubectl get services --all-namespaces +exec_shell("kubectl get services --all-namespaces") ``` """)