Implementation Status
The FeatureAgent LangGraph graph is implemented at
packages/core/src/infrastructure/services/agents/feature-agent/with background execution support, validation/repair loops, and human-in-the-loop approval. The AnalyzeRepository graph is implemented atpackages/core/src/infrastructure/services/agents/analyze-repo/. The Supervisor agent (spec 093) is implemented atpackages/core/src/infrastructure/services/agents/supervisor-agent/and is gated behind thecollaborationfeature flag β see supervision.See AGENTS.md for full implementation details including the directory structure, state schema, graph flow, and node descriptions.
ARCHITECTURAL RULE: Whether using the current executor-based system or the planned LangGraph system, agent type resolution MUST always come from
getSettings().agent.typeviaAgentExecutorFactory.createExecutor(). No node, graph, use case, or worker may hardcode, guess, or default an agent type. This rule applies to ALL current and future agent implementations.
See AGENTS.md β Settings-Driven Agent Resolution for the full rule and resolution flow.
Multi-stage workflow orchestration using LangGraph StateGraphs with agent-agnostic execution. The FeatureAgent and AnalyzeRepository graphs are implemented; the multi-agent supervisor pattern is planned.
Shep implements a state-based workflow system using LangGraph for multi-stage feature development. Nodes are pure async functions that process and update state. Agent execution is delegated to an IAgentExecutor implementation (Claude Code, Gemini CLI, Aider, Cursor, etc.) resolved via settings.
+-----------------------------------------+
| FeatureWorkflow (StateGraph) |
+-----------------------------------------+
| |
| [Analyze] --> [Gather Req] --> [Plan] |
| | |
| (loop until |
| clear) |
| | |
| v |
| [Implement] --> [END] |
| |
| State: typed, immutable updates |
| Execution: IAgentExecutor (delegated) |
| |
+-----------------------------------------+
IAgentExecutor implementations resolved via settingsTyped workflow definition using LangGraphβs StateGraph:
import { Annotation } from '@langchain/langgraph';
export const FeatureState = Annotation.Root({
repoPath: Annotation<string>,
requirements: Annotation<Requirement[]>({
reducer: (prev, next) => [...prev, ...next],
default: () => [],
}),
plan: Annotation<Plan | null>,
tasks: Annotation<Task[]>({
reducer: (prev, next) => [...prev, ...next],
default: () => [],
}),
messages: Annotation<string[]>({
reducer: (prev, next) => [...prev, ...next],
default: () => [],
}),
});
export type FeatureStateType = typeof FeatureState.State;
Functions that process and update state by delegating to IAgentExecutor:
function createAnalyzeNode(executor: IAgentExecutor) {
return async (
state: AnalyzeRepositoryStateType
): Promise<Partial<AnalyzeRepositoryStateType>> => {
const prompt = buildAnalyzePrompt(state.repositoryPath);
const result = await executor.execute(prompt, {
cwd: state.repositoryPath,
});
return { analysisMarkdown: result.result };
};
}
Connections defining workflow progression:
// Direct edge: always go from A to B
graph.addEdge('analyze', 'requirements');
// Conditional edge: choose based on state
graph.addConditionalEdges('requirements', (state) => {
if (allRequirementsClear(state)) return 'plan';
return 'requirements'; // Loop back for clarification
});
Located at packages/core/src/infrastructure/services/agents/analyze-repo/. Single-node graph that generates a repository analysis document.
Located at packages/core/src/infrastructure/services/agents/feature-agent/. Full SDLC workflow graph with:
Key files:
feature-agent-graph.ts β Full SDLC graph definitionfast-feature-agent-graph.ts β Simplified fast-mode graphfeature-agent-process.service.ts β Process managementfeature-agent-worker.ts β Background worker (also emits parallel AgentQuestion of kind = blocking on every waiting_approval transition for the unified inbox)state.ts β State annotationnodes/ β Individual node implementationsLocated at packages/core/src/infrastructure/services/agents/supervisor-agent/. A
delegated guardian agent that evaluates approval gates and agent questions on
behalf of the user. Gated behind FeatureFlags.collaboration. See
supervision.md for the full design.
Key files:
supervisor-graph.ts β LangGraph workflow: ingest-event β load-policy β evaluate (LLM via IAgentExecutorProvider) β emit-decision β optional publish-messagesupervisor-agent-worker.ts β Lazy per-(appId, featureId?) background worker, mirrors the feature-agent-worker shape (own agent_runs row with agent_type='supervisor', heartbeat, checkpointing)evaluator-prompt.ts β Versioned prompt registry; the version is recorded on every SupervisorDecisionstub-supervisor-executor.ts β Deterministic stub (InMemorySupervisorAgent) used by tests so unit / integration coverage runs without an LLM callThree new domain entities β defined in tsp/agents/ β extend the agent system
with structured inter-agent messaging and a unified question/escalation
pipeline. All are gated behind the collaboration feature flag.
| Entity | Source | Storage |
|---|---|---|
AgentMessage |
tsp/agents/agent-message.tsp |
agent_messages (migration 087) |
AgentQuestion |
tsp/agents/agent-question.tsp |
agent_questions (migration 088) |
SupervisorPolicy |
tsp/agents/supervisor-policy.tsp |
supervisor_policies (migration 089) |
SupervisorDecision |
tsp/agents/supervisor-decision.tsp |
supervisor_decisions (migration 090) + mirrored to activity_log |
New ports:
| Port | Path |
|---|---|
IAgentMessageBus |
packages/core/src/application/ports/output/agents/agent-message-bus.interface.ts |
IAgentQuestionService |
packages/core/src/application/ports/output/agents/agent-question-service.interface.ts |
ISupervisorAgent |
packages/core/src/application/ports/output/agents/supervisor-agent.interface.ts |
IAgentMessageRepository |
packages/core/src/application/ports/output/repositories/agent-message-repository.interface.ts |
IAgentQuestionRepository |
packages/core/src/application/ports/output/repositories/agent-question-repository.interface.ts |
ISupervisorPolicyRepository |
packages/core/src/application/ports/output/repositories/supervisor-policy-repository.interface.ts |
ISupervisorDecisionRepository |
packages/core/src/application/ports/output/repositories/supervisor-decision-repository.interface.ts |
New use cases (under packages/core/src/application/use-cases/agents/):
SendAgentMessage, ListAgentMessages, AskAgentQuestion,
AnswerAgentQuestion, CancelAgentQuestion, ListAgentQuestions,
EscalateToUser, ConfigureSupervisor, EnableSupervisor,
DisableSupervisor, GetSupervisorPolicy, EvaluateSupervisorDecision.
ApproveAgentRunUseCase and RejectAgentRunUseCase are extended to recognise
the supervisor:<id> actor namespace and to enforce the βuser always winsβ
invariant. See supervision.md for the full sequence
diagrams.
Three new SSE event kinds β agent_message, agent_question,
supervisor_decision β are streamed through StreamAgentEventsUseCase via
dedicated compute helpers (compute-message-deltas.ts,
compute-question-deltas.ts, compute-decision-deltas.ts).
The agent system uses these key interfaces (defined in packages/core/src/application/ports/output/agents/):
| Interface | Purpose |
|---|---|
IAgentExecutor |
Execute prompts against an AI coding agent |
IAgentExecutorFactory |
Create executor instances for a given agent type |
IAgentExecutorProvider |
Resolve the current executor from settings |
IAgentRegistry |
Register and discover agent definitions |
IAgentRunner |
Run agent workflows with lifecycle management |
IAgentValidator |
Validate agent tool availability |
IFeatureAgentProcessService |
Manage feature agent background processes |
IStructuredAgentCaller |
Make structured (typed) calls to agents |
| Stage | Node | Responsibility |
|---|---|---|
| Analyze | analyzeNode |
Parse codebase structure, patterns, tech stack |
| Requirements | requirementsNode |
Gather requirements via conversation, validate clarity |
| Plan | planNode |
Decompose into tasks, create artifacts (PRD, RFC, Tech Plan) |
| Implement | implementNode |
Execute tasks respecting dependency graph |
For implementation details, see docs/development/adding-agents.md.
Update when:
Related docs: