microsoft/autogen · error · ValueError
Specified model_client doesn't support structured output mod
Error message
Specified model_client doesn't support structured output mode.
What it means
CodeExecutorAgent requires that when retries are enabled the model must support structured (JSON) output, checked via model_client.model_info["structured_output"]. Retries depend on re-requesting the output in a structured format, so an unsupported model cannot be used with max_retries_on_error > 0.
Source
Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py:495
if model_client is not None:
self._model_client = model_client
if model_context is not None:
self._model_context = model_context
else:
self._model_context = UnboundedChatCompletionContext()
self._system_messaages: List[SystemMessage] = []
if system_message is None:
self._system_messages = []
else:
self._system_messages = [SystemMessage(content=system_message)]
if self._max_retries_on_error > 0:
if not self._model_client or not self._model_client.model_info:
raise ValueError("model_client.model_info must be provided when max_retries_on_error > 0")
if not self._model_client.model_info["structured_output"]:
raise ValueError("Specified model_client doesn't support structured output mode.")
@property
def produced_message_types(self) -> Sequence[type[BaseChatMessage]]:
"""The types of messages that the code executor agent produces."""
return (TextMessage,)
@property
def model_context(self) -> ChatCompletionContext:
"""
The model context in use by the agent.
"""
return self._model_context
async def on_messages(self, messages: Sequence[BaseChatMessage], cancellation_token: CancellationToken) -> Response:
async for message in self.on_messages_stream(messages, cancellation_token):
if isinstance(message, Response):
return message
raise AssertionError("The stream should have returned the final result.")View on GitHub (pinned to 027ecf0a37)
Solutions
- Set max_retries_on_error=0 (default) when the model lacks structured output support.
- Switch to a model/client that declares structured_output=True in model_info.
- If you control the model_info dict and the backend actually supports JSON mode (e.g. vLLM guided decoding), correct the flag.
Example fix
// before
agent = CodeExecutorAgent(
name="coder",
code_executor=executor,
model_client=local_client, # structured_output: False
max_retries_on_error=3,
)
// after
agent = CodeExecutorAgent(
name="coder",
code_executor=executor,
model_client=local_client,
max_retries_on_error=0,
) Defensive patterns
Strategy: validation
Validate before calling
info = getattr(model_client, "model_info", None) or {}
if max_retries_on_error > 0 and not info.get("structured_output", False):
max_retries_on_error = 0 # model can't support structured retry
agent = CodeExecutorAgent(name="coder", code_executor=exec_,
model_client=model_client,
max_retries_on_error=max_retries_on_error) Type guard
def supports_structured_output(client) -> bool:
info = getattr(client, "model_info", None) or {}
return bool(info.get("structured_output", False)) Prevention
- Check model_info['structured_output'] before enabling retries.
- Keep a curated map of which deployed models support JSON mode.
- Correct stale model_info flags on custom clients when the backend gains guided-JSON support.
When it happens
Trigger: CodeExecutorAgent(max_retries_on_error=N) with a model whose model_info has structured_output=False (e.g., many open-weight/local models served via clients that declare no JSON-mode support).
Common situations: Using local models (llama.cpp, vLLM without guided JSON) or custom clients with hand-written model_info that sets structured_output=False; enabling retries by copy-paste.
Related errors
- Unsupported config type {config.GetType()}
- Messages should not be provided in options
- The agent name must be a valid Python identifier.
- model_client.model_info must be provided when max_retries_on
- At least one of max_total_token, max_prompt_token, or max_co
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/a53fe1cc750f1fb4.
Report an issue: GitHub.