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 first

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Remove request-body keys from constructor kwargs; only client options (api_key, base_url, timeout, ...) and model/create params belong there.
  2. Pass messages/stream controls to client.create(...) at call time, not to the constructor.
  3. 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

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


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/7e755be78e4ca2eb. Report an issue: GitHub.