This adapter enables Paperclip agents to use Bob Shell as their execution runtime.
The bob_shell adapter integrates Bob Shell into Paperclip's control plane by:
- Workspace Materialization - Generates
.bob/configuration before launching Bob Shell - MCP Integration - Connects Bob Shell back to Paperclip via the Paperclip MCP server
- Skill Projection - Renders company skills as Bob Shell instruction files
- Lifecycle Management - Handles Bob Shell process invocation, monitoring, and cancellation
- Prompt Caching - Content-addressed prompt bundles for faster execution
- Error Handling - Intelligent error classification and retry logic
Paperclip Agent (bob_shell)
↓
Prompt Bundle Cache (content-addressed)
↓
Workspace Sync (.bob/ generation)
↓
Bob Shell Process Launch
↓
Bob Shell ← MCP → Paperclip API
The adapter uses content-addressed prompt bundles to avoid redundant workspace sync:
- Content Hashing: Bundles are keyed by hash of skills, instructions, and mode config
- Cache Reuse: Identical configurations reuse existing bundles
- Fast Startup: Cached bundles skip workspace sync entirely
- Automatic Cleanup: Old bundles can be cleaned up via cache management
Intelligent error handling with automatic retry:
- Error Types: Session, API, Config, Execution, Timeout, Unknown
- Retry Strategy: Exponential backoff for retryable errors
- Session Recovery: Automatic retry with fresh session on session errors
- Detailed Logging: Clear error messages with hints and context
Configurable Options:
maxRetries(default: 2) - Maximum retry attemptsretryDelayMs(default: 1000) - Base delay between retries (exponential backoff)
Support for bootstrap prompts on new sessions:
- New Sessions Only: Bootstrap prompt included only when starting fresh
- Template Support: Use
bootstrapPromptTemplateconfig field - Metrics Tracking: Separate metrics for bootstrap vs heartbeat prompts
Real-time status updates during execution:
- Incremental Parsing: Parses stdout as it arrives
- Rich Metadata: Includes session ID, model, tokens, cost
- Live Dashboard: Updates visible on Paperclip board
- Final Result: Extracted from
<attempt_completion>tags
When a Bob Shell agent runs, Paperclip generates:
Defines the paperclip-agent mode with:
- Role definition
- Custom instructions
- Tool groups (read, edit, command, browser, mcp)
Configures the Paperclip MCP server connection with runtime environment variables:
PAPERCLIP_API_URLPAPERCLIP_API_KEYPAPERCLIP_COMPANY_IDPAPERCLIP_AGENT_IDPAPERCLIP_RUN_ID
Instruction files including:
01-core.md- Core Paperclip agent rules02-repo.md- Repository context guidance03-tasking.md- Task workflow rules04+- Company skill projections
{
command: string; // Bob Shell executable (default: "bob")
mode: string; // Bob Shell mode (default: "paperclip-agent")
cwd: string; // Working directory
model: string; // AI model to use
extraArgs: string[]; // Additional CLI arguments
env: Record<string, EnvBinding>; // Environment variables
timeoutSec: number; // Run timeout (0 = no timeout)
graceSec: number; // SIGTERM grace period before SIGKILL
promptTemplate: string; // Heartbeat prompt template
bootstrapPromptTemplate: string; // Bootstrap prompt for new sessions
maxRetries: number; // Maximum retry attempts (default: 2)
retryDelayMs: number; // Base retry delay in ms (default: 1000)
modeConfig: object; // Custom mode configuration
instructionsFilePath: string; // Path to agent instructions file
}{
"adapterType": "bob_shell",
"adapterConfig": {
"command": "bob",
"mode": "paperclip-agent",
"cwd": "/path/to/workspace",
"model": "claude-3-5-sonnet-20241022",
"timeoutSec": 1800,
"graceSec": 20,
"maxRetries": 2,
"retryDelayMs": 1000,
"bootstrapPromptTemplate": "You are {{agent.name}}. Initialize your workspace and review the task.",
"promptTemplate": "Continue working on your assigned task."
}
}The adapter classifies errors into categories:
| Type | Code | Retryable | Description |
|---|---|---|---|
session |
session_not_found, session_expired, session_corrupted |
✅ Yes | Session-related errors |
api |
api_rate_limit, api_timeout, api_server_error |
✅ Yes | API errors (rate limits, timeouts, 5xx) |
config |
auth_invalid, auth_required, config_invalid |
❌ No | Configuration errors |
execution |
tool_error, user_cancelled, execution_error, max_turns |
❌ No | Execution failures |
timeout |
timeout |
❌ No | Process timeout |
unknown |
unknown |
❌ No | Unclassified errors |
- Retryable Errors: Automatically retried with exponential backoff
- Session Errors: Retry with fresh session
- API Errors: Retry with same session after delay
- Non-Retryable: Fail immediately with detailed error message
Session error - will retry with new session (session error) - retryable
Hint: Session may have expired or been deleted
API rate limit exceeded (api error) - retryable
Hint: Wait before retrying
Details: Error: Rate limit exceeded. Please try again in 60 seconds.
Authentication required (config error)
Hint: Check API key configuration
Details: Error: Invalid API key provided
- Content Hashing: Calculate hash of skills, instructions, mode config
- Bundle Key: Generate unique key from content hash
- Cache Check: Look for existing bundle in cache directory
- Cache Hit: Reuse existing bundle (skip workspace sync)
- Cache Miss: Create new bundle and sync workspace
~/.paperclip/instances/{instance_id}/companies/{company_id}/bob-prompt-cache/{bundle_key}/
- Faster Startup: Skip workspace sync on cache hit
- Consistent Builds: Same input always produces same bundle
- Disk Efficiency: Shared bundles across runs
- Version Control Friendly: Deterministic generation
# View cache size
du -sh ~/.paperclip/instances/default/companies/*/bob-prompt-cache
# Clean old bundles (manual)
find ~/.paperclip/instances/default/companies/*/bob-prompt-cache \
-type d -mtime +30 -exec rm -rf {} +- Bob Shell must be installed and available in PATH or via configured command
- Paperclip MCP server must be accessible
- Valid Paperclip API credentials
Paperclip manages only its own entries:
- Managed:
paperclip-agentmode,paperclipMCP server,rules-paperclip-agent/directory - Preserved: User-defined modes, other MCP servers, unrelated
.bob/files
Same input (skills + config) produces same .bob/ output, enabling:
- Reproducible builds
- Version control friendly
- Predictable behavior
pnpm install
pnpm typecheck# Run unit tests
pnpm vitest run packages/adapters/bob-shell/src/server/__tests__/
# Run specific test file
pnpm vitest run packages/adapters/bob-shell/src/server/__tests__/error-classification.test.ts
# Type check
cd packages/adapters/bob-shell && pnpm typecheckThe adapter can also be tested via Paperclip's adapter test environment:
# In Paperclip UI
Settings → Agents → [Agent] → Test EnvironmentError: Command not found: bob
Solution: Ensure Bob Shell is installed and in PATH, or configure absolute path in command field.
Error: Bob Shell cannot connect to Paperclip MCP server
Solution:
- Verify
PAPERCLIP_API_URLis accessible from Bob Shell process - Check
PAPERCLIP_API_KEYis valid - Ensure Paperclip MCP server is running
Error: .bob/ files not generated or incorrect
Solution:
- Check agent has write permissions to workspace directory
- Verify company skills are properly configured
- Review Paperclip logs for sync errors
Error: Retries exhausted, task still failing
Solution:
- Check error classification in logs
- Verify error is actually retryable
- Increase
maxRetriesif needed - Check for underlying issues (API keys, network, etc.)
Error: Prompt bundle cache not working
Solution:
- Check write permissions to cache directory
- Verify cache directory exists:
~/.paperclip/instances/default/companies/{company_id}/bob-prompt-cache - Review logs for cache-related errors
- Clear cache and retry
- API keys are injected via environment variables, not written to disk
- Secrets should be managed through Paperclip's secret store
- Bob Shell runs with same permissions as Paperclip server process
- Prompt bundles may contain sensitive instructions - cache directory should be protected
The adapter includes session management infrastructure:
- Session Resume Support: Adapter checks for existing sessions and attempts to resume
- Session Validation: Validates session compatibility (working directory and prompt bundle must match)
- Retry Logic: Automatically retries with fresh session if resume fails
- Session Clearing: Clears invalid sessions to prevent accumulation
1. Check runtime.sessionParams for existing session
2. Validate session is compatible with current working directory and prompt bundle
3. Pass --resume-session <id> to Bob Shell (when supported)
4. On session error, retry with fresh session
5. Store new session ID in result for next runThe adapter is ready to use sessions once Bob Shell implements:
--resume-session <id>CLI flag- Session ID output in stdout
- Session error detection and reporting
- Bob Shell must support the configured mode (default:
paperclip-agent) - Session persistence requires Bob Shell implementation (infrastructure ready)
- Usage tracking and cost calculation require Bob Shell output format enhancements
- Prompt bundle cache grows over time (manual cleanup required)
- Automatic cache cleanup (LRU eviction)
- Usage tracking and cost calculation (waiting for Bob Shell output format)
- Model detection and reporting (waiting for Bob Shell output format)
- Incremental workspace sync (only update changed files)
- Bob Shell version detection and compatibility checks
- Advanced workspace strategies (git worktrees, containers)
- JSON stream parsing (when Bob Shell supports it)
- ✅ Enhanced error classification with 6 error types
- ✅ Intelligent retry logic with exponential backoff
- ✅ Configurable retry attempts and delays
- ✅ Detailed error messages with hints
- ✅ Comprehensive test suite (23 tests)
- ✅ Full TypeScript type safety
See doc/bob-shell-adapter-phase1-complete.md for details.
- ✅ Prompt bundle caching system
- ✅ Bootstrap prompt support
- ✅ Content-addressed bundles
- 🔄 Performance benchmarks (pending)
- 🔄 Cache cleanup utilities (pending)
See docs/SETUP.md for end-to-end installation, agent configuration, and troubleshooting.