fix: hide deriver config guidance from validation
This commit is contained in:
parent
08269b0f52
commit
fde9389040
|
|
@ -91,7 +91,10 @@ def _validate_custom_instructions_budget(
|
|||
if not custom_instructions.strip():
|
||||
return custom_instructions
|
||||
|
||||
max_tokens = settings.DERIVER.effective_max_custom_instructions_tokens
|
||||
max_tokens = settings.DERIVER.MAX_CUSTOM_INSTRUCTIONS_TOKENS
|
||||
if max_tokens is None:
|
||||
raise ValueError("custom_instructions are not enabled for this deployment")
|
||||
|
||||
if estimate_tokens(custom_instructions) > max_tokens:
|
||||
raise ValueError(
|
||||
f"custom_instructions exceeds DERIVER.MAX_CUSTOM_INSTRUCTIONS_TOKENS ({max_tokens} tokens)"
|
||||
|
|
|
|||
|
|
@ -208,6 +208,25 @@ class TestResolvedConfigurationMigration:
|
|||
|
||||
|
||||
class TestReasoningCustomInstructionsValidation:
|
||||
def test_nonblank_custom_instructions_require_enabled_deployment_cap(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(
|
||||
settings.DERIVER, "MAX_CUSTOM_INSTRUCTIONS_TOKENS", None, raising=False
|
||||
)
|
||||
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
ReasoningConfiguration(custom_instructions="Prefer concrete facts.")
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any(
|
||||
error["loc"] == ("custom_instructions",)
|
||||
and "custom_instructions are not enabled for this deployment"
|
||||
in error["msg"]
|
||||
for error in errors
|
||||
)
|
||||
assert "[deriver].MAX_CUSTOM_INSTRUCTIONS_TOKENS" not in str(exc_info.value)
|
||||
|
||||
def test_reasoning_configuration_rejects_oversized_custom_instructions(
|
||||
self, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue