Skip to content

fix(agent): ground final answers in observed screen state (DRO-3714) - #541

Closed
Cyro292 wants to merge 8 commits into
droidrun:developfrom
Cyro292:fix/dro-3714-unread-screen-values
Closed

Cyro292 wants to merge 8 commits into
droidrun:developfrom
Cyro292:fix/dro-3714-unread-screen-values

Conversation

@Cyro292

@Cyro292 Cyro292 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes DRO-3714: the task agent reports values that were never on screen, and the task still succeeds.

Root cause (reproduced on a real cloud phone)

5 of 5 real tasks (mobilerun/mobile-agent-fast, vision off, FastAgent) read https://ipinfo.io/json in Chrome and returned succeeded: true with invented values. The values the agent reported (city, country, ASN/org) did not match what the page actually showed.

  1. Chrome had not exposed the page text yet. The accessibility state the model saw before it answered contained only the URL and an empty Web View, with no JSON. A later snapshot did contain the JSON, so this is a timing delay.
  2. The prompt claimed a screenshot. fast_agent/system.jinja2 said "Analyze the current device state and screenshot" even with vision off. The model then wrote "Looking at the screenshot, the JSON displays…" and invented plausible values.
  3. complete() is self-reported. The answer and the success flag are accepted without any check.

Changes

  • FastAgent prompt (fast_agent/system.jinja2)
    • The screenshot instruction appears only when vision is on.
    • With vision off, the prompt says the state is only the accessibility tree, which can leave out rendered content.
    • A URL with an empty Web View is not page content: wait, re-read, or report that the value could not be read.
    • Report only observed values, name where they came from, never substitute another source, and use success=false when a requested value was not read.
  • complete() tool description (signatures.py): the same grounding rules.
  • Manager prompts (system, stateless, rev1, trained): the same rules for reasoning mode. Both manager agents now pass vision to prompt rendering.
  • FastAgent (fast_agent.py): after a failed get_state(), the stale UI state is dropped and the model gets an "unavailable" notice instead of the previous screen.
  • Tests: tests/test_fast_agent_state_grounding.py and tests/test_reasoning_state_grounding.py.

Verification

  • pytest -q: 1625 passed, 41 subtests passed. ruff check on the changed files and git diff --check are clean.
  • New prompt and stale-state tests failed before the fix and pass after it.
  • Offline replay of the real recorded states (empty WebView) with GPT Luna stand-ins: no invented values on either old or new code. This does not prove the fix for Gemini Flash-Lite. The stand-in models did not reproduce the bug even on the old code.

Not yet verified

  • Not yet run with the production model. Before closing the ticket, re-run the same ipinfo tasks on staging with this build and compare against the 5/5 failure baseline.
  • Prompt-only. These changes make invented values less likely but cannot rule them out. If staging still shows them, the follow-up is a code check: refuse success=true when no readable page content was observed.
  • The deployed API ran these tasks with reasoning=false even when reasoning was omitted. The local tasks-api default is true, so this needs checking separately.

lutz-grex and others added 5 commits November 4, 2026 22:05
* fix(inference): expose empty response metadata

* fix(inference): classify empty responses

Add a machine-readable category (provider_blocked, truncated,
tool_calls_only, thinking_only, blocks_without_text, empty_stream,
empty_content, no_response, no_message), read finish_reason from
LiteLLM choices[0] / Gemini candidates[0] and pydantic raw payloads,
and cover the handout's test cases (empty, safety, thinking-only,
tool-only, empty stream, redaction, completion, structured).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* refactor(inference): trim diagnostics

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(inference): classify adapter empties

* fix(inference): classify responses truncation

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* refactor(inference): trim diagnostics and tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(inference): keep str enum reasons

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Drop stale UI state after failed state reads, stop implying screenshot access when vision is off, treat empty WebViews as unread content, and require observed values or an explicit 'could not be read' with success=false in fast-agent and manager prompts.

@lutz-grex lutz-grex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the detailed write-up. Removing screenshot instructions when vision is off and invalidating stale UI evidence both address the reported problem.

Two test issues need fixing before merging:

  1. tests/test_vision_off_grounding_prompt.py:48–63 requires vision-on output to match origin/develop exactly, but this PR also adds a Reading Values section for vision-on mode in the fast-agent and four manager templates. Please assert the intended prompt content instead of comparing against a moving Git ref. The current test also depends on historical prompt blobs being available in the checkout.
  2. tests/test_reasoning_state_grounding.py:47–58 constructs ManagerAgent with object.__new__ without setting agent.vision, then calls a method that reads it at mobilerun/agent/manager/manager_agent.py:236. Please initialize that field in the fixture or remove the redundant new dictionary entry. Both managers already supply vision later in the same dictionary (manager_agent.py:247 and stateless_manager_agent.py:112).

A couple of follow-ups within this change:

  • After mobilerun/agent/fast_agent/fast_agent.py:375 clears action_ctx.ui, UI-dependent actions should return an explicit unavailable-state/retry result. click still dereferences it at mobilerun/agent/utils/actions.py:264, and coordinate actions can reach ctx.ui.convert_point at :182. Please cover an attempted action after a failed state read, including a vision-on step with a fresh screenshot.
  • The Reading Values section is repeated in five templates and overlaps the new vision-off include. Could the common guidance use a shared include too?
  • The supplied diff also changes mobilerun/agent/utils/inference.py and tests/test_inference_retries.py, which account for about half the changed lines. Could those diagnostics changes be split out so this PR stays focused on screen-state grounding?

The write-up correctly separates prompt guidance from an enforced guarantee. The reported model-specific reproduction still needs the matching verification run before claiming the behavior is fixed.

…ctions on missing state, split out inference diagnostics (DRO-3714)
…d-screen-values

# Conflicts:
#	mobilerun/agent/fast_agent/fast_agent.py
@Cyro292
Cyro292 requested a review from lutz-grex November 15, 2026 14:18

@lutz-grex lutz-grex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, everything from the last round landed: the prompt test asserts the intended content, the manager fixture no longer reads vision, UI actions after a failed state read return an explicit retry result with tests for all of them, Reading Values is one shared include, and the inference changes are split out. Approving.

@Cyro292

Cyro292 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: this change already landed in another merged PR.

@Cyro292 Cyro292 closed this Nov 26, 2026
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.

2 participants