Skip to content

fix(chat): only teach image generation when the session has it - #4574

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/sd-rule-only-when-enabled
Oct 5, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/sd-rule-only-when-enabled

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

A new user's first Agent UI question, "What can you do?", was answered with "…researching topics online or generating concept art when inspiration strikes" — but image generation is off by default. Every session's prompt carried the generate_image rule ("when SD enabled"), and a small local model read that as a capability. The rule now appears only when image generation is enabled; otherwise the prompt says it isn't available.

Draft until an eval runs — this changes the system prompt.

Test plan

  • pytest tests/unit/test_sd_rule_gating.py — the rule follows enable_sd_tools
  • pytest hub/agents/gaia/python/tests/test_prompt_prefix_stability.py hub/agents/gaia/python/tests/test_prompt_prefix_stability_sd_off.py: with image generation on or off, the system prompt is byte-identical across turns
  • gaia eval agent --category rag_quality and --category gaia_core (and a capability-question scenario) on this branch and on main
  • Agent UI, default install: "What can you do?" no longer offers images

@github-actions github-actions Bot added the tests Test changes label Oct 2, 2026
@kovtcharov

Copy link
Copy Markdown
Contributor Author

gaia_rag eval, same machine, back to back: a build with this PR (plus the other open walkthrough fixes) passed 8/8, average 9.6/10; main passed 7/8, average 9.1/10. No regression; the one main failure is rag_csv_via_retrieval (7.2).

🔍 Technical details

Local Gemma-4-E4B on Radeon 8060S, sandboxed fresh install with its own embedded Lemonade; two Agent UI servers (integration build on :4301, origin/main 842d014 on :4302) run serially, judge claude-opus-5. One run per scenario per build, so single-scenario deltas are within noise.

scenario this build main
rag_buried_fact_large_doc 9.6 9.8
rag_cross_doc_synthesis 9.7 9.4
rag_cross_turn_retention 9.2 8.8
rag_csv_via_retrieval 9.2 7.2 FAIL
rag_dont_know_absent_fact 9.8 9.7
rag_factual_report 9.8 9.8
rag_hallucination_pressure 9.7 9.8
rag_handbook_policy 9.8 9.8

The integration build was faster on 7 of 8 scenarios. It ran before the last wording tweak to the indexed-documents rule ("the latest message's line"), which is not reflected here.

@kovtcharov
kovtcharov force-pushed the kalin/sd-rule-only-when-enabled branch 3 times, most recently from 4ec9893 to 53cc450 Compare October 4, 2026 21:03
A new user's "What can you do?" in the Agent UI was answered with
"...or generating concept art" although image generation is off by
default: the prompt carried the generate_image rule in every session.
The rule now appears only with enable_sd_tools; otherwise the prompt
says image generation is not available.
@kovtcharov
kovtcharov force-pushed the kalin/sd-rule-only-when-enabled branch from 53cc450 to 934f8a5 Compare October 4, 2026 22:09
Kalin Ovtcharov and others added 2 commits October 4, 2026 18:41
The image-generation rule now depends on enable_sd_tools. The flag is set
once per session, so either rule must leave the system prompt byte-stable
across turns. The cached-prefix test runs the flagship with the flag on;
this runs two turns with it off.
@kovtcharov-amd
kovtcharov-amd marked this pull request as ready for review October 5, 2026 03:44
@kovtcharov-amd
kovtcharov-amd self-requested a review as a code owner October 5, 2026 03:44
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions. Hold the merge until the eval runs, since this changes the system prompt.

The fix is right: a session without image generation no longer carries a rule about generate_image, so a small model stops listing "concept art" as something it can do. The gating uses the same setting that registers the tool, and both new tests cover on and off.

Before merge:

  • Run the evals. The PR is already a draft for this reason. Its checklist names rag_quality and gaia_core, compared against the flagship baseline.
  • Show the Agent UI result. The fix is aimed at the default-install "What can you do?" answer, so attach the before/after screenshot listed in the test plan.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review alone. The user-visible change (how the Agent UI answers a capability question) and the eval impact both still need the strix-halo lane.

🔍 Technical details

🟡 Important

  • The eval is required before merge (hub/agents/chat/python/gaia_agent_chat/agent.py:1243-1253). CLAUDE.md requires a gaia eval agent run for any _get_system_prompt() change. Dispatch eval_flagship.yml and report PASS→FAIL and FAIL→PASS separately against tests/fixtures/eval_baselines/gaia-flagship/. The flagship defaults enable_sd_tools=True, so most lanes see the "on" branch. Only the fast profile (gaia_agent/agent.py:319) and ChatAgent defaults get the new "off" text. Include a lane that exercises the off path.
  • The Agent UI screenshot is missing. This is the surface the bug report came from. Text and unit tests don't replace it under the rubric.

🟢 Minor

  • The off-branch drops the way to turn image generation on (agent.py:1252). The old rule told the model to mention --sd when an image request failed. Now a user who explicitly asks for an image gets a refusal with no next step. "Never offer" is right for capability questions, but an explicit request should still get the pointer:
    **IMAGE GENERATION:** Not available in this session. Never offer or claim it; if the user asks for an image, say it's off in 1 sentence (mention `--sd` flag).
    
    If you take this, update the "Not available in this session." assertions in both new tests to match.
  • The new unit test may never run in the unit lane (tests/unit/test_sd_rule_gating.py:5). importorskip("gaia_agent_chat") skips it wherever the chat wheel isn't installed. test_prompt_prefix_stability_sd_off.py runs in test_gaia_agent.yml, so coverage exists either way. Just confirm the skip is intended.
  • The profilespec_characterization goldens (row13/row14 and others) still contain the old (when SD enabled) text. They were already stale on main (for example, they still list audio as unsupported), so this PR didn't cause it. They will drift further.

Strengths

  • The prompt gating keys on the same enable_sd_tools check that registers the SD tools, so the prompt and the tool list can't disagree.
  • The SD-off prefix-stability test reuses the existing flagship harness through a functools.partial swap of the config. It's a neat way to cover the cache invariant from fix(agent): keep the system prompt fixed so local turns stay cached #4698 on the second branch without duplicating the fixture.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 5, 2026
Merged via the queue into amd:main with commit 3a6acc8 Oct 5, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/sd-rule-only-when-enabled branch October 5, 2026 03:51
kovtcharov-amd added a commit that referenced this pull request Oct 5, 2026
It imports gaia_agent_chat, which test_unit.yml's Linux lane doesn't
install, so it skipped wholesale there (#4574) and check_module_skips.py
has been failing every PR since. test_chat_agent.yml already installs
that wheel; add it to the pytest invocation, path triggers, and the
module_skips allowlist.
kovtcharov-amd pushed a commit to aksh8b/gaia that referenced this pull request Oct 6, 2026
…ation (amd#4809)

Asking GAIA "What can you do?" threw away its answer and tried to
generate an image of the question. Any answer that mentioned image
generation was treated as a failure to call the image tool, with no
check that the user wanted an image or that the agent could make one —
and the flagship has image generation on by default, so this hit the
most common first question. Now a plain answer is never overridden; the
agent only steps in when an image was actually attempted this turn and
the answer doesn't say what happened.

Closes amd#4582. Supersedes the approach in amd#4583, which decides from the
wording of the user's message and so misses requests like "Draw a cat";
this one decides from the turn's tool record instead.

<details>
<summary>🔍 Technical details</summary>

- Removed: the branch that matched the answer against capability phrases
and, with no `generate_image` call on record, demanded one built from
the user's last message. The tool record cannot show intent, so there is
nothing structural to gate it on; whether to call the tool is the
prompt's and tool schema's job (amd#4574).
- Kept, gated on a `generate_image` call that returned a result this
turn on an agent with the tool registered: an answer that says when
image generation is available instead of reporting the outcome gets one
correction, which now names the recorded outcome (succeeded / returned
an error). It was unbounded before. The amd#1023 failure override is
unchanged.
- A wording check on the answer remains in that kept path because the
record holds the outcome but not what the answer claims about it. It can
no longer run without a recorded outcome.
- A call to a `generate_image` the agent doesn't have no longer arms
either check.
</details>

## Test plan

- [x] `python -m pytest tests/unit/agents/test_image_outcome_guard.py
tests/unit/agents/test_parse_error_recovery.py` — the new reproduction
fails on main and passes here; the amd#1023 cases still pass
- [x] `python -m pytest tests/unit/agents
hub/agents/gaia/python/tests/test_prompt_prefix_stability.py`
- [ ] `eval_flagship.yml` — `gaia_media`
- [ ] `eval_flagship.yml` — `gaia_core`
- [ ] `eval_flagship.yml` — `personality`
- [ ] `eval_flagship.yml` — `tool_selection`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants