microsoft/autogen · error · ValueError
Disallowed create args are present: {disallowed_create_args.
Error message
Disallowed create args are present: {disallowed_create_args.intersection(create_args_keys)} What it means
The Anthropic client forbids certain create params (disallowed_create_args — keys the client manages itself, such as 'messages', 'stream', or 'stream_tool_inputs') from being passed in configuration. If any of them appear in the config kwargs, _create_args_from_config raises ValueError listing the offending keys, preventing callers from overriding internal request construction.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py:115
anthropic_init_kwargs = set(inspect.getfullargspec(AsyncAnthropic.__init__).kwonlyargs)
def _anthropic_client_from_config(config: Mapping[str, Any]) -> AsyncAnthropic:
# Filter config to only include valid parameters
client_config = {k: v for k, v in config.items() if k in anthropic_init_kwargs}
return AsyncAnthropic(**client_config)
def _create_args_from_config(config: Mapping[str, Any]) -> Dict[str, Any]:
create_args = {k: v for k, v in config.items() if k in anthropic_message_params or k == "model"}
create_args_keys = set(create_args.keys())
if not required_create_args.issubset(create_args_keys):
raise ValueError(f"Required create args are missing: {required_create_args - create_args_keys}")
if disallowed_create_args.intersection(create_args_keys):
raise ValueError(f"Disallowed create args are present: {disallowed_create_args.intersection(create_args_keys)}")
return create_args
def type_to_role(message: LLMMessage) -> str:
if isinstance(message, SystemMessage):
return "system"
elif isinstance(message, UserMessage):
return "user"
elif isinstance(message, AssistantMessage):
return "assistant"
else:
return "tool"
def get_mime_type_from_image(image: Image) -> Literal["image/jpeg", "image/png", "image/gif", "image/webp"]:
"""Get a valid Anthropic media type from an Image object."""
# Get base64 data firstView on GitHub (pinned to 027ecf0a37)
Solutions
- Remove request-body keys from constructor kwargs; only client options (api_key, base_url, timeout, ...) and model/create params belong there.
- Pass messages/stream controls to client.create(...) at call time, not to the constructor.
- Whitelist config keys at your config-loading layer instead of forwarding raw dicts.
Example fix
# before client = AnthropicChatCompletionClient(model='claude-sonnet-4-5', api_key=..., stream=True) # ValueError # after client = AnthropicChatCompletionClient(model='claude-sonnet-4-5', api_key=...) result = await client.create(messages, stream=True)
Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {'model', 'api_key', 'base_url', 'timeout', 'max_tokens', 'temperature', 'top_p', 'model_info'}
def clean_anthropic_cfg(cfg: dict) -> dict:
return {k: v for k, v in cfg.items() if k in ALLOWED} Prevention
- Whitelist constructor keys instead of forwarding raw dicts
- Keep request-body params (messages, stream) at create() call time
- Separate 'client config' from 'request template' in your config schema
When it happens
Trigger: Passing messages=..., stream=..., or similar request-body keys as constructor kwargs; forwarding a full request payload dict into AnthropicChatCompletionClient(**payload); copying a raw API request body into client config.
Common situations: Treating the client constructor like the messages.create() endpoint; config templating that merges request-body defaults into client kwargs; adapters that pass through user-supplied dicts unfiltered.
Related errors
- Required create args are missing: {required_create_args - cr
- model is required for AnthropicChatCompletionClient
- Invalid name: {name}. Only letters, numbers, '_' and '-' are
- Unsupported config type {config.GetType()}
- Invalid AgentId type: '{type}'. Must be alphanumeric (a-z, 0
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/7e755be78e4ca2eb.
Report an issue: GitHub.