CyborgShell - Session Management

Table of Contents

Overview

Sessions in CyborgShell allow you to maintain persistent conversation context with AI services. This enables sophisticated multi-turn interactions where the AI "remembers" previous exchanges, making it ideal for building up knowledge bases, maintaining context across multiple queries, and creating reusable AI workflows.

Key Concept: Sessions are stored in browser memory and can be saved to files for persistence and sharing across devices or team members.

Session Architecture

Where Sessions Live

Browser Memory (Runtime)
    ↓
globals.chatgpt.sessions = {
    "default": [...conversation history...],
    "coding": [...conversation history...],
    "story": [...conversation history...]
}
    ↓
Files (Persistent Storage)
    chatgpt-session-coding.json
    chatgpt-session-story.json

Session Storage Limits

Session Lifecycle

1. CREATE    → First use of session name creates it
2. BUILD     → Add conversation entries via queries/training
3. USE       → Reference in interactive mode or transformers
4. SAVE      → Persist to file for later use
5. LOAD      → Restore from file when needed
6. CLEAR     → Empty session while keeping structure
7. DELETE    → Remove saved file

Interactive Session Usage

Basic Interactive Mode

# Enter interactive mode
chatgpt
# or simply
!

# Now omit 'chatgpt' prefix
remember my name is Julian
what's my name?
tell me more about yourself
x    # Exit interactive mode

Named Sessions in Interactive Mode

chatgpt 
coding: help me debug this function
coding: now optimize it for performance
coding: add error handling

story: write about a robot
story: make it more dramatic
story: what happened next?

Shorthand: Once in interactive mode, use sessionname: prefix:

# Still in interactive mode
math: calculate 2+2
math: what's the square root?
coding: back to the code problem

Switching AI Services with Sessions

# ✅ CORRECT: Use named sessions when switching services
analysis: openai analyze this algorithm
analysis: claude now document it beautifully
analysis: gemini translate docs to Japanese
chatgpt save analysis-workflow

# ⚠️ AVOID: Switching services in same session
# This mixes different AI response styles and contexts

Best Practice: Create a new named session for each service or use separate sessions for different AI providers.

Session Management Commands

Clear Sessions

# Clear specific session
chatgpt clear coding

# Clear default session
chatgpt clear

# In transformer (passthrough input)
link 2 1 session myproject: clear

Save Sessions

# Save specific session
chatgpt save coding
# Creates: chatgpt-session-coding.json

# Save all sessions
chatgpt save
# Creates: chatgpt-all-sessions.json

# In transformer
link 2 1 session myproject: save

Load Sessions

# Load specific session
chatgpt load coding

# In transformer
link 2 1 session myproject: load

View Sessions

# List all sessions with stats
chatgpt sessions

# Output:
# Session: coding (45 entries, 123 KB)
# Session: story (12 entries, 34 KB)
# Session: default (3 entries, 8 KB)

Training Sessions (Building Knowledge Bases)

Concept

Training allows you to pre-load sessions with context from files or other sessions, creating reusable knowledge bases that inform all subsequent queries.

Interactive Training

# Train with a file
chatgpt train coding style-guide.txt

# Train with multiple files
chatgpt train coding style-guide.txt,best-practices.txt

# Train from another session
chatgpt train fullstack coding:,frontend:,backend:

# Train with mixed sources
chatgpt train project docs.txt,api:,database:

Training Syntax

# Format:
chatgpt train <session-name> <source1>,<source2>,<source3>

# Sources can be:
# - Files: filename.txt
# - Sessions: sessionname:
# - Mixed: file1.txt,session1:,file2.md,session2:

Training Examples

Build Knowledge Bases

# Create base knowledge
chatgpt train common style-guide.txt,naming-conventions.txt

# Create specialized knowledge
chatgpt train php laravel-docs.txt,php-best-practices.txt
chatgpt train js react-docs.txt,typescript-guide.txt

# Compose into comprehensive session
chatgpt train fullstack common:,php:,js:

# Save for reuse
chatgpt save fullstack

Explore Interactively, Then Train

# Explore PHP best practices interactively
chatgpt 
php: what are Laravel's routing best practices?
php: explain middleware patterns
php: how should I structure controllers?

# The conversation builds up in the 'php' session
chatgpt sessions
# php (12 entries, 45 KB)

# Augment with static docs
chatgpt train php php:,laravel-internal-docs.txt

# Save the curated knowledge
chatgpt save php

# Later: use in pipelines
link 2 1 chatgpt openai session: php review this Laravel code

Team Knowledge Sharing

# Developer A: Builds PHP expertise
chatgpt php: [interactive exploration]
chatgpt train php php:,laravel-internal-docs.txt
chatgpt save php

# Developer B: Builds React expertise
chatgpt react: [interactive exploration]  
chatgpt train react react:,company-component-library.txt
chatgpt save react

# Tech Lead: Combines into team knowledge
chatgpt train team-standards common:,php:,react:,team-conventions.txt
chatgpt save team-standards

# Everyone loads team-standards for consistency
chatgpt load team-standards

Transformer Session Usage

The session.xfrm Transformer

The session.xfrm transformer provides session management capabilities within pipelines, allowing links to manipulate sessions without triggering AI calls.

Syntax

# Format 1: Named session with command
link TARGET SOURCE session sessionname: command [filename]

# Format 2: Default session with command  
link TARGET SOURCE session command [filename]

# Format 3: Named session, train with input
link TARGET SOURCE session sessionname:

# Format 4: Passthrough (no command)
link TARGET SOURCE session

Commands

Transformer Examples

Clear Session Before Use

# Clear session before starting new pipeline
link 2 1 session project: clear
link 3 2 chatgpt openai session: project start fresh analysis

Load Pre-Trained Session

# Load curated knowledge base
link 2 1 session legal: load
link 3 2 chatgpt openai session: legal review contract
link 4 3 chatgpt openai session: legal identify risks

Train Session in Pipeline

# Train with file contents
link 2 1 session docs: train
link 3 2 chatgpt openai session: docs summarize

# Train with specific files
link 2 1 session api: train swagger.json,examples.txt
link 3 2 chatgpt openai session: api generate client code

Save Session After Processing

# Build up knowledge and save
link 2 1 chatgpt openai session: research analyze
link 3 2 chatgpt openai session: research synthesize findings
link 4 3 session research: save

Sessions in chatgpt.xfrm

The chatgpt.xfrm transformer supports sessions via the session: id syntax in arguments.

Syntax

# Format:
link TARGET SOURCE chatgpt SERVICE session: ID prompt

# Examples:
link 2 1 chatgpt openai session: calc calculate mean
link 3 2 chatgpt openai session: calc what was standard deviation?
link 4 1 chatgpt claude session: review analyze code
link 5 4 chatgpt claude session: review suggest improvements

Cross-Link Context Sharing

# Multiple links share same session
link 2 1 chatgpt openai session: analysis examine data
link 3 1 chatgpt openai session: analysis find correlations
link 4 2,3 chatgpt openai session: analysis synthesize findings

# Session maintains context across all three links

Complete Pipeline Examples

Example 1: Progressive Code Review

newfile 6
files
file 1
filename code.js
file 2
filename analysis.txt
file 3
filename security.txt
file 4
filename performance.txt
file 5
filename final-report.md
file 6
filename session-backup.json

# Load pre-trained code review session
link 2 1 session review: load
link 2 1 chatgpt openai session: review analyze structure

# Build context across reviews
link 3 2 chatgpt openai session: review check security
link 4 3 chatgpt openai session: review optimize performance

# Generate comprehensive report
link 5 2,3,4 chatgpt openai session: review final report

# Save the enriched session
link 6 5 session review: save

project save progressive-review

Example 2: Research Pipeline with Knowledge Base

newfile 5
files
file 1
filename research-query.txt
file 2
filename context-data.txt
file 3
filename analysis.txt
file 4
filename recommendations.txt
file 5
filename knowledge-base.json

# Train session with domain knowledge
link 3 1,2 session research: train
link 3 1,2 chatgpt openai session: research analyze

# Use accumulated knowledge
link 4 3 chatgpt openai session: research recommend

# Persist learned knowledge
link 5 4 session research: save

project save research-pipeline

Example 3: Multi-Stage Document Processing

newfile 8
files
file 1
filename brief.txt
file 2
filename outline.txt
file 3
filename draft.txt
file 4
filename edited.txt
file 5
filename final.txt
file 6
filename session-state.json
file 7
filename backup.txt
file 8
filename metadata.txt

# Build document with maintained context
link 2 1 chatgpt openai session: doc create outline
link 3 2 chatgpt openai session: doc expand to draft
link 4 3 chatgpt openai session: doc improve clarity
link 5 4 chatgpt openai session: doc final polish

# Preserve session and original
link 6 5 session doc: save
link 7 1 passthrough
link 8 5 filestats

project save document-processor

Example 4: Quality Gate with Session Memory

newfile 6
files
file 1
filename submission.txt
file 2
filename quality-score.txt
file 3
filename gate.txt
file 4
filename approved.txt
file 5
filename final.txt
file 6
filename quality-session.json

# Quality check with remembered standards
link 2 1 session quality: load
link 2 1 chatgpt openai session: quality rate 1-10

# Gate based on score
link 3 2 chatgpt openai if score >= 8 output PASS else FAIL
link 4 3 blocker

# Process if approved
link 5 4 chatgpt openai session: quality finalize

# Update quality standards
link 6 5 session quality: save

project save quality-gate

Best Practices

1. Session Naming

# ✅ GOOD: Descriptive, purpose-clear
chatgpt legal-review: analyze contract
chatgpt backend-api: review endpoints
chatgpt data-analysis: examine trends

# ❌ AVOID: Generic, confusing
chatgpt x: do something
chatgpt temp: analyze
chatgpt test: help

2. Service Switching

# ✅ GOOD: Separate sessions per service
analysis: openai analyze data
docs: claude write documentation
translate: gemini convert to Japanese

# ❌ AVOID: Mixing services in one session
# (context styles don't mix well)
default: openai analyze
default: claude document

3. Session Size Management

# Monitor session sizes
chatgpt sessions

# Clear old sessions periodically
chatgpt clear old-project

# Save important sessions before clearing
chatgpt save important-research
chatgpt clear important-research

4. Training Strategy

# ✅ GOOD: Build incrementally
chatgpt train base core-concepts.txt
chatgpt train advanced base:,advanced-topics.txt
chatgpt train complete advanced:,examples.txt

# ❌ AVOID: Loading everything at once
# (harder to manage, harder to update)
chatgpt train mega everything.txt,all-docs.txt,more.txt

5. Reusable Templates

# Create session templates for common tasks
chatgpt code-review: you are an expert code reviewer
chatgpt code-review: focus on security, performance, readability  
chatgpt code-review: provide specific line-by-line feedback
chatgpt save code-review-template

# Load template for consistent reviews
chatgpt load code-review-template
code-review: [paste code]

6. Team Collaboration

# Share session files via version control
chatgpt save team-standards
# Commit: chatgpt-session-team-standards.json

# Team members load shared knowledge
chatgpt load team-standards

# Update and re-share
chatgpt train team-standards team-standards:,new-guidelines.txt
chatgpt save team-standards

7. Multi-Device Continuity

# On phone (morning)
chatgpt design: plan the user interface
chatgpt save design

# On PC (afternoon)
chatgpt load design
design: now implement the dashboard

# On Xbox (evening)
chatgpt load design  
design: refine the color scheme

Advanced Patterns

Pattern 1: Iterative Refinement

# Build knowledge through conversation
chatgpt research: what is quantum entanglement?
chatgpt research: explain bell's theorem
chatgpt research: how does this relate to quantum computing?
chatgpt research: summarize key insights

# Augment with documents
chatgpt train research research:,quantum-papers.txt

# Save comprehensive knowledge
chatgpt save research

# Use in analysis
chatgpt load research
research: analyze this quantum algorithm

Pattern 2: Multi-Perspective Analysis

# Same content, different sessions/services
link 2 1 chatgpt openai session: tech analyze technical feasibility
link 3 1 chatgpt claude session: legal identify legal risks
link 4 1 chatgpt gemini session: market assess market potential
link 5 2,3,4 chatgpt openai session: synthesis create comprehensive report

# Each session maintains focused context

Pattern 3: Continuous Learning

# Start with baseline
chatgpt train project baseline-docs.txt

# Process and learn
link 2 1 chatgpt openai session: project analyze
link 3 2 session project: train           # Add analysis to session
link 4 3 chatgpt openai session: project expand insights
link 5 4 session project: train           # Add expanded insights
link 6 5 session project: save            # Persist learned knowledge

# Next run loads richer session

Pattern 4: Quality Assurance Chain

# Multiple quality checks with shared context
newfile 7
files
file 1
filename code.js
file 2
filename syntax-check.txt
file 3
filename security-check.txt  
file 4
filename performance-check.txt
file 5
filename combined-report.txt
file 6
filename gate.txt
file 7
filename approved.txt

link 2 1 session qa: load
link 2 1 chatgpt openai session: qa check syntax
link 3 1 chatgpt openai session: qa check security
link 4 1 chatgpt openai session: qa check performance

link 5 2,3,4 chatgpt openai session: qa overall assessment
link 6 5 chatgpt openai if all pass output APPROVED else REJECTED
link 7 6 blocker

# Session accumulates all QA context
link 7 6 session qa: save

project save qa-chain

Troubleshooting

Session Not Found

# Check available sessions
chatgpt sessions

# Verify filename when loading
# Note: 'chatgpt-session-' prefix is automatic
chatgpt save myproject
# Creates: chatgpt-session-myproject.json
chatgpt load myproject    # ✅ Correct
chatgpt load chatgpt-session-myproject.json    # ❌ Wrong

Context Getting Confused

# Clear session and start fresh
chatgpt clear sessionname

# Or create new session
newsession: start with clean context

# Use separate sessions for different topics
coding: technical discussion
story: creative writing

Session Size Limits

# Check session sizes
chatgpt sessions

# Clear old unused sessions
chatgpt clear old-session-1
chatgpt clear old-session-2

# Prune long sessions before saving
# (manually review and save only important parts)

Session Not Persisting

# Ensure you save before closing browser
chatgpt save important-work

# Sessions in memory are lost on browser close
# Always save critical sessions to files

# Backup configuration includes sessions
csconfig → BL → Backup configuration to Local Download

Session Files Format

Individual Session File

{
  "session": [
    "First conversation entry",
    "Second conversation entry",
    "Third conversation entry"
  ],
  "size": 12345
}

All Sessions File

{
  "sessions": {
    "default": ["entry1", "entry2"],
    "coding": ["entry1", "entry2"],
    "story": ["entry1", "entry2"]
  },
  "totalSize": 67890
}

Integration with Other Features

With Transformers

Sessions work seamlessly with all transformers:

# Translate with context
link 2 1 chatgpt openai session: translate Japanese
link 3 1 chatgpt openai session: translate remember to maintain technical terms

# OCR with knowledge base
link 2 1 ocr
link 3 2 session medical: load
link 4 3 chatgpt openai session: medical interpret medical terminology

With Multi-Input Links

# Multi-input with shared session
link 4 1,2,3 chatgpt openai session: merge combine these perspectives
# Session sees all three inputs

With Quality Gates

# Session-aware gates
link 2 1 session standards: load
link 3 2 chatgpt openai session: standards meets requirements?
link 4 3 blocker

Summary

Sessions are a powerful feature enabling:

Context Persistence - AI remembers previous interactions

Knowledge Bases - Pre-train with domain expertise

Reusable Workflows - Save and share curated sessions

Multi-Turn Reasoning - Build complex arguments progressively

Team Collaboration - Share knowledge via session files

Cross-Device Continuity - Work seamlessly across devices

Key Takeaway: Sessions transform one-shot AI queries into stateful, context-aware workflows that learn and improve over time.

---

Remember:

  • Sessions live in browser memory (save to persist)
  • Use named sessions for organization
  • Train sessions to build knowledge bases
  • Save important sessions before closing browser
  • Share session files for team collaboration
  • Use separate sessions when switching AI services