Debug Mode
Debug mode enables verbose logging to help diagnose issues. It’s automatically enabled when running from source, or can be manually enabled in packaged builds.Enabling Debug Mode
To launch the packaged app with debug logging, use the--debug flag (note the double dash separator):
The double dash (
--) separates Electron’s args from the app’s args. The second --debug is passed to your application.Debug Mode Detection
Debug mode is automatically enabled in these scenarios:- Running from source (
bun run electron:startorelectron .) - Packaged app launched with
--debugflag
apps/electron/src/main/logger.ts:
Log File Locations
Log files are written to platform-specific directories when debug mode is enabled:~/Library/Logs/@craft-agent/electron/main.log%APPDATA%\@craft-agent\electron\logs\main.log~/.config/@craft-agent/electron/logs/main.logLog Format
Logs are written in JSON format for agent-parseability:Log Rotation
Log files automatically rotate when they exceed 5MB in size:Scoped Loggers
Craft Agents uses scoped loggers for different subsystems:Available Logger Scopes
Available Logger Scopes
- main - Main process lifecycle and general operations
- session - Session creation, persistence, and management
- ipc - Inter-process communication between main and renderer
- window - Window management and deep linking
- agent - Agent execution and tool calls
- search - Search indexing and queries
Common Issues
MCP Server Connection Failures
Symptom: Source shows as disconnected
Symptom: Source shows as disconnected
Possible Causes:View logs for the specific source at:
- Invalid command or path - Check that the MCP server command is correct
- Missing dependencies - Ensure all required packages are installed
- Credential issues - Verify credentials are set correctly
Sessions Not Persisting
Symptom: Session history is lost after restart
Symptom: Session history is lost after restart
Possible Causes:Sessions are written with a 500ms debounce. Check
- Disk write permissions - Check permissions on
~/.craft-agent/ - Persistence queue failure - Look for errors in logs
packages/shared/src/sessions/persistence-queue.ts for the queue implementation.OAuth Authentication Loops
Symptom: OAuth keeps redirecting without completing
Symptom: OAuth keeps redirecting without completing
Possible Causes:
- Redirect URI mismatch - OAuth app settings don’t match
craftagents://auth-callback - State parameter mismatch - Security token validation failing
- Redirect URI: Must be exactly
craftagents://auth-callback - Scopes: Ensure requested scopes are authorized
Tool Permission Errors
Symptom: Tools are blocked unexpectedly
Symptom: Tools are blocked unexpectedly
Possible Causes:Permission rules are defined in
- Permission mode is ‘safe’ - Read-only mode blocks write operations
- Custom permissions.json rules - Workspace or source has restrictive rules
- Check current permission mode (should show in UI)
- Press SHIFT+TAB to cycle through modes
- Review permission rules:
packages/shared/src/agent/permissions-config.ts.Configuration Not Updating
Symptom: Changes to config.json aren't reflected
Symptom: Changes to config.json aren't reflected
Possible Causes:The config validator is available as a session-scoped tool via
- Invalid JSON syntax - Parser silently fails on malformed JSON
- File watcher not running - Config watcher may have crashed
- Cache not cleared - In-memory config cache needs refresh
config_validate (see packages/session-tools-core/src/handlers/config-validate.ts).Large Response Timeouts
Symptom: Tool responses timeout or get truncated
Symptom: Tool responses timeout or get truncated
Explanation:Tool responses exceeding ~60KB are automatically summarized using Claude Haiku to prevent context overflow.Solution:This is expected behavior. The
_intent field is injected into MCP tool schemas to preserve summarization focus. See the implementation in packages/shared/src/agent/craft-agent.ts.To disable summarization for specific tools, adjust the threshold or implement custom handling.Development Debugging
Running in Development Mode
Development mode enables hot reload and full debugging:Inspecting IPC Communication
All IPC channels are defined inapps/electron/src/shared/types.ts. To debug IPC:
- Enable debug mode
- Check logs for
[ipc]scope entries - Look for request/response pairs
Renderer DevTools
Open Chrome DevTools in the renderer process:Memory Leaks
Profile memory usage in the main process:Environment Variables
OAuth integrations require credentials baked into the build:Google OAuth credentials are NOT baked into the build. Users provide their own credentials via source configuration.
Security Debugging
Credential Storage
Credentials are encrypted using AES-256-GCM:Local MCP Server Isolation
When spawning local MCP servers (stdio transport), sensitive environment variables are filtered to prevent credential leakage: Blocked variables:ANTHROPIC_API_KEY,CLAUDE_CODE_OAUTH_TOKENAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKENGITHUB_TOKEN,GH_TOKEN,OPENAI_API_KEY,GOOGLE_API_KEYSTRIPE_SECRET_KEY,NPM_TOKEN
env field in the source config.
Getting Help
If you’re still experiencing issues:- Check logs in the platform-specific directory
- Search existing issues on GitHub
- Report a bug with logs and reproduction steps
- Ask in Discord for community support
Related Files
Logger Implementation
View the logging code
Security Guidelines
Report security vulnerabilities