Repository navigation
fix(agent): an empty settings quality no longer pins image calls - #1137
Conversation
The WebUI model picker saves `quality: ""` when a reader picks an image model without choosing a quality, and effective_quality() treated any explicitly-present quality key as authoritative, so the empty string outranked the tool call's own request and the `if quality:` sites then dropped it from the outbound request: a call asking for high quality went out with no quality at all. An empty Settings value is the section's "no quality named" (the schema's own default), so it now falls through to the request, and a quality named in Settings still wins over the call's. Co-authored-by: GLM (GLM-5.3-Flash) <noreply@z.ai>
gloryfromca
left a comment
There was a problem hiding this comment.
No blockers; this can merge as far as I am concerned.
Reviewed github/main...HEAD and the surrounding image-generation path. I covered the repository rules, the diff, the sole effective_quality caller, the Web UI writer that persists quality: "", the schema contract, live-config/provider routing, relevant history, backward compatibility, and test strength. The change correctly treats the schema's empty sentinel as unset while preserving named Settings overrides and model-family filtering; the regression tests cover both direct resolution and the outbound request.
Verification:
uv run pytest tests/test_media_gen_tool.py -x- 165 passeduv run ruff check raven/agent/tools/media_gen.py tests/test_media_gen_tool.py- passeduv run ruff format --check raven/agent/tools/media_gen.py tests/test_media_gen_tool.py- passedgit diff --check github/main...HEAD- passed
The first test attempt could not collect because the fresh environment lacked the workspace everos-memory package; after uv sync --all-packages, the complete target file passed.
|
Windows compatibility review — PR #1137 @ Scope: full base Result: no Windows-specific issue. The change is a boolean/string condition on a config field; no path, filesystem, subprocess, signal, encoding, or platform primitive. Verification (native Windows 11, CPython 3.12.13, isolated worktree Limitations: no live image-generation call; the behaviour is covered by the unit suite. |
|
The fix is ready and verified locally: all relevant media-gen agent tests pass in the PR worktree (462 passed across the nine test files that exercise it, including the two new ones). The branch's workflow runs (CI, Docs, Commit lint, Claude Mention) are currently in action_required — once a maintainer approves them, CI will run and this PR can move forward. Thanks! |
LivXue
left a comment
There was a problem hiding this comment.
Review — PR #1137 @ 613ab99a
Scope: base 06509f8e → head, raven/agent/tools/media_gen.py and tests/test_media_gen_tool.py only. I read the sole effective_quality caller (_generate_one), the ppt-engine cache-key caller, resolve_media_selection / live_media_tool_config (the live and constructor paths both preserve model_fields_set), the WebUI mediaSelection() writer that saves quality: "", the schema contract, and the console enum. The condition is correct: an explicitly-present empty quality is the section's "not named" value, so it now falls through to the call's quality, while a named Settings quality still wins and the configured model keeps its documented precedence. The final "gpt-image" in model_id gate means only gpt-image models ever carry a non-None quality, and those always take the Images API, so the response's quality field still describes what was actually sent.
No blocking code issue. The findings below are scope/wording, not defects.
-
The PR body says
Fixes #1106, but #1106 also asks that (a) requested-versus-effective model/quality and their selection source be visible in the trace, and (b) a provider-reported model be distinguishable from Raven's outgoing id. This PR resolves only the empty-quality pin; merging withFixesauto-closes the issue with those asks unaddressed. SuggestPart of #1106/Refs #1106, or narrowing the issue first. -
The Risk note says "calls with no requested quality keep the same behaviour as before (gpt-image-2 still defaults to medium...)". For the exact
gpt-image-2id — the only model matched by themediumspecial case atmedia_gen.py:749— with picker-savedquality: ""and no call quality, the outbound request changes from omittingqualityto sendingquality: "medium"(verified at this head:{}and{"quality": ""}both resolve to"medium"when the request names none). If the provider default is medium this is externally identical, but the sentence as written is not exact and no test pins that combination. Consider adding a case ({"quality": ""}, requestedNone,gpt-image-2→"medium") or softening the claim. -
Minor doc wording (optional):
MediaToolConfig's "Empty quality uses the provider default." now reads narrower than the implemented rule — empty means no quality named, so the call's quality applies first and the provider default only when the call names none. Since this change is precisely about that semantics, clarifying the sentence would prevent the ambiguity recurring.
Verification (native Windows 11, CPython 3.12, isolated worktree at this head, scratch HOME/USERPROFILE, offline venv):
pytest tests/test_media_gen_tool.py -q→ 165 passed.- RED check: reverting only the condition makes exactly the two new behavioural tests fail (
...picker-saved-emptyand the end-to-end case); the other parametrizations still pass, so the tests do catch the bug. pytest tests/test_ppt_engine_generate_image_tool.py tests/test_rpc_console.py -q→ the ppt-engine file passes; the 4test_rpc_console.pyfailures are pre-existing Windows environment failures (WinError 1314 symlink privilege, CRLF versus LF byte compare,HOMEversusUSERPROFILE), with identical failing IDs at base06509f8e.ruff checkandruff format --checkon both changed files → clean.- CI at review time: 20 passed, 1 pending (
unit py3.12 4/4); merge state isBLOCKEDon the required review/approval, not on this diff.
An empty tools.media.image.quality names no quality: with the picker's saved empty value and no quality on the call, resolution lands where an unset section lands -- the exact gpt-image-2 keeps its medium default and a family without the knob sends none. That combination had no test, so the behaviour could regress silently. The MediaToolConfig docstring now states the rule directly instead of saying only that an empty value uses the provider default. Co-authored-by: Claude (deepseek-flash) <noreply@anthropic.com>
|
Windows compatibility review — PR #1137 @ Scope: the PR's own diff is Windows angle: none. The change is pure quality-resolution logic in the image-generation tool; it adds no path, argv, subprocess, signal, socket, encoding, or filesystem surface, and nothing in it branches on the platform. Verification (native Windows 11; detached worktrees
Coverage gaps: the full suite was not rerun; no live image provider call was made (the tests stop at request assembly). No Windows-specific issue found. |
LivXue
left a comment
There was a problem hiding this comment.
Approving at c75ceab. CI is green (22 passed, 1 skipped) and the core fix is correct: an explicitly empty Settings quality no longer outranks the call's own quality, a named Settings value still wins, and the configured model keeps its precedence. The non-blocking review findings (ppt-engine deck-name normalization for the two no-quality spellings, the schema wording, and the custom-base/live-config test coverage) will follow in a separate PR because the fork head branch is no longer writable.
|
Follow-up: #1155 carries the non-blocking review findings that could not be pushed to this fork branch (the fork is no longer writable): deck-name normalization for the two no-quality spellings, the schema wording, and the custom-base/live-config test coverage. |
## Summary Follow-up to #1137. This branch carries the review findings that could not be pushed into the contributor's fork branch: the fork is no longer writable. - The deck generator in `plugins-dist/ppt-engine` keyed its generated file name on the effective quality. #1137 makes an empty Settings quality resolve to `None` where it used to resolve to `""`, and the digest formatted those two spellings differently even though both send no quality. A deck regenerated after the upgrade therefore stopped overwriting the file its page names. The digest now maps both spellings to the empty spelling's key, so a picker-saved section's deck keeps its name while the call still sends no quality; the exact `gpt-image-2` case is the exception under Risk. - `MediaToolConfig`'s docstring now states the actual resolution rule: the request's value applies for the gpt-image family; with nothing on the request either, exact `gpt-image-2` sends `medium` and other models send nothing. - The media-gen tests now compare an empty Settings quality with a truly unset section, and a live-config e2e covers the report's custom `/images/generations` route. ## Type - [x] Fix ## Verification - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [ ] User-facing docs or screenshots are updated when needed - RED at #1137's base: the picker-saved-empty cases and the custom-route e2e fail, and the deck-name test produces two different file names for the same no-quality request (the two unset-section controls pass). - GREEN: `pytest tests/test_media_gen_tool.py tests/test_ppt_engine_generate_image_tool.py tests/test_config_self_surface.py tests/test_raven_config_tool.py -q` -> 455 passed. - The no-quality name is pinned to the empty spelling: normalizing the digest to the `None` spelling instead makes `test_both_spellings_of_no_quality_name_the_same_file` fail on the historical name (`lantern-b384de827020.png`), where the real tree passes. - `ruff check` and `ruff format --check` on the changed files -> clean. - commitlint on the six commits -> 0 problems. ## Risk - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes One compatibility note: before #1137 the digest had two spellings for "no quality" (`""` for an explicitly empty gpt-image section, `None` for an unset or non-gpt-image one). This PR keeps the `""` spelling, which is what the WebUI picker's implicit empty value used; decks whose old name used `None` still move once. There is no key that preserves both. One class of picker-saved deck is not preserved: an exact `gpt-image-2` section's empty quality now resolves to `medium` (the id's documented default, from #1137), so its name follows the `medium` spelling and moves once on the first regeneration after the upgrade. Revert this PR to restore the previous digest formatting. ## Related Issues Part of #1106. Follow-up to #1137. --------- Co-authored-by: Claude Code <noreply@anthropic.com>
Summary
Selecting an image model in WebUI can implicitly save
tools.media.image.quality: ""(the model picker writes an empty quality when the reader picks a model without choosing one), andeffective_quality()treated any explicitly-present quality key as authoritative, so that empty string outranked the tool call's own request. Theif quality:sites then dropped the empty value from the outbound request, so a call asking forquality: "high"went out with no quality at all. The fix is one condition: an empty Settings value is the section's "no quality named" (the schema's own default, per the config docstring and the tool schema's "Quality used only when Settings has no quality"), so it falls through to the request; a quality actually named in Settings still wins over the call's. The configured model keeps its documented precedence over the requested model, unchanged.Type
Verification
Relevant tests pass locally
Relevant lint / type checks pass locally
User-facing docs or screenshots are updated when needed
The issue's reproduction snippet, run on the branch:
uv run pythonwithImageToolConfig(model="custom/gpt-image-2.5", provider="custom", ...)andeffective_quality("high")now prints{}'high',{'quality': ''}'high',{'quality': 'low'}'low'(before the fix the empty case returned'').uv run pytest tests/test_media_gen_tool.py -q-> 167 passed, including the new regression tests: a parametrizedeffective_qualitytable (unset / picker-saved-empty / named), a parametrized no-quality-anywhere case (an exactgpt-image-2section keeps itsmediumdefault and a family without the knob sends none), and anhttpx.MockTransportend-to-end case proving the picker-saved empty section sends the call'squality: "high"while a named Settings quality still wins.uv run pytest tests/test_subagent_routed_lane_readiness.py tests/test_tool_capabilities.py tests/test_cli_doctor_commands.py tests/test_raven_config_tool.py tests/test_rpc_console.py tests/test_ppt_engine_generate_image_tool.py tests/test_agents_ppt_launcher.py -q-> 643 passed (every suite referencingImageToolConfigor the media sections).uv run ruff checkanduv run ruff format --checkon the changed files -> all clean.Risk
User-visible change: on a section whose saved quality is the picker's empty default,
image_generatenow honours the call's own quality instead of silently omitting it; a quality named in Settings still overrides the call. With no quality on the call either, resolution lands where a section that never had the key lands: an exactgpt-image-2sends its documentedmediumdefault (the empty value used to be dropped, so nothing was sent), and a family without the knob sends none. No other request gains a parameter it did not ask for. Rollback: revert this PR; the change is one condition plus tests.Related Issues
Part of #1106