| 107 | } |
| 108 | |
| 109 | function getDebugExecutionPrompt(args: Record<string, string> | undefined): GetPromptResult { |
| 110 | const notebookPath = args?.notebook_path || 'notebook.deepnote' |
| 111 | const executionId = args?.execution_id |
| 112 | const errorMessage = args?.error_message |
| 113 | |
| 114 | return { |
| 115 | description: 'Debug notebook execution using snapshots', |
| 116 | messages: [ |
| 117 | { |
| 118 | role: 'user', |
| 119 | content: { |
| 120 | type: 'text', |
| 121 | text: `Debug the notebook execution for: ${notebookPath} |
| 122 | ${executionId ? `Execution ID: ${executionId}` : ''} |
| 123 | ${errorMessage ? `Error message: ${errorMessage}` : ''} |
| 124 | |
| 125 | ## Understanding Outputs |
| 126 | |
| 127 | **All execution outputs are saved to snapshot files.** After running a notebook: |
| 128 | 1. The response includes \`snapshotPath\` - this is where all results live |
| 129 | 2. Use \`${TOOL_NAMES.snapshotLoad}\` to inspect outputs |
| 130 | |
| 131 | ## Debugging Workflow |
| 132 | |
| 133 | ### Step 1: Run the notebook |
| 134 | \`\`\` |
| 135 | ${TOOL_NAMES.run} path="${notebookPath}" |
| 136 | \`\`\` |
| 137 | |
| 138 | The response will include: |
| 139 | - \`snapshotPath\`: Path to saved outputs (e.g., "snapshots/notebook_uuid_latest.snapshot.deepnote") |
| 140 | - \`executedBlocks\`, \`failedBlocks\`: Execution summary |
| 141 | - \`results\`: Per-block success/failure info |
| 142 | |
| 143 | ### Step 2: Inspect the snapshot |
| 144 | \`\`\` |
| 145 | ${TOOL_NAMES.snapshotLoad} path="<snapshotPath from step 1>" |
| 146 | \`\`\` |
| 147 | |
| 148 | The snapshot contains: |
| 149 | - **Block outputs**: stdout, return values, charts |
| 150 | - **Errors**: Full tracebacks for failed blocks |
| 151 | - **Timing**: When execution started/finished |
| 152 | - **Execution counts**: Order blocks ran |
| 153 | |
| 154 | ### Step 3: Debug issues |
| 155 | If blocks failed: |
| 156 | 1. Check error messages in the snapshot |
| 157 | 2. Use \`${TOOL_NAMES.cat} path="${notebookPath}" blockId="<failed-block-id>"\` to see the code |
| 158 | 3. Fix the issue with \`${TOOL_NAMES.editBlock}\` |
| 159 | 4. Re-run and compare snapshots |
| 160 | |
| 161 | ### Step 4: Compare runs |
| 162 | Each run creates a new snapshot. Use \`${TOOL_NAMES.snapshotList}\` to see history and compare outputs between runs. |
| 163 | |
| 164 | ## Key Tools |
| 165 | |
| 166 | | Tool | Purpose | |