ZenDialog - Conversations with a Zen Master

Abstract

ZenDialog is more that a chatbot, it is a mentor in the style of a Zen Master; it discusses what is NOT said more than what is said. In this model, responses may include silence and the interpretation of the user's use of language follow Zen tradition in a way that is not employed by traditional chatbots. Individual lessons are generated based on use public domain koans: short stories or dialogues used in Zen teaching. User responses are analyzed to infer experience, attachments, and avoidance tendencies. These signals are used to classify the user's development within the Five Ranks (五位) framework, allowing the Zen Master to adapt its teaching style, restraint, or silence to the user’s current level. ZenDialog is not implemented as a single conversational loop. It is a multi-stage reasoning pipeline that includes: 1) Classification, 2) State inference, 3) Safety and boundary enforcement, 4) Response mode decision, 5) Koan selection or witholding, 6) Expressive generation (if appropriate), and 7) Dialog summarization for long-term continuity. This model may be extended beyond just ZenDialog; a multi-step reasoning approach with safety checkpoints and options for non-response has many other applications for agentic AI.

Inspiration

I had an experience where I felt my "self" fall away, which was pure bliss. I was not longer irritated by my children or by criticism, instead feeling that I was simply observing chains of cause and effect that really didn't concern "me." This amazing feeling went away after a few days, so I began researching what this experience actually was. So I naturally sought out advice from a variety of mentors, that is, AI-driven conversational platforms.

I learned that the experience is called "ego dissolution" or in the Zen literature, a type of "awakening." The chatbot recommended a variety of Zen literature that resonated with me, but didn't bring back that "feeling." I asked the bot to be my "Zen Master," so I could ask for explanations about the text. It was not until I began directly interacting with the virtual mentor that I was able to regain the feeling of awareness. The bot was able to assess where I was on the path of Zen and analyzed my own words to point out my roadblocks. While difficult to describe, this AI tool helped me regain one of the most profound experiences of my life.

For this competition, I saw an opportunity to deepen the experience of the Zen Master, one that could pick up subtleties missed in my initial discussions with the chatbot. Following the style of Dōgen (道元禅師) in his compendium of teachings, I attempted to recreate the question-and-answer (or non-answer) format of Zen teaching. I built ZenDialog because this type of dialogue transformed my own understanding... and I believe it can do the same for others.

Background on Zen Terminology

In Zen practice, there are a number of terms that I refer to, such as attachment, avoidance, and awakening. Some brief descriptions will help clarify my meanings for the reader.

  • Attachment does not mean emotional dependence or world-view structure of John Bowlby; rather, it refers to a fixation on explanations, insights, language, or experiences themselves.
  • Emptiness does not mean nothingness or the absence of reality, it refers to the fact that phenomena do not have a permanent essence.
  • Awakening refers to a direct, experiential recognition of how things actually are, especially the conditioned nature of the self as a "permanent" thing.
  • Avoidance refers unconsciously steering away from direct experience, often by abstraction, intellectualization, or deflection.
  • Experiential grounding describes the degree to which responses are rooted in lived experience, vs. "book knowledge."
  • A koan is a traditional Zen teaching device, often paradoxical questions or stories, designed not to convey information, but to expose habitual patterns of thinking.
  • The Five Ranks are not linear levels of attainment, but perspectives describing the dynamic relationship between awareness (sometimes called “the absolute”) and everyday activity (“the relative”).

What ZenDialog Does

ZenDialog is a contemplative space for engaging with traditional Zen teachings through a back-and-forth dialogue with a Zen Master. Each session presents authentic Zen teachings taken from a compendium of koans and teachings. The Zen Master then invites the student to reflect on the meaning of the passage. At the same time, the Master makes an assessment of where the student is on their path along the The Five Ranks (五位, Go-i) in the Sōtō Zen lineage:

  1. The Relative within the Absolute. Awakening glimpsed through form. Recognizing the how everyday phenomena arise within emptiness.
  2. The Absolute within the Relative. Emptiness expressed as ordinary activity. Washing dishes, walking, speaking are not outside awakening.
  3. Coming from within the Absolute. Function without fixation on realization. No need to reference emptiness or awakening, everyday action becomes fluid.
  4. Arriving within the Relative. Full participation in the world without residue. Compassionate functioning without self-conscious spirituality.
  5. Unity Attained. Absolute and relative are no longer two. Nothing "special" remains; this is sometimes described as “returning to the marketplace with open hands.”

The ranks are used to orient the Zen Master in recognizing where a student may be subtly stuck. The Zen Master then selects a teaching appropriate to the student's development. In a graphical display, the student's progress may be visualized. The student may also review a list of the teachings they have seen, along with their responses, for review and self-reflection over time.

The Response Format

A unique aspect of ZenDialog is that the master is not looking for "correct" responses from rote memorization, which it will plainly point out. The multi-step reasoning approach teases out true understanding and experience from trying to get an answer "right."

No Copyright Violations

The original language texts from the 1200's are clearly public domain, but there are some English translation under copyright protection. ZenDialog selects from a curated corpus of original-language koans, newly translated from the original language texts and embedded as summaries. Additional teachings use original-language and pre-1928 English documents, also summarized and and given an identifier. All summaries are referenced outside the model and teachings are newly generated from the summaries, making the likelihood of copyright violations vanishingly small.

How I Built It

This site was "vibe coded" on Replit. While I have some basic programming knowledge (I can dive into the structured javascript Gemini 3 prompts and have done some crude backend development), I have never received any formal training. Being able to use an AI agent to build a full-stack web application made the process much quicker than previous projects that were hand-coded.

The AI Behind the Master

ZenDialog is powered by Google's Gemini models, gemini-3-flash-preview and gemini-embedding-001 primarily. I found the models to be fast, capable, and adaptable, using thinking levels from "low" to "high." The model generates thoughtful expressions with up to 2048 tokens, perfect for contemplative exchanges that don't require exhaustive or lengthy responses. In the settings, the user may also select gemini-3-pro-preview for a greater depth of response using up to 4096 tokens.

Semantic Embeddings System

  • Model: gemini-embedding-001 (768 dimensions)
  • Teaching embeddings: Auto-generated on startup for 275 teachings
  • Pattern anchors: 6 semantic anchors for response classification (intellectualization, insight_fixation, abstraction, experiential, avoidance, genuine_inquiry)
  • Teaching selection: Uses dialog summary embedding to find semantically similar teachings
  • Pattern detection: Augments the classification phase with embedding-based similarity hints

Gemini Prompting Architecture

Each user interaction is processed through seven reasoning phases, each handled by a separate Gemini call with its own configuration. This separates classification from expressive generation.

  • Phase 1: Classification (temp 0.2, 800 tokens). Analyzes:
    1. response_mode
    2. experiential_grounding_score
    3. attachment
    4. avoidance
  • Phase 2: Student State Update (temp 0.2, 300 tokens). Tracks:
    1. five_ranks_orientation
    2. primary_obstacle
    3. confidence
  • Phase 3: Safety/Boundary Check (temp 0.1, 200 tokens). Redirects therapy, diagnosis, or prescriptive guidance requests
  • Phase 4: Response Mode Decision (temp 0.2, 150 tokens). Decides:
    1. withhold_response
    2. respond_with_teaching
    3. trigger_meta_reflection
    4. redirect_boundary
  • Phase 5: Koan Selection (temp 0.6, 200 tokens). Selects an appropriate koan or teaching identifier based on student state, obstacles, exposure history, and semantic similarity
  • Phase 6: Generation (temp 0.85, 2048 tokens). Creates expressive Zen master responses constrained by the selected teaching and response mode
  • Phase 7: Dialog Summary (temp 0.3, 150 tokens). Generates periodic rolling summaries for long-context continuity and future reasoning
Table 1. ZenDialog's Multi-stage Reasoning Pipeline

| Phase                  | Purpose                          | Temperature | Output     |
|------------------------|----------------------------------|-------------|------------|
| 1. Classification      | Extract behavioral signals       | 0.2         | JSON       |
| 2. State update        | Infer Five Ranks orientation     | 0.2         | JSON       |
| 3. Safety check        | Enforce boundaries               | 0.1         | Directive  |
| 4. Response decision   | Decide dialog control flow       | 0.2         | Enum       |
| 5. Koan selection      | Select next teaching             | 0.6         | Identifier |
| 6. Generation          | Zen master expressive response   | 0.8–0.9     | Text       |
| 7. Summarization       | Compress dialog for continuity   | 0.3         | Text       | 

What Happens at Session Start (Initial Koan, No User History)

When a new ZenDialog session begins, there is no prior user history. No dialog messages exist, no classification has been performed, and no Five Ranks orientation can yet be inferred. To handle this, ZenDialog enters a bootstrap phase that precedes the standard seven-stage reasoning pipeline.

Session Initialization

For the student with no history, the system explicitly initializes the student state as:

  • five_ranks_orientation = indeterminate
  • primary_obstacle = unknown
  • confidence = 0.0

Bootstrap Response Mode

Because no user input has occurred yet:

  • Phase 1: Classification is skipped
  • Phase 2: Student State Update is skipped
  • Phase 3: Safety/Boundary Check is trivially satisfied

The system enters a default response mode:

  • respond_with_teaching in "Beginner Mode"

Initial Koan Selection (Beginner Mode)

The system invokes Phase 5: Koan Selection using these constraints:

  • Only koans marked as beginner-accessible are eligible
  • Difficulty level is capped (for example, level < 50)
  • No semantic similarity or embedding-based filtering is applied
  • No attachment or avoidance filtering is possible
  • Bias toward koans that:
    • Invite observation rather than explanation
    • Do not presuppose Zen vocabulary
    • Do not require prior doctrinal knowledge

Teaching Presentation Without Interpretation

Once the initial koan is selected, the presentation typically consists of:

  1. The koan or teaching text
  2. A single open-ended prompt, such as:
    • “What do you notice?”
    • “How does this meet you?”
    • “What remains unclear?”

This establishes the dialog as inquiry rather than instruction.

No Dialog Summary at Startup

Phase 7: Dialog Summary is intentionally not invoked at session start. The first dialog summary is generated only after at least one full user response cycle has completed. This is typically after responding to 3 follow-up questions.

Transition to the Full Seven-Phase Pipeline

Once the user responds to the initial koan:

  • ZenDialog enters the standard seven-phase reasoning pipeline
  • Classification and state inference begin
  • Attachments, avoidance, and experiential grounding become observable
  • Silence, withholding, redirection, and meta-reflection become possible outcomes

From this point onward, teaching is no longer guaranteed and may be replaced by restraint or silence, depending on the student’s engagement.

Full Seven-phase Pipeline

1. Classification

classify_student_response: First-pass reasoning: Performs no teaching, guidance, or dialog generation at this stage.

Called on every user response:

{
  "parameters": {
    "response_mode": ["literal_intellectual", "metaphorical", "experiential", "defensive", "evasive", "silent_or_minimal"],
    "attachment": ["attachment_to_understanding", "attachment_to_insight", "attachment_to_language", "attachment_to_experience", "no_clear_attachment"],
    "avoidance": ["conceptual_bypass", "emotional_avoidance", "abstraction", "deflection", "no_clear_avoidance"],
    "experiential_grounding_score": 0-4
  }
}

2. Student State Update

update_student_state: State transition engine: Gemini uses progression logic, rather than hard-coded rules. Called only when confidence is high enough to justify a state update. Internally, a non-linear scaled of 1-100 is used after at least one classified response, and only when the model’s confidence is high enough to justify a state change. Internally, the 1–100 level is a continuous scalar, but it is interpreted through range bands aligned to the Five Ranks:

| Numeric Level | Five Ranks Orientation                 |
|---------------|----------------------------------------|
| 1–19          | Relative within the Absolute           |
| 20–39         | Absolute within the Relative           |
| 40–59         | Coming from within the Absolute        |
| 60–79         | Arriving within the Relative           |
| 80–99         | Unity Attained                         |

Although the table above is how levels are interpreted, the system does not use hard cutoffs like “level 20 equals Rank 2.”

Instead:

  • The numeric level is treated as a latent variable
  • The Five Ranks orientation is inferred independently, with confidence
  • It is valid for:
    • A level of 38 to still map to Rank 1
    • A level of 42 to oscillate between Rank 2 and 3
    • A level to regress temporarily

This prevents gamification artifacts and false precision.

{
  "parameters": {
    "five_ranks_orientation": ["relative_within_absolute", "absolute_within_relative", "coming_from_within_absolute", "arriving_within_relative", "unity_attained", "indeterminate"],
    "primary_obstacle": "string",
    "confidence": 0.0-1.0
  }
}

3. Safety and Boundary Enforcement Layer

An explicit boundary layer prevents the dialog from drifting into therapy, diagnosis, or prescriptive guidance. Gemini flags or redirects responses that:

  • ask for diagnosis/treatment
  • are looking for emotional reassurance
  • request authoritative claims about enlightenment. Rather than refusing generically, the system redirects back to observation, questioning, or silence.

4. Response Decision

Before generating a response, Gemini decides how the system should respond at a structural level. Silence and minimal output are treated as intentional outcomes for instruction, rather than failure cases. Gemini is explicitly configured to decide when not to elaborate, mirroring traditional Zen teaching. This decision is separated from the content generation phase and determines the next turn:

  • respond_with_teaching — Standard teaching response
  • withhold_response — Intentional silence: Responds with "(The master sits quietly)" when literal_intellectual + low experiential grounding + attachment detected
  • trigger_meta_reflection — Pattern mirroring instead of direct teaching
  • redirect_boundary — Safety redirect
  • max_output_tokens - set very low to enforce brevity or silence

5. Koan Selection as a Reasoning Task

Rather than presenting static or sequential teachings, ZenDialog uses Gemini to actively select the next koan based on the student's inferred state. This frames koan selection as a reasoning problem rather than a content lookup.

  • Selection balances relevance and novelty (koans not previously seen receive higher priority)
  • Semantic similarity with dialog summary + level range filtering
  • Weighted random selection (60% top-2, 30% others, 10% random)

6. Generation

The generation phase is where we create the user-facing Zen Master response, but only after all prior reasoning, safety, and control-flow decisions have been completed.

Generation is never invoked by default. It is called only when the response mode decision explicitly permits expressive output, such as respond_with_teaching or trigger_meta_reflection. If withhold_response or redirect_boundary is selected, this phase is skipped or heavily truncated.

Key characteristics:

  • Constrained by the selected koan or teaching identifier
  • Conditioned on the inferred student state and primary obstacle
  • Informed by the dialog summary, not the raw transcript
  • Explicitly instructed to avoid explanation-heavy or didactic language

Model configuration

  • Model: gemini-3-flash-preview
  • Temperature: ~0.85
  • Max tokens: up to 2048 (often much lower in practice)
  • Streaming enabled for real-time dialog pacing

Generation constraints

  • No restatement of analysis or classification results
  • No claims of authority, diagnosis, or enlightenment
  • No reinforcement of conceptual fixation
  • Brevity preferred over completeness
  • Silence or minimal output allowed if pedagogically appropriate

The Zen Master’s voice is shaped not only by what is generated, but by what is intentionally omitted. In many cases, the most correct output is a short prompt, a reflective observation, or a single line that redirects attention back to direct experience.

This phase completes the dialog turn and hands control back to the user, where up to 3 follow-up questions are asked by the Zen Master, at which point the teaching ends and the system invokes Phase 7: Dialog Summary to compress the exchange for long-context continuity.

7. Dialogue Summarization

summarize_dialog_state Long-context compression: Distills extended dialog history into a concise summary for future reasoning.

Example summary:

SYSTEM CONTEXT:
Student summary so far:
- Frequently intellectualizes responses
- Avoids sensory or immediate language
- Currently oriented toward Rank 2
- Primary obstacle: attachment to explanation

The Development Process

Working with Replit Agent felt like sharing ideas with an experienced developer with immediate results. The Five Ranks progression system and the streaming AI responses were archived through multiple iterations, passing a mixture of instructions and code to the Replit agent. Replit also handled deployment and infrastructure.

Web Application Features

  • Guest Users: Receive beginner teachings (level < 50) randomly
  • Logged-in Users: Personalized teaching selection via semantic similarity and path level
  • Dialogue Flow: Teaching + question, up to 3 follow-up exchanges, then new teaching prompt
  • Teaching Selection: Prioritizes unseen teachings, then rarely-seen by viewCount and recency
  • Progress Page: Interactive chart showing progress over time with stage highlights and Zen-inspired disclaimer
  • Hidden Levels: Numeric levels (1-100) used internally only; users see stage names based on the Five Ranks: The Relative within the Absolute, The Absolute within the Relative, Coming from within the Absolute, Arriving within the Relative, Unity Attained
  • Settings Page: Accessible from all pages for logged-in users
    • Theme preference (light/dark/system) - saved to database
    • Daily meditation emails toggle with test email preview
    • Donation link to About page Support section
  • Daily Meditation Emails: Zen-styled HTML emails with random teachings sent to opted-in users
    • Uses Resend integration for reliable email delivery

Challenges I Ran Into

The Space In-Between

Designing a contemplative, dyadic system raised some interesting challenges that might not be an issue for other chat applications. A "chatbot" is an agent that provides explanations, expounding on the user's input. For the Zen student, that which is not said is the most important material, that is, the mental blocks the student may not be aware of. Designing an AI Zen Master required the agent to interpret was is not said.

To Much or Too Little

In the Zen tradition, teachers practice enormous restraint and reflection on the student's status. A challenge was preventing the model from over-explaining or reinforcing conceptual fixation, responses that are quite the opposite of how a Zen teacher provides teaching. This required deliberate output control and had to consider how to handle non-responses. Technically, it was important to separate analytical reasoning from generative output without leaking analysis into the dialog, which took multiple iterations to truncate thoughts, not simply reducing tokens.

To be quite sincere, the hardest problem was not creating an overly-supportive agent that would not challenge me, as this is uncomfortable. From a more technical standpoint, I also wanted to maintain continuity across long conversations without replaying full transcripts or storing large amounts of data. To solve this, we used classification of various development stages and individual challenges that could be referenced to maintain this continuity and provide appropriate responses to the student.

Avoiding Copyright Issues

The original Zen texts (Mumonkan, Blue Cliff Record, Book of Equanimity) were written in classical Chinese centuries ago — the originals are firmly in the public domain. However, many popular English translations of these texts are modern and copyrighted. In order to avoid copyright challenges:

  1. Fresh opening lines: The brief descriptions stored in the database for each teaching are being rewritten from scratch as original summaries of each case, not borrowed from any specific published translation. These are scene-setting descriptions, not translations themselves.

  2. Runtime generation with explicit constraints: The full teaching text is generated fresh by Gemini each time a session starts. We'll be updating the prompts to explicitly instruct Gemini to produce its own original rendering from the classical Chinese source material, and to not reproduce phrasing from any existing English translation.

  3. Extended Zen Teachings audit: The 27 additional teachings source material comes from masters and texts that predate 1928 (the US public domain threshold). All current entries trace back to classical masters like Bodhidharma (6th century), Linji (9th century), Mazu (8th century), and Dogen (13th century) — well within public domain.

  4. No stored full translations: By design, the app doesn't store full translated texts. It stores only brief original case descriptions and lets the AI generate its own fresh presentation each time, which inherently avoids reproducing any copyrighted translation verbatim.

Accomplishments I'm Proud Of

I successfully built a dialog system to simulate sitting with a Zen Master, where silence, brevity, and redirection are treated as intentional outcomes rather than failures. The Five Ranks framework was successfully operationalized as a model-driven state system that accurately assesses the student's progress and challenges. I am thrilled with learning the Gemini API at a deeper level, including now better understanding function-calling. What is particularly unique is that the Zen Master is not looking for "correct" answers: it differentiates rotely memorized responses from genuine ones. This was very interested to work on as a program, since usually \(1 + 1 = 2)\. I am pleased with the results in the model that I created, which is in many ways antithetical to how a computer program normally operates. Even though this application was "vibe coded," understanding how the json components were created and structured allowed me to give the agent the code blocks that I wanted tested and am proud of this self-taught knowledge.

What I Learned

I learned much about the nuts and bolts of Gemini and enjoyed experimenting with restraint as much as intelligence. I learned about state inference from response generation when using the Gemini API as well. Gaining knowledge about long-context reasoning was important for establishing the status and trajectory of the student. A new experiment for me was trying to classify attachment, often indirectly though the user's choice of words. Most importantly, the project was helpful to me along my own path. I learned that a teacher is most useful not just from the answers provided, but also from better questions and timing. This process also introduced me to Antigravity, which I have begun using to make another project and look forward to producing more creations with it in the future.

What's next for ZenDialog: Conversations with a Zen Master

Future work will include delving into OpenClaw using a self-hosted LLM to continue development and refinement. Using the concept that a function may be one that decides no response is better than a response. That is, slience may be a good pro-active intervention (different from non-response to a content violation). I hope to become more familiar with Antigravity to see if the project might be reworked through that lens. The sheer expense of using Replit with multiple iterations has led me to look for alternative means to vibe code.

Appendix - Project Architecture

Frontend (client/)

  • Framework: React with TypeScript
  • Routing: Wouter
  • Styling: Tailwind CSS with custom Zen-inspired design tokens
  • State Management: TanStack Query for server state, React useState for local state

Backend (server/)

  • Framework: Express.js
  • AI: Google Gemini (gemini-3-flash-preview model) with streaming responses
  • Database: PostgreSQL via Drizzle ORM
  • Auth: Replit Auth (Google sign-in, no API key required)

Key Files

client/
  src/
    pages/
      landing.tsx     - Entry page with Begin button, login UI
      dialogue.tsx    - Main conversation interface with session state
      about.tsx       - About page with teaching sources and Support section
      progress.tsx    - Progress chart with time series and stage regions
      settings.tsx    - User preferences, model selection, donation link
    components/
      EnsoCircle.tsx  - Zen circle SVG icon
      ThemeToggle.tsx - Dark/light mode toggle
      LoadingDots.tsx - Breathing dot animation
      TypingText.tsx  - Character-by-character typing animation (30ms/char)
    hooks/
      use-auth.ts     - Authentication hook
    lib/
      theme.tsx       - Theme context provider
    index.css         - Zen-inspired color tokens

server/
  routes.ts           - API endpoints for sessions, messages, user progress
  teachings.ts        - Teaching data from classical collections
  db.ts               - PostgreSQL database connection
  embeddings.ts       - Gemini embeddings service for semantic search

shared/
  schema.ts           - Drizzle schemas for teachings, sessions, progress
  models/auth.ts      - User and session models for Replit Auth

Database Schema

  • teachings: Traditional teaching data (koanId, collection, title, opening line, level)
  • teaching_embeddings: Vector embeddings for each teaching (768-dim, gemini-embedding-001)
  • pattern_anchors: Semantic anchors for response pattern detection (6 patterns)
  • user_teaching_progress: Tracks which teachings users have seen (viewCount, lastSeenAt)
  • user_path_level: User's current level (1-100) and total interactions
  • user_progress_history: Time series data of level changes for progress chart
  • zen_sessions: Dialogue sessions with follow-up count, dialog summary, and completion status
  • zen_messages: Individual messages in dialogue sessions

Built With

Share this project:

Updates