Skip to content

fix(delegate): guard _load_config() against delegation: null in config.yaml#16345

Closed
ideathinklab01-source wants to merge 1 commit into
NousResearch:mainfrom
ideathinklab01-source:fix/delegate-null-config
Closed

fix(delegate): guard _load_config() against delegation: null in config.yaml#16345
ideathinklab01-source wants to merge 1 commit into
NousResearch:mainfrom
ideathinklab01-source:fix/delegate-null-config

Conversation

@ideathinklab01-source
Copy link
Copy Markdown
Contributor

Problem

delegation: null in config.yaml causes NoneType object has no attribute 'get' on every API call that triggers the delegation path:

File "run_agent.py", line 11938, in run_conversation
    assistant_message.tool_calls = self._cap_delegate_task_calls(
File "run_agent.py", line 4733, in _cap_delegate_task_calls
    max_children = _get_max_concurrent_children()
File "tools/delegate_tool.py", line 335, in _get_max_concurrent_children
    val = cfg.get("max_concurrent_children")
          ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

Root Cause

_load_config() uses dict.get("delegation", {}) which returns the default {} only when the key is missing. When delegation: null is present in YAML, the key exists with value None, so .get() returns None — and downstream cfg.get(...) crashes.

This is the same class of bug as the one fixed in fd9b692 (fix(tui): tolerate null top-level sections in config.yaml), which guarded 21 sites in tui_gateway/server.py but missed delegate_tool.py.

Related issues: #7215, #7346

Fix

Use dict.get(key) or {} instead of dict.get(key, {}) in _load_config(), consistent with the pattern from fd9b692:

# Before
cfg = CLI_CONFIG.get("delegation", {})
return full.get("delegation", {})

# After
cfg = CLI_CONFIG.get("delegation") or {}
return full.get("delegation") or {}

Testing

  • Verified that delegation: null no longer crashes; _get_max_concurrent_children() correctly falls back to the default (3)
  • Verified that delegation: {} and delegation: {max_concurrent_children: 5} still work as expected

…g.yaml

YAML parses `delegation: null` as Python None. `dict.get(key, {})`
only uses the default when the key is *missing*, not when it exists with
a None value, so `cfg.get("max_concurrent_children")` crashes with
`'NoneType' object has no attribute 'get'`.

Same pattern as fd9b692 (fix(tui): tolerate null top-level sections).
Use `dict.get(key) or {}` to handle both missing and None-valued keys.

Closes: delegation null config crash (same class as NousResearch#7215, NousResearch#7346)
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround tool/delegate Subagent delegation area/config Config system, migrations, profiles labels Apr 27, 2026
@teknium1
Copy link
Copy Markdown
Contributor

teknium1 commented May 4, 2026

Salvaged via #19662 onto current main - your commit authorship was preserved. Thanks!

@teknium1 teknium1 closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles P1 High — major feature broken, no workaround tool/delegate Subagent delegation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants