Skip to main content

suggest_routes()

suggest_routes() analyzes a question with an LLM and returns several differentiated analysis paths (routes). Each route is an ordered list of steps that map cleanly to agents in a multi-agent system: template name, role, what each step receives, and what it produces.

Use it when you want users (or your app) to choose an analytical angle — diagnostic vs risk vs trend vs strategic — instead of a single best pipeline.

from mycontext.intelligence import suggest_routes

result = suggest_routes(
"What are the main drivers of churn in Q3 for our B2B SaaS?",
max_routes=4,
provider="openai",
model="gpt-4o",
)

print(result.question_decomposition)
print(result.recommendation)

for route in result.routes:
print(f"\n{route.label} ({route.dimension})")
print(f" Final output: {route.final_output}")
for step in route.steps:
print(f" [{step.template}] {step.agent_role}")
print(f" ← {step.receives}")
print(f" → {step.produces}")

Function signature

def suggest_routes(
question: str,
max_routes: int = 4,
include_enterprise: bool = True,
provider: str = "openai",
temperature: float = 0,
model: str | None = None,
**kwargs,
) -> RouteAnalysis
ParameterDescription
questionUser question or task
max_routesHow many alternative routes to generate (clamped 2–6)
include_enterpriseWhether enterprise-only templates may appear
provider / model / temperaturePassed to the LLM (same pattern as other intelligence APIs)
**kwargse.g. max_tokens, top_p when using the instructor path

Return type: RouteAnalysis

FieldTypeDescription
question_decompositionstrDimensions, stakeholders, scope
routeslist[AnalysisRoute]Ordered by relevance
recommendationstrWhich route to start with and why

AnalysisRoute

FieldDescription
labelHuman-readable name (e.g. “Diagnostic deep-dive”)
dimensione.g. diagnostic, predictive, strategic, risk
rationaleWhy this angle matters for this question
stepsOrdered RouteStep list
final_outputDeliverable description for the full pipeline

RouteStep (one agent)

FieldDescription
templateCatalog template name (snake_case)
agent_rolePlain-language role
receivesuser_input or reference to prior step output
producesWhat this step outputs
paramsSuggested build_context kwargs (may be empty)

Relationship to other APIs

APIRole
suggest_routes()Multiple routes, agent-level detail — planning for orchestration
suggest_patterns()Single ranked list; llm / hybrid modes may use suggest_routes internally
build_workflow_chain()Deprecated — use suggest_routes() for new code
TemplateIntegratorAgentFuse selected templates into one context for a single LLM call

Requirements

  • Requires API keys / provider setup like other LLM-backed intelligence functions.
  • Uses structured output (instructor when available, otherwise JSON parse + validation).

See also