feat(036): wire RunTracker into agent — scenario intent → durable run creation
This commit is contained in:
@@ -544,6 +544,7 @@ async def agent_handler( # noqa: C901 — intentionally complex C4 orchestratio
|
||||
agent_tools,
|
||||
user_role,
|
||||
uicontext.get("objectType") if uicontext else None,
|
||||
intent=uicontext.get("intent") if uicontext else None,
|
||||
)
|
||||
yield json.dumps(
|
||||
{
|
||||
@@ -556,6 +557,29 @@ async def agent_handler( # noqa: C901 — intentionally complex C4 orchestratio
|
||||
},
|
||||
}
|
||||
)
|
||||
# ── 036: Create durable run for scenario intent ──────
|
||||
scenario_mode = uicontext.get("intent") == "build_dashboard_test_scenario"
|
||||
run_tracker = None
|
||||
if scenario_mode and uicontext:
|
||||
try:
|
||||
from ss_tools.agent._run_tracker import RunTracker
|
||||
|
||||
backend_url = os.environ.get("BACKEND_URL", "http://localhost:8000")
|
||||
tracker = RunTracker(backend_url, user_jwt_str)
|
||||
run_id = await tracker.create(uicontext, conversation_id=conv_id)
|
||||
yield json.dumps(
|
||||
{
|
||||
"content": "",
|
||||
"metadata": {
|
||||
"type": "agent_run_started",
|
||||
"agent_run_id": run_id,
|
||||
"sequence": 1,
|
||||
},
|
||||
}
|
||||
)
|
||||
run_tracker = tracker
|
||||
except Exception as exc:
|
||||
logger.explore("Failed to create agent run — proceeding without durability", extra={"error": str(exc)})
|
||||
# Auto-inject environment_id into tool calls when LLM omits it
|
||||
agent_tools = _inject_env_id_into_tools(agent_tools, env_id)
|
||||
agent = await create_agent(agent_tools, env_id)
|
||||
|
||||
Reference in New Issue
Block a user