Claude Certified Architect – Foundations Practice Question 92: SDK File Checkpointing

Claude Certified Architect, Foundations · Test 10 · question 2 of 10

Agent Architecture & Orchestrationhard

A coding-assistant product built on the Claude Agent SDK lets users press "Undo" to restore the files an agent session changed. The agent edits files with the Write and Edit tools and sometimes runs shell commands. An engineer must implement the feature so that, after the stream has finished, the user can return the working tree to its state at the first user message of the session. Which design is correct, including what the team should still expect to handle separately?

Select one answer
Show answer and explanation

Answer:

  • D. Enable file checkpointing and replay-user-messages to receive checkpoint UUIDs; later resume the session with an empty prompt and call rewindFiles() with the stored UUID, and use git for shell-made edits

D is correct. File checkpointing is enabled with enableFileCheckpointing: true (Python: enable_file_checkpointing=True). User messages carry checkpoint UUIDs only when the replay-user-messages extra argument is set, so the app captures the first user message UUID and the session ID. After the stream completes the connection is closed, so the app resumes the session with checkpointing enabled and an empty prompt, then calls rewindFiles() (Python: rewind_files()) with the UUID. Only changes made through Write, Edit, and NotebookEdit are tracked, so Bash edits such as sed -i, and edits applied by subagents (apart from a foreground context: fork skill), must be reverted by other means such as git.

A is wrong on three counts: calling rewind after the loop ends fails with "ProcessTransport is not ready for writing", Bash edits are not tracked, and rewinding restores files but does not rewind the conversation. B is wrong because without replay-user-messages the user messages have no UUIDs, and subagent edits are not restored. C is wrong because rewind takes a checkpoint UUID, and checkpoints exist only if checkpointing was enabled on the session.

Reference: Rewind file changes with checkpointing - Claude Agent SDK

Practice Test 10 ›

Study guides for Claude Certified Architect, Foundations