Skip to content

fix(agent): an empty settings quality no longer pins image calls - #1137

Merged
LivXue merged 2 commits into
EverMind-AI:mainfrom
kaguranananana:fix/media_selection_empty_quality
Nov 1, 2026
Merged

LivXue merged 2 commits into
EverMind-AI:mainfrom
kaguranananana:fix/media_selection_empty_quality

Conversation

@kaguranananana

@kaguranananana kaguranananana commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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), and effective_quality() treated any explicitly-present quality key as authoritative, so that empty string outranked the tool call's own request. The if quality: sites then dropped the empty value from the outbound request, so a call asking for quality: "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

  • Fix

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 python with ImageToolConfig(model="custom/gpt-image-2.5", provider="custom", ...) and effective_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 parametrized effective_quality table (unset / picker-saved-empty / named), a parametrized no-quality-anywhere case (an exact gpt-image-2 section keeps its medium default and a family without the knob sends none), and an httpx.MockTransport end-to-end case proving the picker-saved empty section sends the call's quality: "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 referencing ImageToolConfig or the media sections).

  • uv run ruff check and uv run ruff format --check on the changed files -> all clean.

Risk

  • Security impact considered
  • Backward compatibility considered
  • Rollback path is clear for risky changes

User-visible change: on a section whose saved quality is the picker's empty default, image_generate now 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 exact gpt-image-2 sends its documented medium default (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

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 gloryfromca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 passed
  • uv run ruff check raven/agent/tools/media_gen.py tests/test_media_gen_tool.py - passed
  • uv run ruff format --check raven/agent/tools/media_gen.py tests/test_media_gen_tool.py - passed
  • git 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.

@LivXue

LivXue commented Oct 27, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — PR #1137 @ 613ab99a1caf33616232f28236b16a8e49c9052c

Scope: full base 06509f8e → this head — raven/agent/tools/media_gen.py and its tests. The change makes an explicitly-present but empty tools.media.image.quality count as "no quality named", so it no longer outranks a quality the tool call itself requests.

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 D:\tmp\rv-1137 at this head, scratch HOME/USERPROFILE, PYTHONUTF8=1):

pytest tests/test_media_gen_tool.py -q
→ 165 passed in 8.69s

Limitations: no live image-generation call; the behaviour is covered by the unit suite.

@kaguranananana

Copy link
Copy Markdown
Contributor Author

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 LivXue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. 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 with Fixes auto-closes the issue with those asks unaddressed. Suggest Part of #1106 / Refs #1106, or narrowing the issue first.

  2. 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-2 id — the only model matched by the medium special case at media_gen.py:749 — with picker-saved quality: "" and no call quality, the outbound request changes from omitting quality to sending quality: "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": ""}, requested None, gpt-image-2 → "medium") or softening the claim.

  3. 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-empty and 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 4 test_rpc_console.py failures are pre-existing Windows environment failures (WinError 1314 symlink privilege, CRLF versus LF byte compare, HOME versus USERPROFILE), with identical failing IDs at base 06509f8e.
  • ruff check and ruff format --check on both changed files → clean.
  • CI at review time: 20 passed, 1 pending (unit py3.12 4/4); merge state is BLOCKED on 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>
@LivXue

LivXue commented Oct 31, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — PR #1137 @ c75ceab3338ccfb6dfb922d67c981da8eb66e33d

Scope: the PR's own diff is 06509f8e..c75ceab333 (3 files, +77/−3): ImageGenerateTool.effective_quality now skips an empty settings quality (config.quality truthiness added to the model_fields_set test), so a picker-written quality: "" no longer outranks the request's own value — the gpt-image-2 default (medium) applies only when the call names none either, and other families send no quality. A schema docstring and six new assertions follow.

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 D:\tmp\rv-1137 at head and D:\tmp\rv-base-1137 at base 06509f8e; offline venv from each lock; scratch HOME/USERPROFILE; PYTHONUTF8=1; PYTHONPATH pinned):

  • uv run --no-sync pytest tests/test_media_gen_tool.py -q -n 0 --tb=line
    • head: 167 passed (22.7 s)
    • base: 161 passed (19.6 s)
    • zero failures at both; the added tests pass, including the empty-quality resolution for gpt-image-2 and other families.

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 LivXue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@LivXue
LivXue merged commit a744952 into EverMind-AI:main Nov 1, 2026
23 of 26 checks passed
@LivXue

LivXue commented Nov 1, 2026

Copy link
Copy Markdown
Member

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.

LivXue added a commit that referenced this pull request Nov 2, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants