Skip to content

Keep agent running after image read on gpt-5.5 #283

Closed as not planned
Closed as not planned

Description

@aebrer

Summary

When using gpt-5.5, reading an image with the read tool appears to end the agent turn after the image attachment is returned. The tool result is otherwise valid and the model can see/use the image, but the agent stops until the user manually sends another message.

This is disruptive for interactive use and breaks automated workflows that expect the agent to continue reasoning after read returns an image.

Current Behavior

  • The agent calls read on an image file.
  • read returns text plus an image content block.
  • With gpt-5.5, the agent yields control instead of continuing to the next model call automatically.
  • The user must manually prompt the agent to proceed.

Proposed Behavior

  • Image reads should behave like text reads from the agent-loop perspective.
  • Unless the tool result explicitly sets endTurn: true, the agent should continue to the next model call after processing the image tool result.
  • Automated workflows should be able to read images and continue without user intervention.

Acceptance Criteria

  • Reproduce the issue with gpt-5.5 by calling read on a supported image file.
  • Identify whether the premature yield is caused by provider response handling, image tool-result conversion, agent-loop stop-reason handling, or TUI/session orchestration.
  • Add or update tests that cover image-returning tool results through the affected provider path.
  • Confirm read image results do not set or imply endTurn.
  • Confirm tools that intentionally set endTurn: true still end the turn.
  • Manual verification: with gpt-5.5, ask the agent to inspect an image and continue with a follow-up action; it should proceed without an extra user message.

Context

Reported behavior: "when using gpt-5.5 to view images, for some reason the READ tool on an image is ending the agents turn. Everything works but its annoying to have to manually tell the agent to proceed and this breaks any automated workflows."

Technical Notes

Relevant areas to inspect:

  • packages/coding-agent/src/core/tools/read.ts — image reads return a text note plus an image content block and should not set endTurn.
  • packages/agent/src/agent-loop.ts — tool results should only stop the loop when the tool result explicitly has endTurn: true.
  • packages/agent/src/types.ts — AgentToolResult.endTurn documents the explicit yield mechanism.
  • packages/ai/test/openai-responses-tool-result-images.test.ts — existing coverage for OpenAI Responses-style tool-result images.
  • packages/ai/test/image-tool-result.test.ts — cross-provider image tool-result coverage.

There may already be tests proving image tool results can be sent to providers, so the missing coverage may need to be closer to the full coding-agent/agent-loop flow with the read tool and the openai-codex/gpt-5.5 route.

Suggested Labels

  • bug
  • P1

Activity

  1. added
    bug
    P1
    on Jun 18, 2026
  2. aebrer commented on Jun 18, 2026

    @aebrer
    OwnerAuthor

    Reproduction Evidence from Session Log

    I inspected the recent session log named crengine drawbuf invertColors:

    /home/drew/.dreb/agent/sessions/--home-drew--/2026-06-17T21-47-56-476Z_7d14458e-e50b-4bad-8454-2ef19577f934.jsonl

    Near the end, the log shows the symptom clearly:

    • At 2026-06-18T21:56:07.218Z, the assistant calls read on /home/drew/Downloads/signal-2026-06-18-175507.jpeg.
    • At 2026-06-18T21:56:07.800Z, the read tool returns successfully with:
      • text: Read image file [image/png] ...
      • image content block: image/png, base64 payload length about 1.58 MB
    • There is no subsequent assistant message continuing from that tool result.
    • The next message is a user prompt at 2026-06-18T21:56:31.644Z: and the next one too.
    • The same pattern repeats for /home/drew/Downloads/signal-2026-06-18-175507_002.jpeg:
      • assistant calls read at 2026-06-18T21:56:36.069Z
      • tool result returns at 2026-06-18T21:56:36.551Z with text plus image payload length about 1.52 MB
      • no assistant continuation until the user asks So what do you think, not bad right? ...

    Important observations:

    • The read tool result itself is successful (isError: false).
    • The image block is present and usable; after the user nudges the session, the assistant correctly analyzes both screenshots.
    • The log does not show the read tool setting endTurn, and there is no obvious explicit assistant stop/error immediately after the image tool result.
    • This supports the hypothesis that the premature yield is happening in the agent loop/provider/session orchestration path after an image-bearing tool result, rather than in the file read itself.

    This should be useful as a concrete repro trace for implementation planning.


    Automated progress note by mach6

  3. aebrer commented on Jun 18, 2026

    @aebrer
    OwnerAuthor

    Additional Confirmation

    User confirmed that the model did successfully read and understand the image contents after the manual follow-up. The issue is therefore not that image tool results are unusable or invisible to gpt-5.5; the problem is specifically that the agent turn ends prematurely after the image-bearing read tool result, requiring a user nudge before the model continues reasoning about the image.


    Automated progress note by mach6

  4. aebrer commented on Jun 18, 2026

    @aebrer
    OwnerAuthor

    Issue Assessment: Expected Background-Agent Guardrail

    Root cause identified: this was not caused by gpt-5.5, image tool-result serialization, or the read tool.

    The session that appeared to reproduce the issue had background subagents running. dreb intentionally limits parent-agent continuation while background agents are active to prevent the parent from spinning/hyperactively continuing while waiting for subagent results.

    Relevant implementation:

    • packages/coding-agent/src/core/tools/subagent.ts
      • background subagent launches return endTurn: true intentionally.
    • packages/coding-agent/src/core/agent-session.ts
      • tracks parent turns while background agents are running with _bgTurnCounter.
      • BG_TURN_LIMIT = 3.
      • installs agent.setShouldContinue(...), which returns false once the parent has taken enough turns while background agents are still active.
    • packages/agent/src/agent-loop.ts
      • checks config.shouldContinue() before subsequent LLM calls, so when the guardrail says stop, the loop ends cleanly without another assistant message.

    Why it looked image-specific:

    • The screenshots were read near the end of a session while background review agents were still running.
    • The image read results were successful and visible to the model.
    • The apparent “turn ended after image read” behavior was the normal parent-turn limiter kicking in during background-agent activity, not failure to process image content.
    • In a fresh/current repro without hitting that guardrail, image reads continue normally and the model can inspect the screenshots.

    Conclusion: close as expected behavior / not planned. No code change needed.


    Automated assessment by mach6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions