def test_agent_config_from_toml_section_with_invalid_base():
    """Test that AgentConfig.from_toml_section handles invalid base configurations gracefully."""
    from openhands.core.config.agent_config import AgentConfig

    # Test with invalid base config but valid custom configs
    agent_section = {
        'invalid_field': 'some_value',  # This should be ignored in base config
        'enable_jupyter': 'not_a_bool',  # This should cause validation error
        'CustomAgent': {
            'enable_browsing': False,
            'enable_jupyter': True,
        },
    }

    # Parse the section
    result = AgentConfig.from_toml_section(agent_section)

    # Verify a default base config was created despite the invalid fields
    assert 'agent' in result
    assert result['agent'].enable_browsing is True  # Default value
    assert result['agent'].enable_jupyter is True  # Default value

    # Verify custom config was still processed correctly
    assert 'CustomAgent' in result
    assert result['CustomAgent'].enable_browsing is False
    assert result['CustomAgent'].enable_jupyter is True
Test that AgentConfig.from_toml_section handles invalid base configurations gracefully.
tests/unit/test_config.py