From 25f0d91c18b3d3af7c19d18157051ddea366ffe8 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 22 Jun 2026 19:54:21 +0000 Subject: [PATCH] fix: load_for_agent always returns single-agent manifest Filter to exactly one agent and one bottle in both the lazy (md-dirs) and eager (from_json_obj) paths so the returned manifest invariant holds regardless of how the manifest was constructed. --- bot_bottle/manifest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bot_bottle/manifest.py b/bot_bottle/manifest.py index 7d4e622..6fc581e 100644 --- a/bot_bottle/manifest.py +++ b/bot_bottle/manifest.py @@ -324,13 +324,20 @@ class Manifest: invalid. Must be called on a names-only manifest (from resolve). Backends call this at preflight to upgrade the spec's manifest.""" if self.home_md is None: - # Eager manifest (from_json_obj): already fully loaded; just validate name. + # Eager manifest (from_json_obj): data already parsed; filter to + # the one requested agent and its bottle so the returned manifest + # always contains exactly one agent and one bottle regardless of path. if agent_name not in self.agents: available = ", ".join(sorted(self.agents.keys())) or "(none)" raise ManifestError( f"agent '{agent_name}' not defined. Available: {available}" ) - return self + agent = self.agents[agent_name] + bottle_name = agent.bottle + return Manifest( + bottles={bottle_name: self.bottles[bottle_name]}, + agents={agent_name: agent}, + ) from .manifest_loader import load_bottle_chain_from_dir, scan_agent_names from .manifest_schema import validate_agent_frontmatter_keys from .yaml_subset import YamlSubsetError, parse_frontmatter