Agents Overview¶
The Mistaber encoding plugin includes a specialized agent that orchestrates the complete encoding pipeline with human supervision at every checkpoint.
What Are Agents?¶
In Claude Code, agents are autonomous subprocesses that handle complex, multi-step tasks. Unlike commands (user-initiated) or skills (knowledge resources), agents can:
- Operate Autonomously: Execute sequences of operations
- Manage State: Track progress across multiple phases
- Request Input: Pause for human decisions at checkpoints
- Coordinate Tools: Invoke multiple tools and skills as needed
The Encoding Orchestrator¶
The plugin provides one primary agent: the encoding-orchestrator.
| Attribute | Value |
|---|---|
| Name | encoding-orchestrator |
| Color | cyan |
| Model | inherit (uses session model) |
| Purpose | Orchestrate complete encoding pipeline |
Agent Architecture¶
graph TB
subgraph "Encoding Orchestrator"
O[Orchestrator Agent]
subgraph "Skills"
S1[corpus-prep]
S2[hll-encode]
S3[validate]
S4[review]
S5[commit]
end
subgraph "Hooks"
H1[session-init]
H2[phase-gate]
H3[encoding-guard]
H4[sefaria-logger]
H5[validation-handler]
H6[checkpoint-enforcement]
H7[git-commit-guard]
end
subgraph "MCP"
M[Sefaria MCP]
end
end
O --> S1
O --> S2
O --> S3
O --> S4
O --> S5
H1 -.-> O
H2 -.-> O
H3 -.-> O
H4 -.-> M
H5 -.-> O
H6 -.-> O
H7 -.-> O
Agent vs. Skills vs. Hooks¶
| Component | Triggered By | Purpose | Example |
|---|---|---|---|
| Agent | User request | Orchestrate workflow | "Encode YD 87:3" |
| Skill | Agent/User | Domain knowledge | Corpus preparation steps |
| Hook | System events | Enforce constraints | Block uncommitted writes |
When to Use the Agent¶
The encoding-orchestrator is triggered when users ask to:
- "Encode halacha"
- "Start encoding session"
- "Encode seif"
- "Prepare sources for encoding"
- "Begin systematic encoding"
- "Resume encoding"
Example Triggers:
| User Says | Agent Action |
|---|---|
| "Let's encode YD 87:3" | Start new session at corpus-prep |
| "Resume encoding" | Load session, continue from last phase |
| "Encode the basar bechalav laws" | Plan multi-seif encoding |
Agent Workflow¶
Session Lifecycle¶
stateDiagram-v2
[*] --> SessionStart: User requests encoding
SessionStart --> CorpusPrep: Initialize session
CorpusPrep --> Checkpoint1: Artifacts ready
Checkpoint1 --> HLLEncode: Human approves
Checkpoint1 --> CorpusPrep: Human rejects
HLLEncode --> Checkpoint2: Rules encoded
Checkpoint2 --> Validate: Human approves
Checkpoint2 --> HLLEncode: Human rejects
Validate --> Checkpoint3: Tests pass
Checkpoint3 --> Review: Human approves
Checkpoint3 --> Validate: Human rejects
Review --> Checkpoint4: Package ready
Checkpoint4 --> Commit: Human approves
Checkpoint4 --> Review: Human rejects
Commit --> [*]: Session archived
Human Checkpoints¶
The agent pauses at four mandatory checkpoints:
- Corpus Preparation
- Review source chain
- Verify commentary completeness
- Validate derivation chain
-
Answer clarifying questions
-
HLL Encoding
- Review encoded rules
- Verify predicate correctness
- Check world scoping
-
Validate machloket representation
-
Validation
- Review test results
- Check compilation status
- Verify regression tests
-
Approve for final review
-
Review
- Complete halachic accuracy checklist
- Complete technical accuracy checklist
- Give final approval
Agent Configuration¶
The agent is defined in agents/encoding-orchestrator.md:
---
name: encoding-orchestrator
description: Use this agent when the user asks to "encode halacha"...
model: inherit
color: cyan
tools: ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "Task",
"AskUserQuestion", "TodoWrite",
"mcp__sefaria_texts__get_text",
"mcp__sefaria_texts__get_links_between_texts",
...]
---
Tool Access¶
The agent has access to:
| Tool Category | Tools |
|---|---|
| File Operations | Read, Write, Edit, Glob, Grep |
| Execution | Bash, Task |
| Interaction | AskUserQuestion, TodoWrite |
| Sefaria MCP | get_text, get_links_between_texts, text_search, english_semantic_search, clarify_name_argument, get_text_or_category_shape, get_english_translations, search_in_dictionaries, get_topic_details |
Agent Output¶
Artifacts Generated¶
The agent coordinates generation of:
Corpus Phase:
- corpus-report-YD-{siman}-{seif}.md
- corpus-sources-YD-{siman}-{seif}.yaml
- corpus-chain-YD-{siman}-{seif}.mermaid
- corpus-questions-YD-{siman}-{seif}.yaml
Encoding Phase:
- seif_{N}.lp
- encoding-report-YD-{siman}-{seif}.md
- encoding-mapping-YD-{siman}-{seif}.yaml
Validation Phase:
- validation-report-YD-{siman}-{seif}.md
- validation-results-YD-{siman}-{seif}.yaml
- test-scenarios-YD-{siman}-{seif}.yaml
Review Phase:
- review-package-YD-{siman}-{seif}.md
Session State¶
The agent maintains state in .mistaber-session.yaml:
current_phase: hll-encode
target_seif: "YD:87:3"
started: "2026-01-25T10:00:00Z"
last_activity: "2026-01-25T14:30:00Z"
checkpoints:
corpus-prep:
status: approved
approved_by: human
timestamp: "2026-01-25T10:30:00Z"
hll-encode:
status: in_progress
validate:
status: not_started
review:
status: not_started
Agent Principles¶
1. Human Supervision is Non-Negotiable¶
The agent NEVER proceeds past a checkpoint without explicit human approval. This ensures:
- Halachic accuracy is verified by humans
- Technical correctness is reviewed
- Errors are caught before propagation
2. Single Seif Granularity¶
The agent works on one seif at a time:
- Small enough for thorough review
- Large enough to be meaningful
- Clear boundaries
- Tractable validation
3. Complete Source Attribution¶
Every rule encoded by the agent has:
makor/2facts linking to sourcesmadrega/2facts specifying normative level- Derivation chain to authoritative source
4. Multi-World Semantics¶
The agent models disputes using Kripke semantics:
- base world for universal rulings
- mechaber world for Sefardi positions
- rema world for Ashkenazi positions
override/3for world-specific modifications
Error Handling¶
Compilation Failure¶
If UNSAT or syntax error:
- Agent reports error clearly
- Identifies problematic rules
- Returns to encoding phase
- Does NOT proceed to validation
Test Failure¶
If tests fail:
- Agent reports which tests failed
- Analyzes failure cause
- Returns to appropriate phase
- Requires re-approval
Missing Source¶
If Sefaria returns no results:
- Agent tries alternative reference formats
- Asks human for guidance
- Documents gap in corpus
Debugging¶
Check Agent Invocation¶
# Verify agent file exists
ls -la mistaber-skills/agents/encoding-orchestrator.md
# Check agent frontmatter
head -40 mistaber-skills/agents/encoding-orchestrator.md
Check Session State¶
# View current session
cat .mistaber-session.yaml
# Check checkpoint status
grep -A2 "status:" .mistaber-session.yaml
Manual Skill Invocation¶
If agent doesn't trigger correctly, invoke skills directly:
Related Documentation¶
- Encoding Orchestrator - Detailed agent documentation
- Skills Overview - Skills used by agent
- Hooks Overview - Hooks enforcing workflow
- Workflow Guide - Complete pipeline documentation