fix: ensure lite agents course-correct on validation errors
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Notify Downstream / notify-downstream (push) Has been cancelled

* fix: ensure lite agents course-correct on validation errors

* chore: update cassettes and test expectations

* fix: ensure multiple guardrails propogate
This commit is contained in:
Greyson LaLonde
2025-11-05 19:02:11 -05:00
committed by GitHub
parent 61ad1fb112
commit 7e6171d5bc
28 changed files with 8125 additions and 10295 deletions

View File

@@ -227,28 +227,22 @@ def test_get_conversion_instructions_gpt() -> None:
with patch.object(LLM, "supports_function_calling") as supports_function_calling:
supports_function_calling.return_value = True
instructions = get_conversion_instructions(SimpleModel, llm)
model_schema = PydanticSchemaParser(model=SimpleModel).get_schema()
expected_instructions = (
"Please convert the following text into valid JSON.\n\n"
"Output ONLY the valid JSON and nothing else.\n\n"
"Use this format exactly:\n```json\n"
f"{model_schema}\n```"
)
assert instructions == expected_instructions
# Now using OpenAPI schema format for all models
assert "Ensure your final answer strictly adheres to the following OpenAPI schema:" in instructions
assert '"type": "json_schema"' in instructions
assert '"name": "SimpleModel"' in instructions
assert "Do not include the OpenAPI schema in the final output" in instructions
def test_get_conversion_instructions_non_gpt() -> None:
llm = LLM(model="ollama/llama3.1", base_url="http://localhost:11434")
with patch.object(LLM, "supports_function_calling", return_value=False):
instructions = get_conversion_instructions(SimpleModel, llm)
# Check that the JSON schema is properly formatted
assert "Please convert the following text into valid JSON" in instructions
assert "Output ONLY the valid JSON and nothing else" in instructions
assert "Use this format exactly" in instructions
assert "```json" in instructions
assert '"type": "object"' in instructions
assert '"properties"' in instructions
assert "'type': 'json_schema'" not in instructions
# Now using OpenAPI schema format for all models
assert "Ensure your final answer strictly adheres to the following OpenAPI schema:" in instructions
assert '"type": "json_schema"' in instructions
assert '"name": "SimpleModel"' in instructions
assert "Do not include the OpenAPI schema in the final output" in instructions
# Tests for is_gpt