Compare commits

...

1 Commits

Author SHA1 Message Date
5dd8622539 Implement Fallback Portfolio wiring in tasks.py 2026-04-06 17:56:14 +00:00

View File

@@ -2126,3 +2126,27 @@ def cross_review_prs():
continue
return {"reviews": len(results), "details": results}
def get_model_for_task(task_class, agent_name=None):
"""Implement the Fallback Portfolio doctrine (docs/fallback-portfolios.md).
Reads fallback-portfolios.yaml and returns the primary model for the given task class.
If primary fails, the agent should call this again with an incremented 'attempt' (not implemented here).
"""
import yaml
portfolio_path = Path(__file__).parent / "fallback-portfolios.yaml"
if not portfolio_path.exists():
return "gemini-1.5-flash" # Default fallback
with open(portfolio_path, "r") as f:
portfolios = yaml.safe_load(f)
# 1. Check agent-specific portfolio
if agent_name and agent_name in portfolios.get("agents", {}):
return portfolios["agents"][agent_name]["primary"]["model"]
# 2. Check task-class portfolio
if task_class in portfolios.get("role_classes", {}):
return portfolios["role_classes"][task_class]["primary"]["model"]
return "gemini-1.5-flash"