Skip to content

fix(adapters): Claude Code NotebookEdit dropped its cell content - #35

Merged
jothimani-rajendran merged 1 commit into
mainfrom
claude/dropped-fields
Aug 27, 2026
Merged

jothimani-rajendran merged 1 commit into
mainfrom
claude/dropped-fields

Conversation

@jothimani-rajendran

Copy link
Copy Markdown
Collaborator

What this changes

NotebookEdit is in WRITE_TOOLS, so the adapter advertises that it gates notebook writes — but the cell body arrives as tool_input.new_source, and parse() read only content/new_string/edits. So Event.content was None and any content policy (secret scan, memory guard) was blind at a notebook write.

NotebookEdit {new_source: "SECRET=akia"}  →  event.content = None   (before)
                                          →  event.content = "SECRET=akia"   (after)

Claiming to gate a write while dropping the write is an internal contradiction in the adapter's own contract — which is why this is a safe desk fix, not a vendor guess: it rests on NotebookEdit already being a declared write tool, not on an unobserved payload shape.

Claim check

  • No capability claim widened — NotebookEdit was already claimed as a write tool; this makes the claim true.
  • Verified by execution: NotebookEdit content now reaches the handler; Write/Edit/MultiEdit unchanged.
  • Two neighbouring findings in the same batch did NOT survive scrutiny and were deliberately left alone, rather than suppressed silently:
    • the finding's "MultiEdit content is dropped" half is falseedits[].new_string was already read;
    • the sibling "cursor beforeReadFile carries top-level content" claim has no recorded basis (that event was never observed, no docstring documents the shape), so it stays on the live-capture checklist rather than being guessed.

Checks

  • pytest -q — 749 passed, 1 skipped (up 1)
  • ruff clean; stdlib-only; signed off

Notes for the reviewer

This is the disciplined outcome of working the backlog: of the "verifiable dropped-field / matrix-mismatch" cluster, exactly one was a clean desk fix. The cursor failClosed-on-beforeSubmitPrompt item is a genuine matrix-vs-code mismatch but unresolvable without knowing whether Cursor accepts failClosed on that hook (it uses the continue protocol, not permission) — so it is flagged needs-live-run, not patched.


Generated by Claude Code

NotebookEdit is in WRITE_TOOLS, so the adapter advertises that it gates notebook writes,
but the cell body arrives as tool_input.new_source and parse() read only
content/new_string/edits -- so Event.content was None and any content policy was blind at
a notebook write. Claiming to gate a write while dropping the write is an internal
contradiction in the adapter's own contract, which is why this is a safe desk fix rather
than a vendor guess: it rests on NotebookEdit already being a declared write tool, not on
an unobserved payload shape.

Verified by execution: NotebookEdit content now reaches the handler; Write, Edit and
MultiEdit are unchanged.

From the vendor-truth backlog. Two neighbouring findings in the same batch did NOT survive
the same scrutiny and were deliberately not touched: the finding's "MultiEdit content is
dropped" half is false (edits[].new_string was already read), and the cursor beforeReadFile
top-level-content claim has no recorded basis (that event was never observed and no docstring
documents the shape), so it stays on the live-capture checklist rather than being guessed at.

Signed-off-by: Claude <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is small, consistent with the adapter’s declared write-tool contract, and is covered by a targeted regression test.

Pull request overview

This PR fixes the Claude Code adapter’s NotebookEdit parsing so notebook cell bodies are no longer dropped from Event.content, ensuring content-based policies (e.g., secret scanning / memory guard) can actually evaluate notebook write payloads as claimed by WRITE_TOOLS.

Changes:

  • Read tool_input.new_source into Event.content for Claude Code NotebookEdit events.
  • Add a regression test asserting NotebookEdit content and notebook_path propagate into the parsed Event.
  • Document the fix in CHANGELOG.md.
File summaries
File Description
src/agentseam/adapters/claude_code.py Extends content extraction to include tool_input.new_source so NotebookEdit writes are surfaced to policies.
tests/test_adapter_claude_code.py Adds a regression test proving NotebookEdit cell content reaches Event.content (and path maps from notebook_path).
CHANGELOG.md Notes the fixed blind spot where NotebookEdit previously produced Event.content=None.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@jothimani-rajendran
jothimani-rajendran merged commit e920712 into main Aug 27, 2026
13 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.

3 participants