Skip to content

feat(pair): add an agent-facing CLI for live notebook sessions - #10777

Merged
kirangadhave merged 7 commits into
mainfrom
kg/pair-cli-execute
Sep 16, 2026
Merged

kirangadhave merged 7 commits into
mainfrom
kg/pair-cli-execute

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Sep 9, 2026

Copy link
Copy Markdown
Member

📝 Summary

Add marimo pair, a small CLI that lets a coding agent work inside a live notebook session. pair execute runs Python through the existing scratchpad endpoint and prints one JSON result by default, with --stream to write output as it arrives. Every failure returns the same JSON shape with a next field that holds a filled-in recovery command, so an agent that hits a stale session, a missing session, or a kernel error knows the one thing to run next. Interrupted or malformed responses report "outcome unknown" and tell the agent to inspect rather than retry.

pair notebook list finds live sessions from the local server registry or from --url, grouped by notebook, in the same shape as mo notebook list. pair docs exposes the bundled notebook guidance offline. pair prompt and the Pair with an agent modal generate a help-first bootstrap that includes the current session. The --help text is a copyable procedure written for agents: it prefers Code Mode for every mutation, including package installs through ctx.packages.add, and its wording follows the marimo-pair skill.

Removes the skill-detection warning from pair prompt, since the CLI is now the agent's entry point and the flags stay as hidden no-ops. Tokens never appear in arguments or prompt text; the CLI reads MARIMO_TOKEN or --token-file. Adds client, CLI, frontend, and live-server coverage.

Closes MO-7667

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
marimo-docs Ready Ready Preview Sep 16, 2026 10:10pm UTC

Request Review

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 103.28kB (-0.39%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 26.43MB -103.28kB (-0.39%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 695.35kB 1.33MB 109.19% ⚠️
assets/edit-*.js -768 bytes 439.66kB -0.17%
assets/index-*.css 2.66kB 380.83kB 0.7%
assets/RunButton-*.js -533 bytes 366.85kB -0.15%
assets/ai-*.js 475 bytes 315.86kB 0.15%
assets/panels-*.js -561 bytes 267.74kB -0.21%
assets/glide-*.js 4.3kB 262.11kB 1.67%
assets/reveal-*.js -178 bytes 257.77kB -0.07%
assets/dependency-*.js 1.01kB 162.35kB 0.63%
assets/agent-*.js -330 bytes 153.65kB -0.21%
assets/add-*.js -222 bytes 149.54kB -0.15%
assets/ConnectedDataExplorerComponent-*.js -146 bytes 134.73kB -0.11%
assets/swiper-*.js -15 bytes 116.58kB -0.01%
assets/file-*.js -333 bytes 78.44kB -0.42%
assets/file-*.js -51 bytes 113.06kB -0.05%
assets/file-*.js (Deleted) -805 bytes 0 bytes -100.0% 🗑️
assets/mermaid-*.js -6 bytes 92.25kB -0.01%
assets/chat-*.js -173 bytes 37.4kB -0.46%
assets/chat-*.js -159 bytes 16.23kB -0.97%
assets/chat-*.js -115 bytes 15.05kB -0.76%
assets/dagre-*.js -31 bytes 32.96kB -0.09%
assets/session-*.js -136 bytes 27.32kB -0.5%
assets/home-*.js -183 bytes 18.41kB -0.98%
assets/packages-*.js -106 bytes 17.72kB -0.59%
assets/common-*.js -3 bytes 2.61kB -0.11%
assets/vega-*.js -170 bytes 13.9kB -1.21%
assets/vega-*.js 1 bytes 595 bytes 0.17%
assets/graphlib-*.js 3 bytes 12.64kB 0.02%
assets/alert-*.js (Deleted) -1.96kB 0 bytes -100.0% 🗑️
assets/tracing-*.js -90 bytes 11.37kB -0.79%
assets/tracing-*.js -1 bytes 819 bytes -0.12%
assets/app-*.js -38 bytes 11.26kB -0.34%
assets/run-*.js -235 bytes 10.4kB -2.21%
assets/useCellActionButton-*.js -138 bytes 9.08kB -1.5%
assets/snippets-*.js -136 bytes 7.28kB -1.83%
assets/scratchpad-*.js -130 bytes 7.03kB -1.82%
assets/utils-*.js (Deleted) -303 bytes 0 bytes -100.0% 🗑️
assets/components-*.js -81 bytes 5.68kB -1.41%
assets/cache-*.js -38 bytes 5.5kB -0.69%
assets/gallery-*.js -40 bytes 4.54kB -0.87%
assets/secrets-*.js -126 bytes 4.25kB -2.88%
assets/_baseMerge-*.js 7 bytes 3.18kB 0.22%
assets/logs-*.js -3 bytes 2.87kB -0.1%
assets/any-*.js -39 bytes 1.92kB -1.99%
assets/error-*.js -47 bytes 1.74kB -2.64%
assets/error-*.js (Deleted) -2.94kB 0 bytes -100.0% 🗑️
assets/documentation-*.js -4 bytes 899 bytes -0.44%
assets/state-*.js (Deleted) -808 bytes 0 bytes -100.0% 🗑️
assets/has-*.js -2 bytes 179 bytes -1.1%
assets/JsonOutput-*.js (Deleted) -581.38kB 0 bytes -100.0% 🗑️
assets/dates-*.js (Deleted) -38.6kB 0 bytes -100.0% 🗑️
assets/MarimoErrorOutput-*.js (Deleted) -30.48kB 0 bytes -100.0% 🗑️
assets/react-*.browser.esm-BL2E7f5c.js (Deleted) -25.58kB 0 bytes -100.0% 🗑️
assets/VisuallyHidden-*.js (Deleted) -18.2kB 0 bytes -100.0% 🗑️
assets/html-*.js (Deleted) -14.36kB 0 bytes -100.0% 🗑️
assets/switch-*.js (Deleted) -10.9kB 0 bytes -100.0% 🗑️
assets/download-*.js (Deleted) -9.07kB 0 bytes -100.0% 🗑️
assets/react-*.esm-C6SMwKZH.js (Deleted) -8.38kB 0 bytes -100.0% 🗑️
assets/en-*.js (Deleted) -7.24kB 0 bytes -100.0% 🗑️
assets/RenderHTML-*.js (Deleted) -6.3kB 0 bytes -100.0% 🗑️
assets/markdown-*.js (Deleted) -5.2kB 0 bytes -100.0% 🗑️
assets/tabs-*.js (Deleted) -4.88kB 0 bytes -100.0% 🗑️
assets/datasource-*.js (Deleted) -4.71kB 0 bytes -100.0% 🗑️
assets/emotion-*.esm-nLO-SoUf.js (Deleted) -4.37kB 0 bytes -100.0% 🗑️
assets/useInstallPackage-*.js (Deleted) -3.74kB 0 bytes -100.0% 🗑️
assets/table-*.js (Deleted) -608 bytes 0 bytes -100.0% 🗑️
assets/table-*.js (Deleted) -3.37kB 0 bytes -100.0% 🗑️
assets/tree-*.js (Deleted) -3.06kB 0 bytes -100.0% 🗑️
assets/cell-*.js (Deleted) -2.98kB 0 bytes -100.0% 🗑️
assets/useDateFormatter-*.js (Deleted) -2.72kB 0 bytes -100.0% 🗑️
assets/JsonOutput-*.css (Deleted) -1.32kB 0 bytes -100.0% 🗑️
assets/useRunCells-*.js (Deleted) -1.28kB 0 bytes -100.0% 🗑️
assets/spinner-*.js (Deleted) -1.04kB 0 bytes -100.0% 🗑️
assets/markdown-*.css (Deleted) -613 bytes 0 bytes -100.0% 🗑️
assets/eye-*.js (Deleted) -612 bytes 0 bytes -100.0% 🗑️
assets/hasIn-*.js (Deleted) -567 bytes 0 bytes -100.0% 🗑️
assets/kbd-*.js (Deleted) -529 bytes 0 bytes -100.0% 🗑️
assets/_baseSet-*.js (Deleted) -484 bytes 0 bytes -100.0% 🗑️
assets/_hasPath-*.js (Deleted) -322 bytes 0 bytes -100.0% 🗑️
assets/refresh-*.js (Deleted) -321 bytes 0 bytes -100.0% 🗑️
assets/formats-*.js (Deleted) -264 bytes 0 bytes -100.0% 🗑️
assets/external-*.js (Deleted) -251 bytes 0 bytes -100.0% 🗑️
assets/message-*.js (Deleted) -241 bytes 0 bytes -100.0% 🗑️
assets/extends-*.js (Deleted) -231 bytes 0 bytes -100.0% 🗑️
assets/isValid-*.js (Deleted) -231 bytes 0 bytes -100.0% 🗑️
assets/useIframeCapabilities-*.js (Deleted) -228 bytes 0 bytes -100.0% 🗑️
assets/ellipsis-*.js (Deleted) -226 bytes 0 bytes -100.0% 🗑️

Files in assets/edit-*.js:

  • ./src/components/editor/actions/pair-with-agent-commands.ts → Total Size: 2.16kB

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 58.3% 22202 / 38082
🔵 Statements 58.23% 22591 / 38793
🔵 Functions 51.42% 5013 / 9749
🔵 Branches 51.94% 11669 / 22465
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/components/editor/actions/pair-with-agent-commands.ts 95.65% 94.44% 100% 95.65% 66
frontend/src/components/editor/actions/pair-with-agent-modal.tsx 10% 0% 0% 10.34% 34-45, 51-119, 155-163, 171-218
Generated in workflow #21532 for commit dbc2047 by the Vitest Coverage Report Action

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread marimo/_cli/pair/client.py Outdated
Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread marimo/_cli/pair/client.py Outdated
Comment thread frontend/src/components/editor/actions/pair-with-agent-commands.ts Outdated
Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread frontend/src/components/editor/actions/pair-with-agent-commands.ts Outdated
Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread tests/_cli/_pair_server.py
Comment thread tests/_cli/_pair_server.py
@kirangadhave
kirangadhave added this pull request to stack #10779 September 9, 2026 22:07
@kirangadhave
kirangadhave requested a lite review from Copilot September 9, 2026 22:07
@kirangadhave kirangadhave added the enhancement New feature or request label Sep 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved URL construction, production bootstrap prompt, and Windows integration-test issues block approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds live notebook execution, offline docs, and session-aware agent prompts to marimo pair.

Changes:

  • Added streaming pair execute and offline pair docs commands.
  • Added credential handling and session-aware prompts.
  • Added CLI, client, frontend, and integration tests.
File summaries
File Reviewed changes
tests/_cli/test_pair_integration.py Live execution coverage; Moderate (2 votes): select.select on pipes is not Windows-compatible.
tests/_cli/test_pair_client.py Client behavior and streaming tests.
tests/_cli/test_cli_pair.py CLI command coverage.
tests/_cli/fixtures/pair/execute-success.sse Successful execution SSE fixture.
tests/_cli/fixtures/pair/execute-failure.sse Failed execution SSE fixture.
tests/_cli/_pair_server.py Integration server fixture.
marimo/_cli/pair/commands.py Execute, docs, and prompt commands; Moderate (2 votes): prompt hardcodes uv run marimo in installed environments.
marimo/_cli/pair/client.py HTTP/SSE execution client; Critical (3 votes): endpoint construction breaks URLs containing query parameters.
frontend/src/components/editor/actions/pair-with-agent-modal.tsx Session-aware pairing modal.
frontend/src/components/editor/actions/pair-with-agent-commands.ts Agent command generation; Moderate (3 votes): production prompt incorrectly directs agents to run uv run marimo.
frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts Frontend command-generation tests.
Review details

Suppressed comments (1)

marimo/_cli/pair/client.py:173

  • A truncated chunked HTTP response from http.client can raise http.client.IncompleteRead, which is an HTTPException, not an OSError. That exception bypasses this handler and produces a traceback instead of the promised PairError/exit status 1 for an unconfirmed execution; include the HTTP client exception type in the connection-read handling.
        except OSError as error:
            write_buffered_output()
            raise PairError(
                "The execution response ended before completion was confirmed."
            ) from error
  • Files reviewed: 11/11 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread marimo/_cli/pair/client.py Outdated
Comment thread frontend/src/components/editor/actions/pair-with-agent-commands.ts Outdated
Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread tests/_cli/test_pair_integration.py
Comment thread frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts Outdated
Comment thread marimo/_cli/pair/commands.py
manzt
manzt previously approved these changes Sep 11, 2026
Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread tests/_cli/test_pair_integration.py
manzt

This comment was marked as outdated.

Stream scratchpad execution over SSE, list sessions, resolve a session from a
notebook path, and read server URLs from the local registry. Tokens travel in
headers only, and every server response is validated before use.
execute runs Python in a live kernel and prints one JSON result, or one JSON
failure with a next step an agent can run. notebook list finds servers and
sessions. --help is a copyable procedure. prompt no longer checks for an
installed skill, because the CLI replaces it.
…modal

The Pair with an agent modal emits the marimo pair --help bootstrap with the
server URL and current session id. The prompt never contains the token.
Start a real marimo server in a subprocess and run the CLI against it, so the
streaming, cancellation, and failure paths are checked end to end.
@kirangadhave
kirangadhave requested a balanced review from Copilot September 16, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Default behavior contradicts the PR description, and execution parsing, command quoting, launcher portability, and HTTPS discovery need correction.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 5
  • Review effort level: Balanced

Comment thread marimo/_cli/pair/commands.py Outdated
Comment thread frontend/src/components/editor/actions/pair-with-agent-commands.ts Outdated
Comment thread marimo/_cli/pair/client.py
Comment thread marimo/_cli/pair/client.py
Comment thread marimo/_cli/pair/commands.py
The workflow snippet installs through ctx.packages.add, and the rules
cover package installs, empty cells, and deletions. Wording follows the
marimo-pair skill.
…nfirmed

Recovery commands shell-quote the URL and session id and embed the cell
id as a Python literal. A malformed execute event now raises the same
unconfirmed-completion error as a dropped connection, so the caller
inspects instead of retrying. Registry entries on port 443 use https.
@kirangadhave kirangadhave changed the title feat(pair): add live notebook execution commands feat(pair): add an agent-facing CLI for live notebook sessions Sep 16, 2026
@kirangadhave
kirangadhave requested a review from manzt September 16, 2026 20:31
@kirangadhave
kirangadhave marked this pull request as ready for review September 16, 2026 20:31

@manzt manzt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that uv run ends up in a lot of the prompts. Is that something that users would see when we make a release?

Comment thread frontend/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts Outdated
Comment thread frontend/src/components/editor/actions/pair-with-agent-commands.ts
Keep the current Pair with Agent experience stable while the CLI-backed
prompt is prepared behind an opt-in flag. Restore agent-specific flags,
installed-skill validation, and token handling, and use
`uvx marimo@latest` for generated commands so the modal does not assume a
local uv project.
@kirangadhave
kirangadhave merged commit 020ef25 into main Sep 16, 2026
48 checks passed
@kirangadhave
kirangadhave deleted the kg/pair-cli-execute branch September 16, 2026 22:32
kirangadhave added a commit that referenced this pull request Sep 18, 2026
## 📝 Summary

Add `MARIMO_PAIR_NEXT=1` to opt into CLI-based pairing from `pair
prompt` and all four Pair tabs. The preview skips skill installation and
directs agents to `marimo pair --help`. Keep the existing skill flow
when the flag is off.

Share the prompt template and launcher through page configuration.
Include the known notebook file and current session, format terminal
commands across multiple lines, and teach file-first selection so agents
can reconnect after a page reload.

Explain `--token-file` and `MARIMO_TOKEN` in basic help. Allow an empty
token entry to skip file creation and retain the environment fallback.
Preserve hidden token entry, private token files, and raw-prompt token
masking.

The preview uses local `uv run marimo`; switching to `uvx marimo@latest`
remains a separate change after publication. Follow-up to #10777.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request team-draft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants