Prompt Details
Model
Chat - (gpt-6-luna)
Token size
891
Example input
[EXISTING_AGENT_ARCHITECTURE]: Customer Support Agent, Intent Classifier Agent, Knowledge Agent, Refund Agent, Human Escalation Agent, Central Orchestrator.
[AGENT_ROLES_RESPONSIBILITIES_WORKFLOWS]: Classifier identifies intent via LLM. Knowledge agent searches FAQ vector store. Refund agent executes refund API calls. Support agent re-phrases outputs in polite tone. Escalation pushes to human queue.
[ORCHESTRATION_COMMUNICATION_DEPENDENCIES]: Sequential hub-and-spoke via Central Orchestrator. Every node reports back to Orchestrator before next node triggers.
[STATE_MEMORY_AND_DATA_FLOW]: Global shared Redis instance containing unencrypted chat history, user auth token, intent cache, and tool logs.
[REFACTORING_GOALS_AND_CONSTRAINTS]: Reduce P95 latency below 2s. Eliminate redundant handoffs. Strict PCI-DSS compliance isolation for financial refunds. Do not rebuild UI frontend.
Example output
# ποΈ ENTERPRISE ARCHITECTURAL AUDIT & REFACTORING BLUEPRINT
### PHASE 1: CURRENT STATE RECONSTRUCTION & CALL GRAPH
* Sequence Path: User β Orchestrator β Classifier β Orchestrator β Specialist β Orchestrator β Support Agent β User.
* Inherent Flaws:
- 4 roundtrip LLM context switches per single question.
- Global Redis store grants every agent unbounded read/write access.
- Refund API exceptions bubble up and terminate conversational context.
* Unknowns: Deterministic SLA limits, Redis persistence configuration, PCI-DSS boundaries.
### PHASE 2: BOUNDARY ANALYSIS & AGENT NECESSITY AUDIT
| Agent | Responsibility | Necessity | Verdict |
|---|---|---|---|
| Intent Classifier | Parse request intent | Low (2/5) | Replace with Deterministic Semantic Router / Regex |
| Knowledge Agent | FAQ retrieval | High (5/5) | Retain (optimize with Vector DB tool-call) |
| Refund Agent | Process monetary returns | Critical (5/5) | Retain (Isolate under strict authorization boundary) |
| Customer Support Agent| Format output response | Low (2/5) | Consolidate into streaming specialist template |
| Orchestrator | Traffic routing | Medium (3/5) | Refactor into Async StateGraph |
### PHASE 3: STATE RESTRUCTURING & DATA OWNERSHIP
* Ephemeral Context: Agent scratchpad memory (local dictionary, wiped post-turn).
* Session State: Read-only for Knowledge Agent; Write-restricted to Orchestrator.
* Transactional State: Controlled strictly by Refund Service via idempotent idempotency_key: UUIDv4.
### PHASE 4: LATENCY & TOKEN OVERHEAD OPTIMIZATION
* Baseline: 4 LLM calls ~ 7.8s average latency, 3,400 tokens/session.
* Refactored: Fast heuristic router (50ms) + 1 LLM specialist invocation (1.2s) β Target Latency: <1.5s (80% latency cut, 62% token cost reduction).
### PHASE 5: RESILIENCE & FAILURE ISOLATION
* Refund execution isolated via Circuit Breaker (3 failures / 30s open threshold).
* Fallback: If Refund API fails, return partial resolution payload + dispatch asynchronous webhook to Human Escalation queue.
### PHASE 6: REFACTORED TARGET ARCHITECTURE
User Request
β
[Deterministic Fast Router] (Regex + Embeddings)
ββββββββββββββββββββββββ¬βββββββββββββββββββββββ
βΌ βΌ βΌ
[Knowledge Node] [Refund Node] [Escalation Node]
(Vector Search) (Auth Guard + API) (Slack/Zendesk)
β β β
ββββββββββββββββββββββββ΄βββββββββββββββββββββββ
β
[Streaming Finalizer Engine] βββΊ User
### PHASE 7: IMPLEMENTATION SKELETON
from pydantic import BaseModel, Field
from typing import Optional, Literal
class SessionState(BaseModel):
session_id: str
user_id: str
intent: Optional[Literal["faq", "refund", "escalate"]] = None
refund_status: Optional[str] = None
response_payload: Optional[str] = None
async def route_request(query: str, state: SessionState):
if "refund" in query.lower():
state.intent = "refund"
return await execute_refund_node(state)
state.intent = "faq"
return await execute_knowledge_node(state)
### PHASE 8: ZERO-DOWNTIME MIGRATION ROADMAP
* Stage 1: Add OpenTelemetry Distributed Tracing (Span IDs across nodes).
* Stage 2: Canary deploy deterministic routing for 10% of high-confidence traffic.
* Stage 3: Lock down Redis ACLs to enforce read-only role privileges.
By purchasing this prompt, you agree to our terms of service
GPT-6-LUNA
Enterprise Multi-Agent Architecture Refactoring & Cost Optimizer
...more
Added 1 week ago
