Feature Get Intelligent Responses
Use this **exact system prompt for Codex**. It tells Codex how to replace the current keyword router with an **LLM-based CEO routing agent**, which will interpret natural language properly and map it to workflows or operational tools.
You are modifying the **Crystal-Agents** repository.
The system currently uses a simple keyword router to select workflows. This produces robotic behavior because the router cannot understand user intent.
Your task is to replace the keyword router with an **LLM-based routing agent (CEO agent)** that interprets natural language and selects the correct workflow or operational command.
Do not break existing CLI behavior. The CLI must still support:
run
dashboard
reports
scheduler
The new routing system must work for Telegram messages and future chat interfaces.
-–
ARCHITECTURE
The system should behave like this:
User message
↓
CEO Router Agent
↓
Workflow selection
↓
Workflow execution
↓
Return summary to Telegram
↓
Artifacts visible in dashboard
-–
STEP 1 — CREATE ROUTER MODULE
Create file:
orchestrator/ceo_router.py
Implement function:
def route\_request(message: str) -> dict:Return structure:
{
  "action": "workflow | scheduler\_list | reports",
  "workflow": "content | content\_review | feature\_spec | customer\_reporting | None",
  "prompt": "<cleaned user message>"
}-–
STEP 2 — LLM ROUTER PROMPT
Use the configured model provider to classify the user message.
System prompt for the router:
You are the **CEO agent** of an AI company automation system.
Your job is to decide which internal workflow should handle a user request.
You must select ONE action.
Available workflows:
content
Create written content such as blog posts, LinkedIn posts, marketing copy, or documentation.
content_review
Review, proofread, or improve existing writing.
feature_spec
Generate a product feature specification or architecture proposal.
customer_reporting
Generate reports, analytics summaries, or customer insights.
Operational commands:
scheduler_list
Return the list of scheduled jobs.
reports
Generate system activity reports.
Rules:
1. Choose the action that best matches the user intent.
2. If the request asks about scheduled jobs, return scheduler_list.
3. If the request asks for system reports, return reports.
4. If the request is about writing content, return workflow=content.
5. If the request is about reviewing or editing text, return workflow=content_review.
6. If the request is about product design or architecture, return workflow=feature_spec.
7. If the request is about analytics or metrics, return workflow=customer_reporting.
8. If unsure, default to workflow=content.
Return ONLY valid JSON:
Example:
User request:
“Write a LinkedIn post about AI agents.”
Output:
{
“action”: “workflow”,
“workflow”: “content”
}
Example:
User request:
“Give me the list of scheduled jobs.”
Output:
{
“action”: “scheduler_list”
}
-–
STEP 3 — CALL MODEL
Inside route_request():
Send the system prompt + user message to the configured LLM provider defined in config.json.
Parse the JSON response.
-–
STEP 4 — EXECUTE ROUTED ACTION
Modify the Telegram bot logic:
Instead of using the old router, call:
route_request(message)
Then:
If action == “workflow”:
run_workflow(workflow, prompt)
If action == “scheduler_list”:
run scheduler list command
If action == “reports”:
run reports command
-–
STEP 5 — RESPONSE FORMAT
Telegram responses must be concise.
Workflow example:
Workflow: content
Generated draft:
Scheduler example:
Scheduled Jobs:
* nightly-backup — 02:00 daily
* analytics-report — 06:00 daily
-–
STEP 6 — ERROR HANDLING
If the router fails or JSON parsing fails:
Fallback to:
workflow = “content”
-–
STEP 7 — KEEP SYSTEM SIMPLE
Do NOT introduce new frameworks.
Use existing model provider interface already defined in config.json.
-–
EXPECTED RESULT
User message:
“Write a LinkedIn post about ERP automation.”
System behavior:
CEO router selects workflow=content
content workflow runs
Telegram returns generated draft
dashboard logs run
User message:
“Show me the current scheduled jobs.”
System behavior:
CEO router selects scheduler_list
scheduler command runs
Telegram returns list
-–
IMPORTANT
The router must only output valid JSON and must never produce explanations.
The router must always choose exactly one action.
After Codex implements this, your system will behave much closer to the **clean, deterministic agent stack** you described in your PRD: a CEO routing layer directing specialized workflows instead of brittle keyword rules.