fix(agents): resolve paraId-less paragraphs by ordinal index in headless bridge#648
Open
jacobjove wants to merge 1 commit into
Open
fix(agents): resolve paraId-less paragraphs by ordinal index in headless bridge#648jacobjove wants to merge 1 commit into
jacobjove wants to merge 1 commit into
Conversation
|
Someone is attempting to deploy a commit to the EigenPal Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
All contributors have signed the CLA ✍️ ✅ Posted by the CLA bot. |
…ess bridge `read_document` (formatContentForLLM) labels a paragraph with no w14:paraId by its ordinal index — `[0]`, `[1]`, … — but `buildParaIdMap` only registered paragraphs that carried a paraId. So for a document without paraIds (Word does not always emit them) every id read_document handed the agent was rejected by every paraId-anchored bridge op — addComment, proposeChange, applyFormatting, setParagraphStyle, scrollTo — leaving the doc read-only through the bridge. Key paraId-less paragraphs by `String(index)`, mirroring the label. The index space is identical to getContent, so the key and the advertised id match, and a real paraId still takes precedence when present. All five map consumers share the same lookup, so the fix applies uniformly. find_text keeps its own paraId-only guard by design — a separate follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
11cca32 to
3d71175
Compare
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.
What & why
In the headless agent bridge,
read_document(viaformatContentForLLM) labels a paragraph that has now14:paraIdby its ordinal index —[0],[1], … — because Word doesn't always emit paraIds. ButbuildParaIdMaponly registered paragraphs that carried a paraId. So for a document without paraIds, every idread_documenthanded the agent was rejected by every paraId-anchored op —addComment,proposeChange,applyFormatting,setParagraphStyle,scrollTo(all five share the samemap().get(paraId)lookup) — leaving the document effectively read-only through the bridge.Fix
Key paraId-less paragraphs by
String(index), mirroring the labelformatContentForLLMalready emits. The index space is identical togetContent(same paragraph/table/other counting), so the registered key and the advertised id always match. A realw14:paraIdstill takes precedence when present. The change is strictly additive: paraId-bearing paragraphs key exactly as before; paraId-less ones gain an entry that previously didn't exist.No collision risk: generated paraIds are 8-char zero-padded hex (
generateHexId) and Word'sw14:paraIdisST_LongHexNumber(8 hex digits), so a real paraId is never equal to a 1–2 digit ordinal string.find_textkeeps its own!para.paraIdguard (it deliberately only anchors paraId-bearing paragraphs) — surfacing paraId-less matches there is a separate follow-up, noted in the test.Changes
packages/agents/src/reviewerBridge.ts—buildParaIdMapregistersparaId ?? String(index).packages/agents/src/__tests__/reviewerBridge.test.ts— 6 cases: ordinaladdComment/proposeChange/applyFormattingresolve, real paraId still wins, ordinal counts across a table, unknown id still returns null.Verification
bun run typecheckclean;bun test packages/agents/src/→ 247 pass / 0 fail. Changeset added (patch).