step 5 complete: execution plan builder, template registry, and LRU plan cache
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ from langchain_openai import ChatOpenAI
|
||||
from app.config.settings import settings
|
||||
from app.core.agent_registry import AgentRegistry
|
||||
from app.core.agent_registry import registry as _default_registry
|
||||
from app.schemas import ChatRequest, ChatResponse, ExecutionPlan, PlanStep
|
||||
from app.schemas import ChatRequest, ChatResponse, ExecutionPlan
|
||||
|
||||
_FALLBACK_AGENT = "task_agent"
|
||||
|
||||
@@ -99,22 +99,21 @@ async def route_pipeline(
|
||||
|
||||
|
||||
def _build_plan(agent_name: str, message: str) -> ExecutionPlan:
|
||||
"""Build a minimal ``ExecutionPlan`` for the resolved agent.
|
||||
"""Build an ``ExecutionPlan`` for the resolved agent.
|
||||
|
||||
The full ``ExecutionPlanBuilder`` (with template registry and caching) is
|
||||
implemented in Step 5. This function produces the single-step baseline
|
||||
plan that the orchestrator returns in ``'plan'`` mode.
|
||||
Uses ``ExecutionPlanBuilder`` with the server-side template registry.
|
||||
If a default template exists for the agent, an LLM step is emitted;
|
||||
otherwise a plain ``handle`` action step is used.
|
||||
"""
|
||||
return ExecutionPlan(
|
||||
agent=agent_name,
|
||||
steps=[
|
||||
PlanStep(
|
||||
action="handle",
|
||||
prompt_template=f"tpl_{agent_name}_default",
|
||||
variables={"message": message},
|
||||
)
|
||||
],
|
||||
)
|
||||
from app.core.execution_plan import ExecutionPlanBuilder, template_registry
|
||||
|
||||
template_id = f"tpl_{agent_name}_default"
|
||||
builder = ExecutionPlanBuilder(agent_name)
|
||||
if template_registry.has(template_id):
|
||||
builder.add_llm_step(template_id, {"message": message})
|
||||
else:
|
||||
builder.add_step("handle", {"message": message})
|
||||
return builder.build()
|
||||
|
||||
|
||||
async def orchestrate(
|
||||
|
||||
Reference in New Issue
Block a user