FoundationAgents/MetaGPT · error · InputRequired
prompt or messages is required!
Error message
prompt or messages is required!
What it means
DashScope generation entry (Generation.acall) requires either prompt or messages; if both are None/empty, InputRequired('prompt or messages is required!') is raised immediately, before any network call. It is a pure argument-validation guard.
Source
Thrown at metagpt/provider/dashscope_api.py:120
request_data.add_parameters(**kwargs)
request.data = request_data
return request
class AGeneration(Generation, BaseAioApi):
@classmethod
async def acall(
cls,
model: str,
prompt: Any = None,
history: list = None,
api_key: str = None,
messages: List[Message] = None,
plugins: Union[str, Dict[str, Any]] = None,
**kwargs,
) -> Union[GenerationResponse, AsyncGenerator[GenerationResponse, None]]:
if (prompt is None or not prompt) and (messages is None or not messages):
raise InputRequired("prompt or messages is required!")
if model is None or not model:
raise ModelRequired("Model is required!")
task_group, function = "aigc", "generation" # fixed value
if plugins is not None:
headers = kwargs.pop("headers", {})
if isinstance(plugins, str):
headers["X-DashScope-Plugin"] = plugins
else:
headers["X-DashScope-Plugin"] = json.dumps(plugins)
kwargs["headers"] = headers
input, parameters = cls._build_input_parameters(model, prompt, history, messages, **kwargs)
api_key, model = BaseAioApi._validate_params(api_key, model)
request = build_api_arequest(
model=model,
input=input,
task_group=task_group,
task=Generation.task,View on GitHub (pinned to 11cdf466d0)
Solutions
- Pass a non-empty prompt or a non-empty messages list.
- Add your own precondition check/log before calling so empty prompts are caught with better context.
- If messages-based, ensure the messages list itself (not history) carries the conversation.
Example fix
// before resp = await Generation.acall(model="qwen-plus", prompt="", messages=[]) // after resp = await Generation.acall(model="qwen-plus", prompt="Summarize this document...")
Defensive patterns
Strategy: validation
Validate before calling
def has_prompt(prompt, messages) -> bool:
return bool(prompt) or bool(messages)
assert has_prompt(prompt, messages), "prompt or messages required" Try / catch
try:
resp = await Generation.acall(model=model, prompt=prompt, messages=messages)
except Exception as e:
if "prompt or messages is required" in str(e):
raise ValueError("refusing to call LLM with empty prompt") from e
raise Prevention
- Reject empty prompts at the application layer with a descriptive error.
- Log prompt length before dispatch to catch silent empty-string bugs.
When it happens
Trigger: Calling Generation.acall(model='qwen-plus') with neither prompt nor messages, or with prompt='' and messages=[]; template code where the prompt variable ended up empty.
Common situations: Building prompts dynamically and shipping an empty string; passing messages only as history (history alone does not satisfy the check); config-driven prompt templates resolving to empty.
Related errors
- Unsupported protocol: %s, support [http, https, websocket]
- There is no input data and form data
- Model is required!
- Only support for python, markdown, but got {language}
- Only support for language: python, markdown, but got {langua
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/5c8797d134587a2a.
Report an issue: GitHub.