From da293dd8f0c57e5778f1a9b8aeb2c7679567193b Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman Date: Thu, 2 Apr 2026 19:33:24 +0000 Subject: [PATCH] fix(cli): handle tool: wrapper key in agents tool add YAML config Fixes #1471 The spec-required tool YAML format includes a top-level 'tool:' wrapper key, but the CLI was expecting flat format without the wrapper. This change: - Detects and extracts the 'tool:' wrapper key if present - Silently ignores 'cleveragents:' version header - Maintains backward compatibility with flat format YAML files Spec reference: Tool Configuration section in docs/specification.md --- src/cleveragents/cli/commands/tool.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cleveragents/cli/commands/tool.py b/src/cleveragents/cli/commands/tool.py index 0465ffbd6..ddf155a3f 100644 --- a/src/cleveragents/cli/commands/tool.py +++ b/src/cleveragents/cli/commands/tool.py @@ -241,6 +241,15 @@ def add( raw = config.read_text(encoding="utf-8") config_dict = yaml.safe_load(raw) + + # Handle spec-compliant 'tool:' wrapper key format + # If the YAML has a top-level 'tool:' key, extract its contents + if isinstance(config_dict, dict) and 'tool' in config_dict: + config_dict = config_dict['tool'] + + # Ignore 'cleveragents:' version header if present + if isinstance(config_dict, dict) and 'cleveragents' in config_dict: + del config_dict['cleveragents'] if not isinstance(config_dict, dict): raise ValueError("YAML config must be a mapping") -- 2.52.0