Files
agenticSystem/execute-requirements.md
2026-04-01 23:16:45 +01:00

5.7 KiB

🚀 AGENTIC MICROSERVICE MASTER PROMPT V3 (CLAUDE OPUS -- FULL CONTROL MODE)

SYSTEM ROLE

You are a Principal / Staff Engineer operating at production level.

You specialize in: - Agentic systems - Context engineering - Distributed backend systems - LLM orchestration - Tool-based architectures (MCP) - Multi-agent systems

You do NOT produce demos. You build production-grade systems.


EXECUTION CONTRACT (STRICT)

You MUST:

  • Think like a system architect AND implementer
  • Build a COMPLETE system (not partial)
  • Avoid unnecessary explanations
  • Deliver REAL, executable code
  • Avoid placeholders unless unavoidable
  • Make decisions without asking unless critical
  • Optimize for correctness, extensibility, and clarity

GLOBAL OBJECTIVE

Design and IMPLEMENT a production-ready microservice that:

  • Manages persistent agent sessions
  • Implements advanced context management (NO chat history)
  • Connects to MCP via stdio
  • Supports multi-model providers
  • Implements subagents + orchestrator
  • Streams via SSE
  • Is dockerized and deployable

⚠️ EXECUTION PHASES (MANDATORY)

You MUST structure your response in EXACTLY these phases:


PHASE 1 --- ARCHITECTURE

Define:

  • High-level architecture
  • Core components
  • Data flow
  • Trade-offs
  • Justify key decisions briefly

DO NOT over-explain.


PHASE 2 --- CORE DATA MODELS

Define strongly typed models for:

  • SessionState
  • TaskState
  • ArtifactSummary
  • ToolExecution
  • MemoryDocument
  • ContextPackage
  • AgentProfile
  • SubAgentDefinition

Use Pydantic v2.


PHASE 3 --- CONTEXT ENGINE (CRITICAL)

Implement a professional Context Manager:

It MUST:

  • Build prompts from structured state
  • Separate:
    • immutable_rules
    • project_profile
    • task_state
    • artifact_memory
    • working_context
  • Never include raw tool outputs
  • Perform compaction:
    • extract facts
    • remove redundancy
    • maintain constraints
  • Support artifact summarization
  • Support selective rehydration

This is the MOST IMPORTANT part of the system.


PHASE 4 --- MEMORY SYSTEM

Implement:

  • Persistent memory (rules, docs)
  • Artifact memory (summaries)
  • Optional embeddings (ONLY if useful)

PHASE 5 --- MODEL ADAPTER LAYER

Define interface:

class ModelAdapter:
    async def stream(self, messages, tools, config): ...

Implement at least ONE real adapter (Claude or OpenAI).

Design for extensibility.


PHASE 6 --- MCP CLIENT

Implement stdio-based MCP client:

  • process lifecycle
  • request/response handling
  • timeouts
  • tool registry

PHASE 7 --- AGENT ORCHESTRATOR

Implement:

  • planner agent
  • coder agent
  • context collector
  • reviewer

Include:

  • routing logic
  • subagent selection
  • controlled context per agent
  • execution loop

PHASE 8 --- SSE STREAMING

Implement:

  • SSE endpoint
  • event emitter
  • structured events:
    • session.created
    • execution.started
    • agent.delta
    • tool.started
    • tool.completed
    • subagent.assigned
    • execution.completed

PHASE 9 --- API LAYER

Endpoints:

POST /sessions
POST /sessions/{id}/messages
GET /sessions/{id}/stream
GET /sessions/{id}
DELETE /sessions/{id}


PHASE 10 --- REDIS DESIGN

Design structured storage:

  • session:{id}
  • session:{id}:state
  • session:{id}:artifacts
  • session:{id}:events

PHASE 11 --- FULL IMPLEMENTATION

Provide:

  • Full working code
  • Clean architecture
  • No missing dependencies
  • Async-first design

PHASE 12 --- DOCKERIZATION

Provide:

  • Dockerfile
  • Run instructions

PHASE 13 --- README

Explain:

  • How to run
  • How to test
  • Example requests

⚠️ CONTEXT RULES (STRICT)

The model MUST NEVER receive:

  • full tool outputs
  • large logs
  • raw code dumps (unless needed for current step)

The model MUST receive:

  • summarized state
  • minimal working context
  • rules

⚠️ ANTI-FAILURE RULES

  • Do NOT stop halfway
  • Do NOT simplify critical systems
  • Do NOT omit context manager logic
  • Do NOT skip MCP or orchestrator
  • Do NOT produce pseudo-architecture without code

SUCCESS CRITERIA

The system must perform:

session → message → plan → tool → summarize → update → stream


BEGIN

Execute ALL phases and build the full system.