Skip to content

feat(notebooks): add append-only edit command#495

Merged
platinummonkey merged 1 commit into
DataDog:mainfrom
mbldatadog:feat/notebooks-edit
May 12, 2026
Merged

feat(notebooks): add append-only edit command#495
platinummonkey merged 1 commit into
DataDog:mainfrom
mbldatadog:feat/notebooks-edit

Conversation

@mbldatadog
Copy link
Copy Markdown
Contributor

@mbldatadog mbldatadog commented May 12, 2026

Why this is needed

This command is required to ship the LLMObs skills (/eval-trace-rca, /eval-bootstrap, /experiment-analyzer) on top of pup.

Those skills currently call Datadog MCP notebook tools (create_datadog_notebook, edit_datadog_notebook) to write persistent analysis artifacts. When the skills run through pup instead of the MCP server, they need an equivalent pup command. notebooks create already exists; this PR adds the missing append-only variant.

Skills that break without this

/eval-trace-rca and /llm-obs-trace-rca — Phase 6 exports the root cause analysis report as a formatted Datadog notebook. Without notebooks edit, the skill produces console-only output with no shareable artifact. It also breaks the downstream chaining workflow described below.

/eval-bootstrap — After bootstrapping an evaluator suite, the skill detects whether a prior RCA notebook was created in the same session (by matching the notebook URL) and appends the bootstrapped evaluator summary to that notebook rather than creating a new one. This is the append-only pattern: the skill calls edit_datadog_notebook with append_only=true to preserve the existing RCA content and add new cells alongside it. Without notebooks edit, this entire chained workflow — /eval-trace-rca → creates notebook → /eval-bootstrap → appends to same notebook — is broken at the second step.

/experiment-analyzer — Phase 5 optionally exports the analysis report to a Datadog notebook. Without notebooks edit (or notebooks create), the skill falls back to chat-only output with no persistent artifact.

What breaks end-to-end

The most impactful breakage is the RCA → bootstrap chain:

/eval-trace-rca          # creates notebook with RCA findings
    ↓ notebook URL passed to next skill
/eval-bootstrap          # appends evaluator suite to same notebook
    ↓ broken without notebooks edit

Users lose the ability to produce a single unified notebook that documents both the root cause diagnosis and the evaluator suite that addresses it.

Summary

Adds pup notebooks edit <id> --file <cells.json> as an append-only alternative to notebooks update. Instead of replacing the entire notebook, it fetches the current notebook, appends the provided cells, and writes back — preventing accidental clobber of existing content.

Changes

  • src/commands/notebooks.rs — new edit() function (read-modify-write via typed API)
  • src/main.rsNotebookActions::Edit variant and routing

Interface

# --file contains a JSON array of cell objects to append (not the full notebook)
pup notebooks edit <notebook_id> --file cells.json

Example cells file:

[
  {
    "attributes": {
      "definition": {
        "type": "markdown",
        "text": "## New Section\n\nContent here."
      }
    },
    "type": "notebook_cells"
  }
]

Testing

Automated

  • cargo test — passing
  • cargo clippy -- -D warnings — clean
  • cargo fmt --check — clean

Manual smoke tests

cat > /tmp/cells.json << 'BODY'
[{"attributes": {"definition": {"type": "markdown", "text": "## pup smoke test\n\nAppended by pup notebooks edit — safe to delete."}}, "type": "notebook_cells"}]
BODY
  • pup notebooks edit 13937752 --file /tmp/cells.json — cell appended to notebook, returns updated notebook (exit 0)
  • pup notebooks edit 999999999 --file /tmp/cells.json — 404 "Notebook not found" on the initial fetch (exit 1)

🤖 Generated with Claude Code

Adds `pup notebooks edit <id> --file <cells.json>` which appends cells to
an existing notebook without clobbering existing content. Internally does a
read-modify-write: fetches the current notebook, appends the cells array
from --file, then writes back via the existing update endpoint.

The --file should contain a JSON array of cell objects (not the full notebook
body). This is distinct from `notebooks update` which does a full replace.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@platinummonkey platinummonkey merged commit 2098ac3 into DataDog:main May 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants