Skip to content

fix: feishu_doc create 支持同时写入内容,避免创建空文档 - #125

Merged
lishuceo merged 1 commit into
mainfrom
fix/create-doc-empty-content
Mar 10, 2026
Merged

fix: feishu_doc create 支持同时写入内容,避免创建空文档#125
lishuceo merged 1 commit into
mainfrom
fix/create-doc-empty-content

Conversation

@lishuceo

Copy link
Copy Markdown
Owner

Summary

  • feishu_doccreate action 此前只创建空文档,agent 需要分两步(create → write)才能写入内容
  • 实际使用中 agent 经常只调 create 就返回结果,用户打开文档看到空内容
  • 现在 create 接受可选 content 参数,创建后自动调用 markdownToBlocks 写入 Markdown 富文本内容
  • 写入失败只 warn 不报错,确保文档创建本身不受影响

Test plan

  • 新增测试:create with content 成功写入
  • 新增测试:content 写入失败时文档仍创建成功
  • 全部 26 个 doc tool 测试通过

🤖 Generated with Claude Code

create action 只创建空文档返回 token,agent 需分两步调用才能写入内容。
实际使用中 agent 经常只调 create 就返回结果,用户打开文档看到空内容。
现在 create 接受可选 content 参数,创建后自动写入 Markdown 内容。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Mar 10, 2026

Copy link
Copy Markdown

Claude finished @lishuceo's task in 59s —— View job


PR Review: fix: feishu_doc create 支持同时写入内容

  • Check for previous review comments — none found
  • Read changed files and understand context
  • Perform code review
  • Post results

Approved — Clean, well-scoped change.

What this PR does: Adds an optional content parameter to the create action in feishu_doc tool. When provided, content is written immediately after document creation using the existing markdownToBlocks + batchBlocks pipeline. Write failures are logged as warnings without failing the overall operation.

Review findings:

No issues found (confidence ≥ 75). Specifically verified:

  • Correctness: The write logic reuses the same markdownToBlocksbatchBlocksdocumentBlockChildren.create pattern used by write and append actions. Using doc.document_id as the block_id for a freshly created doc is consistent with the fallback behavior in write/append (pageBlock?.block_id ?? args.doc_token).
  • Error handling: The warn-not-throw approach is a good design choice here — the user gets their document created and a token back, even if content write fails. The agent can retry the write separately.
  • Schema/description updates: Both the Zod schema description and the tool description string are updated to reflect the new capability.
  • Tests: Two new test cases cover the happy path (create with content) and the degraded path (content write fails, doc still created). Both correctly assert on the key behaviors.

@lishuceo
lishuceo merged commit 8af881e into main Mar 10, 2026
2 checks passed
@lishuceo
lishuceo deleted the fix/create-doc-empty-content branch March 10, 2026 03:52
lishuceo added a commit that referenced this pull request Apr 8, 2026
create action 只创建空文档返回 token,agent 需分两步调用才能写入内容。
实际使用中 agent 经常只调 create 就返回结果,用户打开文档看到空内容。
现在 create 接受可选 content 参数,创建后自动写入 Markdown 内容。

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant