Skip to content

bug: first LLM call returns empty response (max_tokens on a 4096 model), second call with same prompt succeeds #181

Description

@EtienneLescot

Summary

The very first LLM call from the app fails with an empty response from the model. The second call with the exact same prompt works — the failure is only on the first invocation after a cold start (or session open).

Error message

Empty response from model (provider=minimax-token-plan, model=MiniMax-M3, chat_model_chunks=314, other_events=36:on_chain_start,on_chain_start,on_chain_end,on_chain_start,on_chain_end).
Last chunk: {"lc":1,"type":"constructor","id":["langchain_core","messages","AIMessageChunk"],"kwargs":{"content":[],"additional_kwargs":{"stop_reason":"max_tokens"},"tool_call_chunks":[],"usage_metadata":{"input_tokens":0,"output_tokens":4096,"total_tokens":4096},"response_metadata":{},"id":"run-019fa5b2-ab3f-735a-8f97-69329f5c7e31","tool_calls":[],"invalid_tool_calls":[]}}

Observations from the error

  • model: MiniMax-M3
  • stop_reason: max_tokens
  • output_tokens: 4096 (hit the per-call cap on a response that was discarded)
  • content: [] (model emitted no text / tool calls before hitting the cap)
  • input_tokens: 0 (the request appears to have been sent with an empty prompt, or the prompt accounting was lost)
  • chat_model_chunks: 314 (the stream produced many chunks but none carried content)
  • The LangChain AIMessageChunk is empty, so the app reports "Empty response from model"

Steps to reproduce

  1. Start the app / open a fresh editor session (cold start)
  2. Trigger any LLM-backed feature (e.g. chat assistant, auto-zoom, caption polish, etc.) on the first prompt
  3. Observe the error in the console / chat panel
  4. Resend the same prompt — it succeeds

Expected

The first LLM call should produce a normal response, same as subsequent calls.

Actual

First call fails with the empty-response error above; second call with the identical prompt succeeds.

Hypotheses to investigate

  • The first call is being made with an empty / zero-token prompt (input_tokens: 0), causing the model to immediately hit max_tokens while producing no content.
  • Provider warm-up: the first call to minimax-token-plan / MiniMax-M3 after a cold start may not receive a proper prompt.
  • LangChain streaming: 314 chunks with no content — possible bug in how the first stream is consumed (e.g. no AIMessageChunk is finalized).
  • output_tokens: 4096 is suspiciously the model cap; the first call may be silently retried / looped until the cap is exhausted.

Environment

  • Version: v1.8.0.rc4
  • Provider: minimax-token-plan
  • Model: MiniMax-M3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions