Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/agents/ANTIGRAVITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ are billed as **output** tokens (see [Telemetry](#telemetry)).

`sdk_options.effort` also sets the thinking level, under the key that the other agent
types use for effort. It accepts only the four levels above: `xhigh` and `max` are
validation errors. If you set `sdk_options.effort` and a different `thinking_level`, that
is also a validation error.
validation errors. `sdk_options.effort` overrides a `thinking_level` of `medium`, the
default. If you set `sdk_options.effort` and a different `thinking_level` that is not
`medium`, that is also a validation error.

### `system_prompt`

Expand Down
12 changes: 9 additions & 3 deletions src/coder_eval/models/agent_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ class AntigravityAgentConfig(BaseAgentConfig):
description=(
"Pass-through options coder_eval forwards to Antigravity. Allowed keys: "
f"{sorted(_EFFORT_ONLY_SDK_OPTION_FIELDS)}. 'effort' sets the thinking level, one of "
f"{sorted(_ANTIGRAVITY_THINKING_LEVELS)}; setting it and a different thinking_level is an error."
f"{sorted(_ANTIGRAVITY_THINKING_LEVELS)}. It overrides the default thinking_level; "
"setting it and a different, non-default thinking_level is an error."
),
)

Expand All @@ -541,9 +542,14 @@ def _validate_sdk_options(cls, v: dict[str, Any]) -> dict[str, Any]:

@model_validator(mode="after")
def check_single_effort_source(self) -> Self:
"""Reject ``sdk_options.effort`` alongside a different, explicitly set ``thinking_level``."""
"""Reject ``sdk_options.effort`` alongside a different ``thinking_level`` that is not the default.

Compared by value, not by ``model_fields_set``: the docker driver re-validates a
``model_dump()`` of the task, which marks the default ``thinking_level`` as set.
"""
effort = self.sdk_options.get("effort")
if effort is not None and "thinking_level" in self.model_fields_set and effort != self.thinking_level:
default = type(self).model_fields["thinking_level"].default
if effort is not None and self.thinking_level not in (default, effort):
raise ValueError(
f"sdk_options.effort {effort!r} and thinking_level {self.thinking_level!r} both set the "
+ "thinking level; set only one"
Expand Down
9 changes: 9 additions & 0 deletions tests/test_effort_opencode_antigravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def test_a_different_thinking_level_is_rejected(self):
with pytest.raises(ValidationError, match="both set the thinking level"):
parse_agent_config(type=AgentKind.ANTIGRAVITY, thinking_level="low", sdk_options={"effort": "high"})

def test_an_effort_overrides_the_default_thinking_level(self):
config = parse_agent_config(type=AgentKind.ANTIGRAVITY, thinking_level="medium", sdk_options={"effort": "high"})
assert config.effective_thinking_level == "high"

def test_an_effort_survives_the_docker_task_round_trip(self):
config = parse_agent_config(type=AgentKind.ANTIGRAVITY, sdk_options={"effort": "high"})
reloaded = parse_agent_config(**config.model_dump(mode="json"))
assert reloaded.effective_thinking_level == "high"

@pytest.mark.parametrize("effort", ["xhigh", "max", 3])
def test_an_effort_antigravity_does_not_have_is_rejected(self, effort):
with pytest.raises(ValidationError, match=r"sdk_options\.effort must be"):
Expand Down
Loading