mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-27 17:23:34 +00:00
SSE Proxy Decoupling (ADR-130): - Fix ruvbrain-sse proxy: proper MCP handshake, session creation, drain polling - Fix internal queue endpoints: session_create keeps receiver, drain returns buffered messages - Add response_queues to AppState for SSE proxy communication - Skip sparsifier for >5M edge graphs (was crashing on 16M edges) - Add SSE_DISABLED/MAX_SSE env vars for configurable connection limits - Route SSE to dedicated mcp.pi.ruv.io subdomain (Cloudflare CNAME) - Serve SSE at root / path on proxy (no /sse needed) - Update all references from pi.ruv.io/sse to mcp.pi.ruv.io - Fix Dockerfile consciousness crate build (feature/version mismatches) Claude Code CLI Source Research (ADR-133): - 19 research documents analyzing Claude Code internals (3000+ lines) - Decompiler script + RVF corpus builder for all major versions - Binary RVF containers for v0.2, v1.0, v2.0, v2.1 (300-2068 vectors each) - Call graphs, class hierarchies, state machines from minified source Integration Strategy (ADR-134): - 6-tier integration plan: WASM MCP, agents, hooks, cache, SDK, plugin - Integration guide with architecture diagrams and performance targets Co-Authored-By: claude-flow <ruv@ruv.net>
5.5 KiB
5.5 KiB
Claude Code CLI: Agent and Subagent System
Agent Architecture
Core Agent Types
| Type | Internal Reference | Purpose |
|---|---|---|
default |
Built-in | Standard Claude Code agent |
advisor |
AgentModel/AgentConfig | Advisory/review agent |
reviewer |
AgentPlugin | Code review agent |
custom |
AgentFromJson/AgentFromMarkdown | User-defined agents |
Agent Definition Sources
Agents can be defined from multiple sources:
- Built-in agents: Compiled into the binary
- JSON definitions:
.claude/agents/*.json - Markdown definitions:
.claude/agents/*.md - CLI
--agentsflag: Inline JSON --agentflag: Select a named agent- Plugin agents: From marketplace plugins
Agent Definition Schema
{
"reviewer": {
"description": "Reviews code for quality and correctness",
"prompt": "You are a code reviewer...",
"model": "claude-sonnet-4-6",
"tools": ["Read", "Glob", "Grep"],
"hooks": { ... }
}
}
Agent State Machine
AgentBaseInternalState
|
v
AgentBusy -> AgentContext -> AgentMode
|
v
AgentSubmit -> API Call -> Response Processing
|
v
AgentOutputTool -> Tool Execution -> Result
Agent Configuration
| Property | Purpose |
|---|---|
AgentConfig |
Full agent configuration |
AgentDefinition |
Agent spec (name, prompt, tools) |
AgentOptions |
Runtime options |
AgentModel |
Model override per agent |
AgentColorMap |
Visual differentiation |
AgentPrefix |
Message prefix per agent |
AgentLanguages |
Language settings |
AgentOperatingSystem |
OS-specific behavior |
AgentPolicy |
Policy constraints |
AgentMiddleware |
Processing middleware |
AgentProgressSummariesEnabled |
Progress tracking |
Agent Factory
AgentFactoryFromOptions creates agents from configuration:
- Resolves agent definitions from cache:
AgentDefinitionsCache - Applies overrides:
AgentDefinitionsWithOverrides - Sets up agent context with tools, permissions, hooks
Subagent / Task System
Task Tool
The Task tool spawns subagents for parallel work:
Main Agent
|-- Task("Review auth module") -> Subagent 1
|-- Task("Write unit tests") -> Subagent 2
|-- Task("Update docs") -> Subagent 3
Subagent Types
| Type | Purpose |
|---|---|
SubagentStart |
Subagent creation event |
SubagentStop |
Subagent completion event |
SubagentEventReader |
Read subagent events |
SubagentInternalEvents |
Internal event bus |
SubagentTranscripts |
Conversation history |
SubagentTranscriptsFromDisk |
Persisted transcripts |
SubagentStartHooks |
Hooks for subagent creation |
Task Lifecycle
TaskCreated
|
v
TaskAssignment -> TaskAgent
|
v
TaskActiveQ (queue management)
|
v
TaskAbort / TaskCompleted
|
v
TaskAbortReasonInfo (if aborted)
Task Configuration
| Config | Purpose |
|---|---|
CLAUDE_CODE_ENABLE_TASKS |
Enable task system |
CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY |
Max parallel tools |
TASK_MAX_OUTPUT_LENGTH |
Max task output |
CLAUDE_CODE_PLAN_V2_AGENT_COUNT |
Plan mode agent count |
CLAUDE_CODE_PLAN_V2_EXPLORE_AGENT_COUNT |
Exploration agents |
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS |
Experimental teams |
Agent Cost Steering
CLAUDE_CODE_AGENT_COST_STEER -- Controls cost optimization for
multi-agent scenarios, balancing between model quality and cost.
Agent List in Messages
CLAUDE_CODE_AGENT_LIST_IN_MESSAGES -- Include agent list in
conversation messages for context.
Skill System
Skills are reusable capability modules that extend Claude Code:
Skill Discovery
.claude/skills/directory.claude/commands/directory (legacy)/skillsslash command -- List available--disable-slash-commands-- Disable all skillsSLASH_COMMAND_TOOL_CHAR_BUDGET-- Character budget for skill content
Skill Definition Format
Skills are defined as Markdown files with YAML frontmatter:
---
name: deploy
description: Deploy the application
tools: [Bash, Read]
---
# Deploy Skill
Instructions for deployment workflow...
Plugin System
Plugins extend Claude Code through marketplace:
| Component | Purpose |
|---|---|
PluginAgent |
Agent provided by plugin |
PluginCache |
Plugin artifact cache |
PluginConfiguration |
Plugin settings |
PluginControl |
Plugin lifecycle management |
PluginAutoupdate |
Auto-update mechanism |
PluginEditableScopes |
Configurable scopes |
PluginAffectingSettingsSnapshot |
Settings impact tracking |
Marketplace Integration
| Component | Purpose |
|---|---|
MarketplaceFromGcs |
GCS-hosted marketplace |
MarketplaceIsPrivate |
Private marketplace flag |
MarketplaceAutoInstalled |
Auto-installed plugins |
MarketplaceModelEndpoint |
Model endpoint plugins |
MarketplaceModelEndpoints |
Multiple endpoints |
MarketplaceDependenciesOn |
Dependency tracking |
Plugin configuration:
CLAUDE_CODE_PLUGIN_CACHE_DIR-- Cache locationCLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS-- Git operation timeoutCLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE-- ResilienceCLAUDE_CODE_PLUGIN_SEED_DIR-- Seed directoryCLAUDE_CODE_PLUGIN_USE_ZIP_CACHE-- Zip cachingFORCE_AUTOUPDATE_PLUGINS-- Force updatesCLAUDE_CODE_SYNC_PLUGIN_INSTALL-- Synchronous installCLAUDE_CODE_USE_COWORK_PLUGINS-- Cowork plugin support