-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Jira: RHOAIENG-51904
Problem
When a user selects a workflow (e.g., CLAUDE.md Generator), the welcome/greeting message takes 20+ seconds to appear in the chat UI. This is because the startupPrompt from ambient.json is sent through the full LLM round-trip:
runner → backend API → runner /agui/run → Claude SDK → MCP server startup (~14s) → Anthropic API (~3s) → AG-UI events → frontend
The greeting is a static message defined in the workflow's ambient.json. It doesn't need LLM processing.
Root Cause
_trigger_workflow_greeting in ambient_runner/endpoints/workflow.py sends the startupPrompt as a hidden user message to /agui/run, which spins up a full Claude session (including connecting all MCP servers) just to echo back a predetermined message.
Additional bug found during investigation
_trigger_workflow_greeting used path.split("/")[-1] to derive the workflow directory, while clone_workflow_at_runtime uses the repo name (git_url.split("/")[-1].removesuffix(".git")). These don't match, causing the greeting to silently fail — it can't find ambient.json and skips the greeting entirely.
Proposed Solution
-
Frontend renders the greeting directly: When a workflow is selected, the frontend reads the
startupPromptfrom the workflow metadata endpoint (/workflow/metadata) and renders it as a system/assistant message in the chat UI immediately — no Claude round-trip needed. -
Claude is only invoked when the user sends a real message (e.g., types "1" to select PROJECT/REPO).
-
Remove
_trigger_workflow_greetingfrom the runner or keep it as a fallback only.
Impact
- Every workflow activation has a 20+ second delay before the user sees anything
- Most of that time is MCP server cold starts (google-workspace downloads 80 Python packages via uv on every session start)
- The greeting itself is static text that could render in <100ms
Time Breakdown (from debug logs)
| Phase | Duration |
|---|---|
| mcp-atlassian connect | ~1s |
| webfetch connect (downloads cpython + deps via uv) | ~4s |
| google-workspace connect (downloads 80 packages via uv) | ~9s |
| Anthropic API call | ~3s |
| Total | ~20s |
Steps to Reproduce
- Create a session in the UI
- Wait for MCP servers to show as connected
- Click a workflow (e.g., CLAUDE.md Generator)
- Observe 20+ second delay before greeting appears