feat(kb): edit documents in place with textReplacements and pick the response shape - #896
Open
kmonsoe wants to merge 1 commit into
Open
feat(kb): edit documents in place with textReplacements and pick the response shape#896kmonsoe wants to merge 1 commit into
kmonsoe wants to merge 1 commit into
Conversation
…response shape kb_update_document takes textReplacements — ordered, all-or-nothing exact-match edits applied to the stored body, sharing the CMS implementation — so an agent can correct a fact without regenerating the document. Document-returning write tools take responseFormat (full | summary). KbInvalidError carries a code so kb_replacement_no_match and kb_replacement_ambiguous reach the control plane. New skill://kb/revise-document documents the loop. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJjhaB9bMU1agbqVKTwbB1
kmonsoe
force-pushed
the
feat/kb-text-replacements
branch
from
September 6, 2026 18:45
52bd3f3 to
ff08c16
Compare
kmonsoe
changed the base branch from
feat/cms-text-replacements
to
feat/cms-block-edits
September 6, 2026 18:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #895 — merge that first, then retarget this PR to
mainbefore merging it.Why
A knowledge-base document is one markdown body that the support agent answers from verbatim. Changing one fact today means resending the whole body, and a regenerated body drifts: a caveat disappears, a number gets rounded. Same problem #895 fixes for CMS entries, same fix.
What
kb_update_documentgainstextReplacements— an ordered, all-or-nothing list of{ oldText, newText, replaceAll? }edits applied to the stored body, reusing the shared helper from #895.oldTextmust match exactly once, or setreplaceAll. Zero matches fails withkb_replacement_no_match, several withkb_replacement_ambiguous; nothing is written andversiondoes not move.bodyandtextReplacementsare alternatives; sending both is rejected.sourceUrlride along on the same call as before./v1/kb/candidates/:idPATCH accepts the same field.KbInvalidErrornow carries acode, and the candidates controller passes it through, so the dashboard can translate these errors if it ever needs to.responseFormat: "full" | "summary"onkb_create_document,kb_update_document,kb_restore_versionandkb_publish_curation_revision, defaulting tofull.summaryshortens the body to a lead and reports its word count inbodySummary.kb_propose_curation_revisiondeliberately still takes the full proposed body — the reviewer sees it diffed against the current document — and the new skill says so.Skills
New
skill://kb/revise-documentowns the editing loop.import-from-google-docsandreview-contentpoint at it for small edits. Fixtures regenerated.Tests
kb.service.test.ts: happy path with ordered edits andreplaceAll, coded failures leave the row untouched, body/replacements overlap rejected, summary presenter for long and short bodies.kb.integration.test.ts: the surface through/mcp, including error codes in the tool result andresponseFormaton create and restore.🤖 Generated with Claude Code
https://claude.ai/code/session_01VJjhaB9bMU1agbqVKTwbB1