Skip to content

Commit bd9b242

Browse files
authored
fix(gatekeeper): pass a looser schema to the model (#462)
In evals, Claude Opus and Claude Sonnet were performing *much* worse when run directly from Anthropic than when run from Vertex AI (and worse than other flagship models) Switching the schema passed to response_format so that the reason is optional first greatly improves the Claude models on the Anthropic pplatforms (Opus from 76.7% => 93.2%) and doesn't have much noticeable effect on other models. Theory here is: - The response_format isn't ending up in the prompt for Vertex AI, though it may constrain decoding. - When the response_format does end up in the prompt, being required to provide a reason "intimidates" the model, and responding OK seems easier.
1 parent 18509ca commit bd9b242

3 files changed

Lines changed: 3 additions & 11 deletions

File tree

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from linux_mcp_server.gatekeeper.check_run_script import check_run_script
22
from linux_mcp_server.gatekeeper.check_run_script import GatekeeperResult
3-
from linux_mcp_server.gatekeeper.check_run_script import GatekeeperResultStrict
43
from linux_mcp_server.gatekeeper.check_run_script import GatekeeperStatus
54

65

7-
__all__ = ["check_run_script", "GatekeeperStatus", "GatekeeperResult", "GatekeeperResultStrict"]
6+
__all__ = ["check_run_script", "GatekeeperStatus", "GatekeeperResult"]

src/linux_mcp_server/gatekeeper/check_run_script.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ def get_model() -> str:
105105
what is wrong with the script. Be specific to allow the language model to correct
106106
the problem.
107107
108-
If status is OK, the detail should be an empty string.
109-
110108
If the script seems buggy but does not fall into any of the categories above, return
111109
a status of `OK`.
112110
@@ -186,10 +184,6 @@ def parse_from_description(cls, description: str) -> "GatekeeperResult":
186184
return cls(status=status, detail=detail)
187185

188186

189-
class GatekeeperResultStrict(GatekeeperResult):
190-
detail: str # type:ignore
191-
192-
193187
def check_run_script(description: str, script_type: str, script: str, *, readonly: bool) -> GatekeeperResult:
194188
# Check that the script does what is described
195189
if "start_of_script" in script.lower() or "end_of_script" in script.lower():
@@ -215,7 +209,7 @@ def check_run_script(description: str, script_type: str, script: str, *, readonl
215209

216210
params = get_supported_openai_params(model=get_model())
217211
if params is not None and "response_format" in params:
218-
response_format = GatekeeperResultStrict
212+
response_format = GatekeeperResult
219213
else:
220214
response_format = None
221215

tests/gatekeeper/test_check_run_script.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pydantic import ValidationError
1010

1111
from linux_mcp_server.gatekeeper import GatekeeperResult
12-
from linux_mcp_server.gatekeeper import GatekeeperResultStrict
1312
from linux_mcp_server.gatekeeper import GatekeeperStatus
1413
from linux_mcp_server.gatekeeper.check_run_script import check_run_script
1514
from linux_mcp_server.gatekeeper.check_run_script import get_model
@@ -125,7 +124,7 @@ def test_response_format_handling(self, mock_litellm, supported_params, expect_r
125124

126125
call_kwargs = mock_completion.call_args.kwargs
127126
if expect_response_format:
128-
assert call_kwargs["response_format"] is GatekeeperResultStrict
127+
assert call_kwargs["response_format"] is GatekeeperResult
129128
else:
130129
assert call_kwargs["response_format"] is None
131130

0 commit comments

Comments
 (0)