Editing a Notebook Workbook: Code Sheet & AI Handshake
This section documents the internal structure of the hidden _BOARDFLARE worksheet and the protocol AI agents must use to inspect, modify, and verify notebook code.
The AI Edit Loop Handshake
When an AI assistant (such as ChatGPT, Copilot, or Claude inside Excel) modifies a workbook, it communicates with the Boardflare add-in via the request counter (H1) and the response JSON (H2):
AI Agent Boardflare Add-in
│ │
├─ 1. Edit code rows in Column A / H9 │
├─ 2. Increment H1 (e.g. 0 -> 1) │
│ ├─ 3. Detects request change
│ ├─ 4. Sets H2 status="running"
│ ├─ 5. Reloads and runs notebook
│ ├─ 6. Writes final response JSON to H2
│◄─ 7. Polls H2 until status!="running" ──────────────┤
│ │
▼ ▼
Verify status: "ok" or fix errors
Handshake Protocol Steps
- Diagnose First: When a user reports an issue, do not blindly edit code. First, add 1 to the integer in
_BOARDFLARE!H1and read_BOARDFLARE!H2to inspect any existing errors and traceback. - Apply Edits:
- To update an existing cell: update the corresponding row in Column A (
A3:A<last>). - To add a new cell: append it to the next empty row in Column A.
- To change notebook width or app settings: update the header text in cell
H9.
- To update an existing cell: update the corresponding row in Column A (
- Signal Reload: As your last action, increment the integer in
_BOARDFLARE!H1by 1. - Wait for Settlement:
- Read
_BOARDFLARE!H2. Because Office.js environments may lacksetTimeout, pollH2with short successive reads untilrequestequals the integer in H1 andstatusis not"running". Allow up to the AI edit settle timeout in System Limits.
- Read
- Evaluate Response:
status: "ok": The notebook compiled and ran all cells without uncaught Python exceptions.status: "errors": One or more cells failed. Inspect theerrorsarray in the JSON response, address the issue, and repeat. Stop after at most two fix attempts.
Response JSON Schema (cell H2)
Cell H2 contains a JSON string with the following fields:
{
"request": 1,
"status": "ok",
"time": "2026-10-02T21:00:00.000Z",
"errors": [
{
"cell": "A5",
"type": "ValueError",
"message": "Unsupported driver: Units sold",
"traceback": "Traceback (most recent call last):\n..."
}
],
"note": "All cells ran without errors."
}request(integer): The request counter value (H1) this response answers.status("running"|"ok"|"errors"): Current execution state.time(string): ISO 8601 timestamp.errors(array): List of error objects containing:cell: Cell address (e.g."A5","H9", or"(notebook)").type: Exception class (e.g."ValueError","LayoutError","FormatVersionError","StartupError").message: Truncated error message (capped at 1,000 characters).traceback: Truncated traceback (capped at 4,000 characters).
note(string): Summary message.
What a Request Does
Every request reloads the notebook from the code sheet, waits until the new session reports that nothing is running or queued (up to the AI edit settle timeout in System Limits), and answers with the same request number. Cells Marimo cannot parse appear in errors as SyntaxError entries, because Marimo never runs them. A ModuleNotFoundError for a cell includes a pointer to the package list. If the notebook is still running when the wait ends, status is "errors" and note says it did not finish in time.
Response Truncation Caps
To ensure the response JSON fits inside Excel’s single-cell limit (32,767 characters): - Total response payload is capped at 32,000 characters. - If tracebacks exceed the limit, tracebacks are shortened to 300 characters each. - If the payload still exceeds 32,000 characters, trailing errors are omitted, and note indicates: Tracebacks were shortened and X of Y errors were left out to fit the cell limit.
Editing via Office.js vs. OpenPyXL
Office.js (Within Excel)
- Read and write
_BOARDFLARE!A3:A<last>using standardrange.values. - Ensure range formats are text (
@) so code is not parsed as formulas. - Read
_BOARDFLARE!H1, write back its integer plus 1, then poll_BOARDFLARE!H2until itsrequestequals the new H1 value andstatusis not"running".
OpenPyXL (External File Modification)
- Load the workbook with
openpyxl.load_workbook(filename). - Access the
_BOARDFLAREworksheet. - Modify column A and/or cell
H9. - Save the workbook. The next time the workbook is opened in Excel with Boardflare installed, the add-in automatically detects the changed source, updates its caches, and runs the notebook.
- Note: OpenPyXL may discard non-standard Excel parts such as certain embedded controls or drawing artifacts.
Uploading and Importing Python Scripts
The add-in task pane allows uploading local .py Marimo notebook files: - File extension: Must be a .py file. - Encoding: Must be valid UTF-8 encoded text. - Content: Must be non-empty (cannot contain only whitespace). - Size limit: Total file size must not exceed the 200,000-byte workbook storage limit.