fix(captain/mcp): save_agent_spec — passa categorias já serializadas pra build_skill_md
Bug: build_skill_md recebia AR Captain::PricingCategory objects mas o format_pricing_block fazia cat['amounts'] (índice de hash). AR respondem a .amounts, não a ['amounts'] → nil → undefined method 'group_by' for nil. Fix: serializa primeiro, reusa em ambos os lugares. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5ef59ecc12
commit
828e2e6af3
@ -99,6 +99,7 @@ class Captain::Mcp::Tools::SaveAgentSpecTool < Captain::Mcp::Tools::BaseTool
|
|||||||
return [{}, errors] if errors.any?
|
return [{}, errors] if errors.any?
|
||||||
|
|
||||||
name = spec['name'].presence || slug.tr('_', ' ').split.map(&:capitalize).join(' ')
|
name = spec['name'].presence || slug.tr('_', ' ').split.map(&:capitalize).join(' ')
|
||||||
|
serialized_categories = pricing_categories.map { |c| serialize_category(c) }
|
||||||
|
|
||||||
{
|
{
|
||||||
'slug' => slug,
|
'slug' => slug,
|
||||||
@ -112,8 +113,8 @@ class Captain::Mcp::Tools::SaveAgentSpecTool < Captain::Mcp::Tools::BaseTool
|
|||||||
'skill_name' => "#{slug.tr('_', '-')}-reservas",
|
'skill_name' => "#{slug.tr('_', '-')}-reservas",
|
||||||
'humanization' => spec['humanization'] || default_humanization,
|
'humanization' => spec['humanization'] || default_humanization,
|
||||||
'soul_md' => build_soul_md(name, brand, spec),
|
'soul_md' => build_soul_md(name, brand, spec),
|
||||||
'skill_md' => build_skill_md(name, brand, spec, pricing_categories),
|
'skill_md' => build_skill_md(name, brand, spec, serialized_categories),
|
||||||
'categories' => pricing_categories.map { |c| serialize_category(c) },
|
'categories' => serialized_categories,
|
||||||
'saved_at' => Time.current.iso8601,
|
'saved_at' => Time.current.iso8601,
|
||||||
'saved_by_tool' => 'mcp_save_agent_spec'
|
'saved_by_tool' => 'mcp_save_agent_spec'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user