Status: ✅ Not a bug - working as designed
Explanation:
The system correctly shows that 19 files are saved in persistent storage but not yet loaded into the active session. The user needs to run /contextload to load them.
User Action Required:
aiwb
> /contextloadOr accept the resume prompt when starting AIWB.
Documentation Added:
/home/user/AIworkbench/docs/TROUBLESHOOTING_CONTEXT_AND_SWARM.md- Complete troubleshooting guide
Status: ✅ Fixed
Root Cause:
- Default
SWARM_MIN_TOKENS=1000was too high for test prompts - User's prompt "audit the app" (~15 tokens) < 1000 tokens
- Swarm correctly fell back to standard mode
- No visual indicators shown because swarm didn't activate
Fixes Applied:
- SWARM_MIN_TOKENS=1000 # Minimum tokens to activate swarm (lowered for easy testing)
+ SWARM_MIN_TOKENS=100 # Minimum tokens to activate swarm (very low for easy testing)Also updated config default:
- SWARM_MIN_TOKENS=$(config_get "swarm.min_tokens" "1000")
+ SWARM_MIN_TOKENS=$(config_get "swarm.min_tokens" "100")Impact: Swarm now activates on much smaller prompts, making testing easier.
none)
- echo "⚠ Context too small for swarm, using standard mode" >&2
- echo "DEBUG: Returning 1 to fall back to standard execution" >&2
+ echo "⚠ Prompt too small for swarm mode (estimated $tokens tokens < $SWARM_MIN_TOKENS threshold)" >&2
+ echo "💡 Tip: Use '/swarm' menu to enable Force mode or lower the threshold" >&2
+ echo "DEBUG: Returning 1 to fall back to standard execution" >&2
return 1
;;Also added token calculation in swarm_execute() to support the new message:
swarm_execute() {
local prompt="$1"
local mode="$2"
echo "" >&2
ui_header "🐝 Swarm Mode Execution" >&2
echo "" >&2
echo "DEBUG: swarm_execute called with mode=$mode" >&2
echo "DEBUG: Prompt length: ${#prompt} characters" >&2
+
+ # Calculate tokens for messaging
+ local tokens=$(estimate_tokens "$prompt")
+ echo "DEBUG: Estimated tokens: $tokens" >&2Impact: Users now get clear feedback about why swarm didn't activate and how to fix it.
- "100 tokens - Always activate (for testing)" \
- "1000 tokens - Low threshold ⭐ EASY TESTING" \
+ "100 tokens - Very low threshold ⭐ RECOMMENDED FOR TESTING" \
+ "1000 tokens - Low threshold" \
"5000 tokens - Medium threshold" \
- "10000 tokens - High threshold (default old)" \
+ "10000 tokens - High threshold (production)" \Impact: Menu now clearly recommends 100 tokens as the testing default.
- lib/swarm.sh
- Line 21: SWARM_MIN_TOKENS default changed from 1000 → 100
- Line 33: Config default changed from 1000 → 100
- Lines 320-322: Added token calculation in swarm_execute()
- Lines 345-347: Improved fallback error message
- Lines 250-253: Updated menu labels to recommend 100 tokens
-
docs/TROUBLESHOOTING_CONTEXT_AND_SWARM.md (NEW)
- Complete troubleshooting guide
- Step-by-step testing instructions
- Common issues and solutions
- Visual examples of swarm mode in action
- Quick reference card
-
ISSUE_ANALYSIS.md (NEW)
- Detailed technical analysis
- Root cause explanation
- Token estimation examples
- Swarm activation flow diagram
- Proposed fixes with rationale
-
FIXES_SUMMARY.md (THIS FILE)
- Summary of all changes
- Before/after comparisons
- Testing instructions
Before:
🐝 Swarm Mode Execution
DEBUG: swarm_execute called with mode=make
DEBUG: Prompt length: 15 characters
Strategy: none
⚠ Context too small for swarm, using standard mode
[Falls back to standard mode - no visual indicators]
After:
🐝 Swarm Mode Execution
DEBUG: swarm_execute called with mode=make
DEBUG: Prompt length: 15 characters
DEBUG: Estimated tokens: 15
Strategy: none
⚠ Prompt too small for swarm mode (estimated 15 tokens < 100 threshold)
💡 Tip: Use '/swarm' menu to enable Force mode or lower the threshold
[Falls back to standard mode with helpful tip]
OR if user enables Force mode:
🐝 Swarm Mode Execution
Strategy: mapreduce
━━━ Phase 1: Parallel Processing ━━━
🤖 Worker 1: Processing...
✓ Worker 1: Complete
━━━ Phase 2: Aggregation ━━━
🧠 Aggregating with claude...
✓ Phase 2 complete
[Shows all visual indicators even for small prompt]
Before (threshold=1000):
⚠ Context too small for swarm, using standard mode
[Falls back - no swarm]
After (threshold=100):
🐝 Swarm Mode Execution
DEBUG: Estimated tokens: 523
Strategy: mapreduce
━━━ Phase 1: Parallel Processing ━━━
Processing 2 chunks with 5 parallel workers
🤖 Worker 1: Processing...
🤖 Worker 2: Processing...
✓ Worker 1: Complete
✓ Worker 2: Complete
━━━ Phase 2: Aggregation ━━━
✓ Phase 2 complete
[Swarm activates and shows visual indicators]
# 1. Start AIWB
aiwb
# 2. Load context (if you have saved files)
> /contextload
# 3. Enable swarm with new default
> /swarm
# Select: "Toggle swarm mode ON/OFF" (if disabled)
# Select: "Set minimum token threshold"
# Select: "100 tokens - Very low threshold ⭐ RECOMMENDED FOR TESTING"
# 4. Test with small prompt
> /make
> hello world
# Expected: Swarm activates (100 tokens default) OR shows helpful message> /swarm
# Select: "Set minimum token threshold"
# Select: "Force swarm mode (ignore token count)"
> /make
> test
# Expected: Swarm activates with visual indicators regardless of prompt size# 1. Load context to create large prompt
> /contextload # If you have 19 saved files
# 2. Enable swarm with 100 token threshold
> /swarm
# Enable swarm, set to 100 tokens
# 3. Ask complex question
> /make
> analyze all files and suggest improvements
# Expected: Large prompt (files + question) naturally triggers swarm
# Shows Phase 1 with multiple workers, Phase 2 with aggregation✅ Easier Testing: Swarm mode now activates on smaller prompts (100 vs 1000 tokens) ✅ Better Feedback: Clear error messages explain why swarm didn't activate ✅ Clearer UI: Menu labels indicate recommended settings ✅ Complete Docs: Troubleshooting guide covers common scenarios
However, users who want the new 100-token default should either:
- Delete
~/.aiwb/config.jsonto regenerate with new defaults - Or manually update via
/swarmmenu to select "100 tokens - Very low threshold"
✅ Code Changes
- SWARM_MIN_TOKENS default changed: 1000 → 100
- Config default changed: 1000 → 100
- Token calculation added to swarm_execute()
- Improved fallback error message
- Updated menu labels
✅ Documentation
- Created TROUBLESHOOTING_CONTEXT_AND_SWARM.md
- Created ISSUE_ANALYSIS.md
- Created FIXES_SUMMARY.md (this file)
✅ Testing Scenarios Covered in Docs
- Context persistence explained
- Swarm activation with small prompts
- Swarm activation with large prompts
- Force mode testing
- Natural activation with context loaded
- Common mistakes and fixes
This work builds on recent improvements:
2e4cbda- Lower swarm activation threshold for easy testing91ddb83- Add easy swarm testing guidef542fa6- Add visual indicators and integrate swarm mode into chat
-
Update your local copy:
cd /home/user/AIworkbench git pull origin claude/fix-context-swarm-mode-QTprT -
Load your saved context:
aiwb > /contextload -
Test swarm mode:
> /swarm # Enable swarm, set to 100 tokens or force mode > /make > [any prompt]
If you want to ensure swarm config persists, verify config file exists:
cat ~/.aiwb/config.jsonIf it doesn't exist or swarm section is missing, create/update it:
# Via UI (recommended):
aiwb
> /swarm
# Configure as desired - settings auto-save to config.json
# Or manually:
# Edit ~/.aiwb/config.json to include swarm sectionIf you encounter issues after applying these fixes:
-
Check the troubleshooting guide:
less docs/TROUBLESHOOTING_CONTEXT_AND_SWARM.md
-
Enable debug mode and check output:
# Look for DEBUG: lines in swarm output -
Verify swarm library is loaded:
echo $AIWB_LIB_SWARM_LOADED # Should output: true
-
Check issue analysis for technical details:
less ISSUE_ANALYSIS.md
- ✅ Lowered swarm activation threshold from 1000 to 100 tokens (10x easier to trigger)
- ✅ Added helpful error messages with specific token counts and tips
- ✅ Updated menu to recommend 100 tokens for testing
- ✅ Created comprehensive troubleshooting documentation
- ✅ Context persistence is working correctly - just needs
/contextload - ✅ Swarm mode requires minimum token threshold or force mode
- ✅ Visual indicators only show when swarm actually activates
- ✅ Best practice: Load context + enable swarm for optimal experience
Quick Fix for Both Issues:
aiwb
> /contextload # Fix "Context: none" - loads your 19 files
> /swarm # Enable swarm mode
> Set threshold → 100 tokens # Or force mode for testing
> /make # Now swarm visual indicators work!
> [your prompt] # 🐝 Phase 1/2 with worker emojis appearThe system is now much more user-friendly for testing and demonstrates swarm mode behavior clearly! 🎉