Repository navigation
fix(agent): gate SD capability claim guardrail on user image intent (bug #4582) - #4583
madcow4242 wants to merge 1 commit into
Conversation
|
Verdict: Request changes This PR has the right goal. The image-generation guardrail should only fire when the user actually asked for an image, so questions like "what can you do?" stop getting their answers overwritten. The problem is the check that decides whether the user asked for an image. It misses the most common ways people ask, so the guardrail now goes quiet exactly when it is needed.
Real-world evidenceN/A: no evidence bundle was produced for this run (agent-loop guardrail change, real inference is deferred to the strix-halo lane). This verdict rests on static review alone. The prompt results above come from running the PR's patterns directly, not from a live agent run. The PR doesn't show a 🔍 Technical details🟡 Intent regex has large false-negative and false-positive gaps (
Also consider hoisting this list (and the existing 🟡 Intent is read from the last The loop appends many synthetic That also keeps the injected tool-call prompt seeded with the real request instead of a correction message. 🟡 No tests for the new gating
🟢 Nit: the default for Strengths
|
|
Thanks for tracking this down and fixing it — #4582 was real and your report pinned it. It's now fixed by #4809, which merged today and takes a different route: rather than deciding from the wording of the user's message (which misses requests like "Draw a cat"), it only steps in when an image was actually attempted this turn, judged from the turn's tool record. Closing this one as superseded. Thanks again for the contribution. |
…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`
Closes #4582
Summary
Add user-intent checking before triggering the Stable Diffusion capability guardrail in
gaia/agents/base/agent.py. This prevents GAIA from blocking plain-text answers and injecting forcedgenerate_imagetool calls on general Q&A queries.Why
When an agent answers a general prompt (e.g., "What capabilities do you have?" or "What tools do you support?") with text mentioning image generation, the SD guardrail previously flagged it as an unattempted tool claim. The framework then injected a synthetic prompt (
SYSTEM: STOP. Do NOT write text. You must output a JSON tool call...), forcing the agent into a second turn where it declined the forced call—overwriting its original complete answer with a refusal summary.Linked issue
Closes #4582
Changes
_last_user_msgprior to evaluating capability claim blocks ingaia/agents/base/agent.py._USER_IMAGE_PATTERNSregex matching to scan the last user message for explicit image creation verbs/nouns (e.g.,generate,draw,create,picture,image,generate_image)._user_requested_image == Truein_should_block_sdbefore blocking text capability claims.Test plan