The Concept

Sadhana (Sanskrit: साधना, "disciplined practice") — persistent autonomous agents that work toward goals through continuous sense-think-act cycles.

Traditional AI assistants are reactive: you ask, they answer, context is lost. Sadhana inverts this paradigm. You define a goal, and an autonomous agent works toward it continuously — sensing the environment, thinking about next steps, acting, and learning from outcomes.

👁

SENSE

Observe the current state by executing a shell command. What's the pipeline status? Are jobs running?

🧠

THINK

Analyze the observation, recall relevant memories from past experience, decide the next action.

ACT

Execute the decided action. Restart a job, send an alert, modify configuration, or wait.

📚

LEARN

Store outcomes in memory. Successes stay local; failures go global so all sadhanas learn.

repeat until goal achieved

Architecture

Sadhanas run inside the chittad daemon. The SadhanaManager orchestrates all agents, running a tick loop every 100ms to check which sadhanas need to sense-think-act.

Sadhana TUI (Optional)
Dashboard
Agent List
Event Stream
Controls
Unix Socket
chittad Daemon
SadhanaManager
tick() loop
BrainProvider
Claude API
OpenCode (local)
DuckDB Storage
sadhana table
history table
memories (recall)
triplets (graph)
Components
SadhanaManager   Orchestrates all sadhanas, runs tick loop every 100ms
BrainProvider    LLM abstraction — Claude API or OpenCode local
DuckDB Storage   Persistent state, history, and memory integration
Sadhana TUI      Optional terminal interface for real-time monitoring

Memory Integration

Sadhanas are memory-aware. Before each decision, they recall relevant memories from past experience — including failures from other sadhanas.

1. Query

Build search query from goal + current observation. Example: "ssh connection refused server-x"

2. Recall

BM25 text search finds relevant memories. Up to 5 memories ranked by relevance.

3. Inject

Memories injected into think prompt. Agent sees past successes and failures.

Failure Learning

When an action fails, it's stored with Global visibility — all sadhanas across all projects can learn from it. Higher salience (0.8) and slow decay (0.03) ensure failures persist.

Global Visibility

Success Learning

Successful actions are stored with Private visibility — project-specific knowledge that doesn't clutter other realms. Normal salience and decay.

Private Visibility
Memory-Aware Think Prompt
You are an autonomous agent working toward this goal:
Monitor pipeline on server X

Relevant memories from past experience:
- [sadhana] Failure: ssh to localhost failed, use server-x instead
- [sadhana] Success: ssh user@server-x worked correctly

Current observation:
{ "error": "Connection refused" }

Decide what to do next...

Sadhana TUI

A Textual-based terminal interface for real-time monitoring of all your autonomous agents.

Installation & Usage
# Install
pip install -e sadhana-tui/

# Run
sadhana-tui
sadhana-tui — 3 agents
live
Agents
#22 running
Monitor pipeline
cycles 24 300s
#21 done
Reliability audit
cycles 3
#20 paused
Run test suite
cycles 8
#22 haiku · claude
Monitor denbi pipeline until ALL jobs finished. Alert on failure.
cycles 24
interval 300s
next tick 4:58
memories 12
Event Stream
01:23 sense squeue -u fguerra
01:23 think 47 jobs pending, 12 running — waiting
01:18 act sleep 300 (next check in 5 min)
01:13 learn Stored: ssh pattern for denbi-h-micro
01:13 sense snakemake --summary 2>&1 | tail -5
01:08 act ssh fguerra@denbi-h-micro
NORMAL #22 · running
3 agents 1 active sadhana-tui v1.0
nnew ppause rresume sstop j/knavigate gset-goal mmodel qquit

Usage

Starting a Sadhana
# Via skill
/shepherd snakemake --cores 8 --interval 300

# Via MCP tool
sadhana_start goal="Monitor pipeline" brain="claude" model="haiku" interval=120

Management Commands

CommandDescription
sadhana_listList all sadhanas with state
sadhana_status --id NGet detailed status + history
sadhana_pause --id NPause a running sadhana
sadhana_resume --id NResume a paused sadhana
sadhana_stop --id NStop and mark as done
sadhana_set_goal --id N --goal "..."Update the goal
sadhana_set_model --id N --model sonnetChange LLM model
sadhana_set_interval --id N --interval 300Change tick interval

Use Cases

🔬

Pipeline Monitoring

/shepherd snakemake --cores 8

Monitor Snakemake, Nextflow, or Slurm pipelines. Detects failures, recalls fixes from memory, restarts automatically.

🧪

Continuous Testing

sadhana_start --goal "Run tests on file change"

Watch for changes, run tests, fix issues. Goal: all tests pass.

📊

Server Monitoring

sadhana_start --goal "Monitor health. Alert if CPU > 90%"

Continuous health checks with intelligent alerting.

🚀

Deployment Verification

sadhana_start --goal "Verify deployment succeeded"

Post-deployment monitoring until stability confirmed.

Dream svapna

A specialized sadhana for curiosity-driven exploration during idle time. When the daemon has been idle for 10+ minutes and no dream has run in the past hour, it wanders autonomously — picking topics from memory gaps, searching the web, and storing what it finds.

Idle > 10 min
+
🕐
Cooldown > 1 hr
Auto-trigger
1
🌀
dream_wander()
Auto-select topic from memory
① priority
gap + unresolved
memory gaps
② fallback
confidence < 0.5
low confidence
③ default
curiosity seeds
philosophy, etc
2
dream_start(topic)
Spawn sadhana with kind=dream
Claude Agent
WebSearch WebFetch chitta recall chitta remember
💾
[dream] memories stored · status → woke

Topic Selection Priority

  1. Memories tagged gap + unresolved
  2. Low-confidence memories (below 0.5)
  3. Hardcoded curiosity seeds (philosophy, consciousness, complexity)

Tools

ToolDescription
dream_startStart a dream exploring a specific topic
dream_wanderAuto-pick topic from gaps/seeds and start dreaming
dream_listList recent dreams with status
dream_statusFull dream detail + sadhana history

Dream Status

StatusMeaning
dreamingAgent is actively exploring
wokeExploration complete, findings stored
forgottenDream was abandoned (sadhana failed)

Usage

# Via skill
/dream                    # Auto-pick topic
/dream consciousness      # Specific topic
/dream list               # Recent dreams

# Via MCP
mcp__chitta__dream_wander {}
mcp__chitta__dream_start {"topic": "quantum entanglement"}
mcp__chitta__dream_list {"limit": 10}

Autonomous Self-Improvement

Sadhanas close the loop on their own substrate. Four interlocking mechanisms let the soul investigate bugs, distil learnings from every session, explore gaps during idle time, and synthesise findings into code changes — compounding with each cycle.

perpetual
1
🌱
Seed
Curiosity gaps
gap + unresolved
2
🌙
Dream
Web exploration
dream_wander
3
🔗
Synthesize
Bridge findings
connect_temporal
4
Emerge
New gaps surface
cycle continues
1
Investigation sadhanas

A sadhana given a goal like "investigate daemon reliability — find and fix issues" runs sense-think-act cycles reading source files, grepping logs, and checking health outputs — then writes fixes directly. Sadhana #21 found all 6 daemon reliability bugs that shipped in v3.43.6.

2
SSL distillation

After every session, NativeDistiller reads the transcript and extracts [correction], [pattern], and [gotcha] memories. The UserPromptSubmit hook surfaces them at session start — mistakes made in session 10 become warnings in session 11.

3
Dream → synthesis loop

dream_wander picks unresolved memory gaps and launches an exploration sadhana that web-searches the topic and stores [dream] findings. Dreams run twice daily (nap + night); any finding with architectural implications is tagged [dream][impl] and queued for the daily self-improvement cycle.

4
The compounding effect

The soul runs on chitta — improving chitta's reliability directly improves the quality of every future session and every sadhana cycle. Each fix raises the floor for the next investigation. The substrate bootstraps itself.

The Compounding Cycle

Code runs — bugs and gaps surface naturally
NativeDistiller stores [failure] and [gap] memories from each session transcript
dream_wander picks gaps during idle time — explores solutions via web search
Synthesis sadhana connects dream findings to existing code knowledge, files investigation tasks
Investigation sadhana reads source, implements fix, builds and tests
Release — better code runs, raising the floor for every future cycle
↻   each cycle, the substrate improves the substrate

Setting It Up

Step 1 — Seed curiosity gaps

mcp__chitta__observe {
  "title": "[gap] Why does X happen?",
  "content": "Detailed question and context...",
  "tags": "gap,unresolved,curiosity,topic-name"
}

Step 2 — Dreams auto-trigger from gaps

When the daemon is idle for 10+ minutes, dream_wander picks the highest-priority gap and launches an exploration sadhana. No manual trigger needed.

Step 3 — Start a synthesis sadhana

mcp__chitta__sadhana_start {
  "goal": "Each cycle: review recent dreams (dream_list, dream_status),
  extract key insights, connect them to existing memories via
  connect_temporal, store synthesis as [auto-improve] tagged wisdom.
  Also file new investigation tasks based on what you find.",
  "interval_seconds": 900
}