microsoft/autogen · error · ValueError

Required create args are missing: {required_create_args - cr

Error message

Required create args are missing: {required_create_args - create_args_keys}

What it means

AnthropicChatCompletionClient splits its kwargs into AsyncAnthropic client params and message-create params. _create_args_from_config requires that every entry of required_create_args (in practice 'model') survives the filter into create_args; if none matches (e.g. the key is misspelled or nested), it raises ValueError naming the missing set. This is the config-reconstruction path (e.g. component deserialization) catching an incomplete config.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/anthropic/_anthropic_client.py:112

}
disallowed_create_args = {"stream", "messages"}
required_create_args: Set[str] = {"model"}

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"

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Ensure the top-level kwargs include model='claude-...' when constructing AnthropicChatCompletionClient.
  2. Check spelling: it must be 'model', not 'model_name' or 'deployment'.
  3. When deserializing from component config, validate the dumped dict contains 'model' before calling cls(**copied_config).

Example fix

# before
client = AnthropicChatCompletionClient(model_name='claude-sonnet-4-5', api_key=...)  # ValueError

# after
client = AnthropicChatCompletionClient(model='claude-sonnet-4-5', api_key=...)
Defensive patterns

Strategy: validation

Validate before calling

def make_anthropic_client(cfg: dict):
    if not cfg.get('model'):
        raise ValueError('anthropic config missing required key "model"')
    return AnthropicChatCompletionClient(**cfg)

Prevention

When it happens

Trigger: AnthropicChatCompletionClient(**config) where config lacks 'model' or has it misspelled ('model_name', 'modelId'); building the client from ComponentConfig where model was dropped by exclude_none or a schema mismatch; empty kwargs dict.

Common situations: Loading client config from YAML/JSON where the model key name differs; copy-pasting config between OpenAI-style clients (model_name) and Anthropic; component_config round-trips that lose the model field after upgrades.

Related errors


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