🐛 fix: consolidate agent-documents tools and fix empty readDocument#14288
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19be44107f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const scheduleNode = task.automationMode ? ( | ||
| <TaskScheduleConfig | ||
| currentInterval={taskDetail?.heartbeat?.interval ?? 0} | ||
| taskId={task.identifier} | ||
| > | ||
| <TaskTriggerTag | ||
| automationMode={task.automationMode} | ||
| heartbeatInterval={taskDetail?.heartbeat?.interval} | ||
| schedulePattern={task.schedulePattern} | ||
| scheduleTimezone={task.scheduleTimezone} | ||
| /> | ||
| </TaskScheduleConfig> | ||
| <TaskTriggerTag | ||
| automationMode={task.automationMode} |
There was a problem hiding this comment.
Keep schedule trigger wrapped in TaskScheduleConfig
Replacing TaskScheduleConfig with a bare TaskTriggerTag removes the schedule popover and its click stopPropagation, so clicking the schedule pill now bubbles to the parent clickable row and navigates to /task/:id instead of opening inline schedule controls. This is a functional regression for automated tasks because list-level schedule edits are no longer possible from this entry point.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #14288 +/- ##
==========================================
- Coverage 68.28% 68.28% -0.01%
==========================================
Files 2328 2328
Lines 201505 201464 -41
Branches 25376 25376
==========================================
- Hits 137607 137577 -30
+ Misses 63765 63754 -11
Partials 133 133
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rework the lobe-agent-documents builtin tool surface and fix a long-standing bug where readDocument returned empty content for ~5% of agent documents that had non-empty markdown plus a stale editor_data JSON. Tool surface changes (LLM-facing): - Drop readDocumentByFilename — read by ID is the only entry now - Drop upsertDocumentByFilename from the LLM tool (kept on the internal AgentDocumentsService for onboarding/user.ts/webOnboarding) - Rename editDocument → replaceDocumentContent across manifest, types enum, executor, ExecutionRuntime, Inspector, TRPC, client service, i18n keys, Conversation workflow constants, and tests - systemRole gains an explicit "empty content means the document is empty, do not retry" hint to stop the format/filename retry loop readDocument empty-content fix: - AgentDocumentsService.attachLiteXML now detects when hydrating a stale editorData yields an empty editor while doc.content has markdown, and re-hydrates from the markdown column with a fresh litexml. Previously the empty snapshot was returned as-is. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19be441 to
c99e627
Compare
💻 Change Type
🔗 Related Issue
Related to LOBE-8358 (cloud team).
🔀 Description of Change
Two changes in one PR — both about the
lobe-agent-documentsbuiltin tool.**1. Fix:
readDocumentreturns empty content for ~5% of agent documents **AgentDocumentsService.attachLiteXMLwas the only read path that did not apply the markdown fallback wheneditorDatahydration silently failed. For documents that have valid markdown indocuments.contentbut aeditor_dataJSON saved by an older Lexical schema,editor.hydrateEditorData()throws (HeadingNode.splice: start + deleteCount > oldSize (undefined + 0 > undefined)in Lexical 0.42), the error is caught by@lobehub/editor, and the editor ends up empty. Previously the empty snapshot was returned to the LLM ascontent: ""— indistinguishable from a genuinely empty document, leading agents to retry with different formats / filenames.The fix detects the empty-snapshot case and re-hydrates from the markdown column (
exportEditorDataSnapshot({ editorData: undefined, fallbackContent: doc.content, litexml: true })), which produces both correct markdown and a fresh, valid LiteXML.Verified against a real prod row (1387 chars markdown, 16 568 chars stale
editor_data) — fix yieldscontent.length = 1387andlitexml.length = 4673with proper<h1>/<quote>/<p>nodes.2. Refactor: consolidate the agent-documents tool surface
Goal: one read entry, no by-filename variants, clearer write API name.
readDocumentByFilenamefrom the LLM tool — read by ID is the only entry now.upsertDocumentByFilenamefrom the LLM tool. InternalAgentDocumentsService.upsertDocumentByFilenameis kept because cloud onboarding flows (user.ts,webOnboarding) still rely on it; only the LLM-facing surface is removed.editDocument→replaceDocumentContentacross manifest, types enum, executor, ExecutionRuntime, Inspector, TRPC, client service, i18n keys, Conversation workflow constants, and tests.systemRole.tsgains an explicit "If the response contains empty content, the document is genuinely empty; do not retry with a different format or filename" hint to stop the format/filename retry loop seen in production traces.Net result: 11 LLM-facing APIs → 9. No more dual read paths, no `format` / `filename` combinations for the model to thrash through.
🧪 How to Test
📝 Additional Information
Breaking changes (LLM-facing):
The agent-documents-index already names `readDocument` as the only read entry, so the model has guidance to fall back gracefully when it sees the new tool list.
Non-breaking:
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com