#!/usr/bin/env python3 """Fail if docs/platform-issues/agent-tools-and-context/individual-agents-report-2026-11-01.md no longer matches the agents' tools, contracts or the workflow's wiring. Usage (from this Feature folder): python3 scripts/check_context_doc.py """ import glob import json import sys from pathlib import Path import yaml ROOT = Path(__file__).resolve().parents[1] REPORT = ROOT.parents[1] / "docs" / "platform-issues" / "agent-tools-and-context" / "individual-agents-report-2026-11-01.md" DOC = REPORT.read_text() def main() -> int: export = json.loads(next((ROOT / "workflows").glob("*.json")).read_text()) template = export.get("template") or export["workflow"]["template"] problems, read = [], set() for step in template["steps"]: read.update((step.get("inputs") or {}).get("from_steps", {}).values()) for step in template["steps"]: if step["id"] == "u1": continue agent = step["agent"].replace("_", "-") if not (ROOT / agent).exists(): continue # a built-in activity, not an agent of this pattern spec = yaml.safe_load((ROOT / agent / "agent.yaml").read_text()) for server, tools in spec.get("mcp", {}).items(): problems += [f"{agent}: {server} {tool}" for tool in tools if f"`{tool}`" not in DOC] problems += [f"{step['id']}: receives {source}" for source in step["inputs"].get("from_steps", {}).values() if f"`{source}`" not in DOC] outputs = json.loads((ROOT / agent / "schemas" / "output.json").read_text()).get("properties", {}) problems += [f"{agent}: returns {field}" for field in outputs if f"`{field}`" not in DOC] if step["id"] != "s9": lost = [f for f in outputs if f"{step['id']}.{f}" not in read] row = f"| {step['id']} | " + ", ".join(f"`{f}`" for f in lost) + " |" if row not in DOC: problems.append(f"{step['id']}: the unread fields are now {lost}") print("\n".join(problems) or "The page matches.") return 1 if problems else 0 if __name__ == "__main__": sys.exit(main())