fix(base): improve field creation and query guidance - #2114
Conversation
1. Document batch field creation in shortcut help and the delivered Base skill.
2. Choose field types from stored values instead of business-purpose names.
3. Add generic common filter values to the data-query quick guide with contract tests.
说明:
- Combines the accepted fixes for base_table_096, base_table_028, and base_table_087;
MR 1275 contributes round 4 only.
```ai-signature
改动范围: Base field-create 帮助与 Skill 指南、data-query 快速指南,以及对应的 shortcuts/base 契约测试
思考过程: 保留三个实验的最终通用规则,合并 public main 上新增的字段读回提示,并排除没有 benchmark 支撑的 MR 1275 round6
改动原因: 让代理发现批量字段接口、按存储值选择字段类型,并用常见通用形状构造 data-query 过滤条件
Break Change: 否
```
Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: a53fdb6b6b82d74e4deff5e6d32591ec897cd2dc6ad662885c961a27e67d4666
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughBaseFieldCreate now supports documenting and validating single or batch field creation, including structured partial-failure responses. Related references and skill rules were updated, while the data-query quick guide and its contract test now focus on common ChangesField creation contract and guidance
Data-query quick guide
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant FieldCreate
participant FieldAPI
CLI->>FieldCreate: Submit field object array
FieldCreate->>FieldAPI: Create fields sequentially
FieldAPI-->>FieldCreate: Success or API error
FieldCreate-->>CLI: Return created, failed, and not-attempted results
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/base/data_query_guide_contract_test.go`:
- Around line 18-31: Expand the assertion list in the contract test around the
guide fixture to cover every newly added filter example: isLess,
isEmpty/isNotEmpty, value as an empty array, type 1, conditions, and the exact
["<status_value>"] shape. Keep the existing substring-based validation and add
one assertion for each required contract fragment so removal of any example
causes the test to fail.
In `@skills/lark-base/references/lark-base-field-create.md`:
- Line 46: Insert one blank line immediately after the arguments table in
lark-base-field-create.md and before the following heading, leaving the table
content unchanged so markdownlint MD058 is resolved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4562f56b-1db3-4620-80f7-15c88607d2ce
📒 Files selected for processing (6)
shortcuts/base/base_shortcuts_test.goshortcuts/base/data_query_guide_contract_test.goshortcuts/base/field_create.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-data-query-guide.mdskills/lark-base/references/lark-base-field-create.md
1. Assert every common filter fragment introduced by the data-query quick guide. 2. Keep the field-create argument table compliant with markdown table spacing. ```ai-signature 改动范围: data-query 指南契约测试与 field-create Markdown 表格后的空行 思考过程: 逐条核对 CodeRabbit 建议,只补会防止新增指南片段回退的断言和确定性的 MD058 格式问题,不改生产提示语义 改动原因: 关闭 PR 2114 的两条有效自动审查意见并保持变更可回归 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 81096f474001f2c9c59af48ee64150f205101710ebcf3b909ab9d300a019f46f
1. Replace the date-and-status scenario template with reusable Condition.value shape rules.
2. Update the contract test to require relative-date guidance and reject evaluation-shaped placehold
ers.
```ai-signature
改动范围: lark-base data-query quick guide 与对应 shortcuts/base 契约测试
思考过程: 保留 select、datetime、empty 的通用 value shape,删除日期字段和状态字段组合模板,避免将 base_table_087 的解题路径固化到公共指南
改动原因: benchmark 显示当前文案能引导目标题,但组合示例与测试过度贴合单题,需要收敛为跨场景可复用的不变量
Break Change: 否
```
Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local>
AI-SHA256: 7b6916f05dccf6489dce65610fe757f7b346bcd0f8f5500cfbfb1f30c60471f3
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/base/data_query_guide_contract_test.go`:
- Around line 42-51: Update the forbidden-content loop in the contract test to
search normalizedGuide instead of the raw guide, matching the positive checks
and ensuring forbidden phrases split by whitespace or Markdown line breaks are
detected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8b8e8e8b-59bc-4c3c-ab2a-58a3fdf140a8
📒 Files selected for processing (2)
shortcuts/base/data_query_guide_contract_test.goskills/lark-base/references/lark-base-data-query-guide.md
🚧 Files skipped from review as they are similar to previous changes (1)
- skills/lark-base/references/lark-base-data-query-guide.md
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/base/field_ops.go`:
- Around line 223-233: Preserve the underlying err when constructing the partial
failure in field_ops.go, passing it as the OutPartialFailure cause while
retaining the existing structured payload. In base_execute_test.go, replace the
display-string-only assertion with checks that errs.ProblemOf metadata includes
category, a non-empty subtype, code, log ID, and the original cause.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7695c4d8-a2af-4837-a4b3-afe0a71f91e1
📒 Files selected for processing (7)
shortcuts/base/base_execute_test.goshortcuts/base/base_skill_contract_test.goshortcuts/base/data_query_guide_contract_test.goshortcuts/base/field_ops.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-field-create.mdskills/lark-base/references/lark-base-field-json.md
🚧 Files skipped from review as they are similar to previous changes (2)
- skills/lark-base/references/lark-base-field-create.md
- skills/lark-base/SKILL.md
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@6680508e9481b9b07d0a3727de278b14f69abe65🧩 Skill updatenpx skills add huarenmin13/cli#codex/base-field-query-guidance -y -g |
1. 将固定 1 秒批次等待改为 500ms 最小请求起点间隔,并让请求耗时抵扣等待 2. 新增节流计算契约测试,覆盖首次请求、快速响应和慢响应 3. 同输入 150 字段 A/B 从 269.64s 降至 118.80s,且两侧均创建 150/150 说明: - 保持同表写入串行和 partial failure 输出不变 ```ai-signature 改动范围: shortcuts/base/field_ops.go 与 shortcuts/base/base_execute_test.go,仅调整 field-create 数组批次的串行节流计算和回归测试 思考过程: 保留同表串行写入,以 500ms 作为请求起点最小间隔,并把请求耗时计入间隔,避免固定空等同时降低写冲突风险 改动原因: PR 引导 Agent 使用数组批量创建后触发既有每项固定 1 秒等待,导致 150 字段用例产生约 149 秒可归因耗时回退 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 69b888d362d2f484c4ce6ad050bdbfe2de7368948eb79ba516bcaa6806ec9107
1. 派生、自动、同步或回填行为只使用已记录能力,无法实现时禁止探测、占位或虚假完成 2. 删除 data-query 契约测试对旧题模板占位符的反向黑名单,只保留原子规则和真实 case 污染检查 3. field-create 指引替换前后均为 36 个英文词,不扩大该帮助项的词数 ```ai-signature 改动范围: shortcuts/base/field_create.go、base_shortcuts_test.go 与 data_query_guide_contract_test.go,仅收口通用终止规则和测试泛化 思考过程: 采纳 review 中可独立闭环的两点,不增加翻译专用规则,不修改运行时能力;用等词数替换避免帮助上下文继续增长 改动原因: 当前规则能阻止按业务名猜字段类型,却仍允许退化成普通文本占位;同时测试记住旧题模板会阻碍未来合理示例 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 759b7f4044c6381b963c8ea299b70967e634ab9d43b6ebfbe94ef38bb69ba46a
1. 批量成功与部分失败仅返回字段 id/name/type,保留恢复所需身份并减少大响应上下文 2. 引导数组在调用方超时范围内一次提交,并为生成的大数组推荐 @file 或 argv-safe 调用 3. 字段列表默认页大小提升到 API 上限 200,避免百字段以上场景的帮助查询与重试 说明: - 同口径 case032:raw token 432292→428304,weighted token 126408→117761,耗时 272675ms→235022ms,两侧均读回 154 字段 ```ai-signature 改动范围: Base field-create 批量输出、帮助提示、field-list 默认分页及对应契约测试与 Skill 返回说明 思考过程: 从同口径 trace 定位固定分块、大字段对象回传、100 条分页和 shell 双重转义四个确定性开销,保持单字段与部分失败恢复语义不变并逐项用测试锁定 改动原因: PR 引导数组批量创建后虽降低耗时,但多回合大输出会推高 raw token;需要在不牺牲正确率和恢复信息的前提下同时压缩 token 与耗时 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 8a2bd2d79c9abdb1e36ae45822dd04b2a3384498a1dc268cffcd47cff00d94ed
1. 合并 GitHub main 7363eb5,保留上游新增的统一 flag alias、恢复提示和其他仓库能力 2. field-list 唯一冲突采用上游 Aliases 机制,同时维持本 PR 的默认 limit 200 3. 合并后重新通过完整 race 单测、构建、数组 E2E、vet 与全部 lint 门禁 说明: - 普通 merge 不重写 PR 历史;冲突仅涉及 shortcuts/base/field_list.go ```ai-signature 改动范围: 合并 GitHub main 7363eb5,并解决 Base field-list 分页别名与默认值冲突 思考过程: PR 已落后 main 40 个提交且 GitHub 标记 DIRTY;选择普通 merge 避免 force-push,冲突处采用 main 的原生 Aliases 机制而保留本 PR 经评测验证的 200 默认页大小 改动原因: 让 PR 恢复可合并状态,同时不丢失 token 和耗时优化,也不把已经被上游统一实现的旧别名辅助逻辑带回最终代码 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: a98424c2559b48ebb1b9f861ba02b632b53a8f0cfe720646d16968ca04b03abc
1. 大数组成功路径推荐保留摘要的 --jq 投影,失败路径仍原样保留部分失败明细 2. 为一个或多个简单 text 字段提供 help fast path,并让 next_step:done 终止默认回读 3. 补充 Skill、帮助与执行结果契约测试,锁定有界输出和可恢复失败语义 说明: - 最新 main 同题 A/B:两侧均回读 154 字段,raw token 下降 5.9%,耗时下降 19.3%,峰值上下文下降 13.3%,工具调用下降 20% ```ai-signature 改动范围: Base field-create 帮助、简单字段成功提示、lark-base Skill 路由与对应契约测试 思考过程: 从最终 A/B trace 分别定位批量成功展开 150 项、简单 text 读取冗余指南和成功后整表回读三类可控上下文开销,用成功摘要与失败全量明细分流来保留恢复能力 改动原因: 继续优化 PR 2114 的 token 和耗时,同时要求任何回退不能归因到 PR;需要让大批量成功路径有界且不削弱正确性或部分失败恢复 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 626b288a7f5444dfecb872e6cd29d4fe0788404f5001dcb47aac64e2d55d9b5a
1. 批量创建完整成功时保留服务端字段元数据,部分失败仍返回精简 identity 2. 将 +field-list 默认页大小恢复为 100,继续支持显式 --limit 200 3. 补充回归测试与字段创建文档,保留 --jq 有界输出指导 说明: - 定向、Base 全量、race、仓库单测、构建、vet 与 lint 均通过 ```ai-signature 改动范围: Base 批量字段创建成功输出、字段列表默认分页、对应测试与文档 思考过程: 先用契约测试复现完整字段元数据丢失和默认分页翻倍,再只恢复主干既有成功输出与默认值,同时锁定部分失败精简输出不变 改动原因: 移除可归因到 PR 的兼容性和 token 回退,并保留显式 jq 投影、节流、快速路径及部分失败恢复带来的通用收益 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 6351ed9d228611e3b6f5bc30faf278835b463e07f4eb020f225abd41e264399c
1. Merge upstream main at 875d20a without changing the PR-owned diff 2. Bring Runtime.PresentError and the shared recovery concealment contract into the branch ```ai-signature 改动范围: 合并 larksuite/cli 最新 main 到 PR 分支,不新增 PR 自有业务差异 思考过程: 当前修复必须调用最新公共错误呈现 API;正常合并主干可避免复制实现或制造重复提交,并保持相对 main 的改动最小 改动原因: 确保部分失败修复在真实合并契约上编译和验证,同时保留上游错误隐藏与恢复策略 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: b88e0c8bc0064c0d2b84a2e544bf735fd69143d9634a44a5db6aaadff0ff9194
1. Project the typed field-create error through Runtime.PresentError before copying result fields 2. Read Error, ProblemOf, and permission extensions from the presented clone 3. Cover visible scoped authorization and concealed recovery without fabricating missing_scopes 说明: - Targeted, Base, full race, build, vet, format, lint, and module checks pass ```ai-signature 改动范围: Base 批量字段创建部分失败的错误呈现,以及 visible 和 concealed 恢复契约测试 思考过程: 先在最新 main 合并树上复现无 scope 授权提示和隐藏命令泄露,再复用兄弟批量命令的 PresentError 边界,仅替换 payload 复制时的错误来源 改动原因: OutPartialFailure 不会再次呈现根错误,必须在复制 typed error 字段前应用命令 scope 与发行隐藏策略 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: deee600dc8d4bb889629895178c1f217ba7762fbd5b3163da3b9d621c8585ac0
1. Clarify that retryable gates unchanged automatic retries, not corrected resubmissions 2. Classify Base error 1254291 as a retryable conflict with canonical wait guidance 3. Cover authorization recovery, write conflicts, and reference contract consistency ```ai-signature 改动范围: internal/errclass/codemeta_base.go、shortcuts/base/field_ops.go、对应 Base 回归测试与 field-create 参考文档 思考过程: 将 retryable 限定为同一请求原样自动重试资格,保留授权或输入修正后重新提交,并复用现有 conflict 恢复提示 改动原因: 部分失败顶层提示会与权限恢复 hint 冲突,且 1254291 未分类导致等待重试规则无法由结构化错误驱动 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 65cd95f24968c5e0b0c43cf858ed787eabb6d9d63b3d5199a294bd284816c35e
1. Preserve presented typed-error extensions without allowing them to overwrite batch ledger fields 2. Align field creation guidance with command-specific name semantics and caller-timeout recovery 3. Cover security challenges, extension collisions, and storage-type selection with regression tests ```ai-signature 改动范围: shortcuts/base 的 field-create 部分失败输出、命令提示、Base Skill 写入规则、field-create reference 与对应回归测试 思考过程: 复用 Runtime.PresentError 后 concrete typed error 的 JSON wire shape 作为扩展字段单源;对批次账本自有键统一生成无冲突 error_ 别名,并只收敛已证实的同名、fast path 与 timeout 契约矛盾 改动原因: 部分失败会丢失 challenge_url 等恢复字段,自定义 typed error 还可覆盖 status/index/error 导致错误账本;过度绝对的字段类型、同名和超时文案也会形成可归因正确率回退 Break Change: 否 ``` Co-authored-by: BASE Infra Harness <ai@base-infra-harness.noreply.local> AI-SHA256: 02377560f14202ea652f530389ac102647189923e45548337814ec3871f5a4de
Summary
Improve Base agent guidance for recurring field/query failures and remove the batch-create latency regression exposed by the new array guidance.
+data-queryfilter values;--jq, skip unnecessary simple-text references/readbacks, and avoid deterministic chunking, quoting, and pagination retries;1254291as retryable.Changes
+field-create.--json @fileor argv-safe invocation instead of fixed-size chunks or double-escaped shell substitutions.created/total/ next-step fields while preserving the complete partial-failure envelope;next_step:donestops default field-list/get readback.{name,type:text}fields use command help as a fast path; other types/properties still require the field JSON SSOT, and formula/lookup keep their mandatory guides.+field-listdefault of 100; large-schema verification can explicitly request--limit 200 --jq ....Runtime.PresentErrorbefore copying message, typed metadata, hints, and permission extensions into the result payload.retryable:true; non-retryable items may be resubmitted after following their authorization or input-correction hint. Register1254291asapi/conflict/retryable:truewith the canonical wait guidance.Attribution and live A/B
The evaluation report's 150-field case (
base_table_032) took 197.444s on baseline and 347.016s on the PR version: a 149.572s regression. This PR makes array field creation the recommended path, which activates a pre-existing fixed one-second delay before each field after the first.Using fresh, equivalent Bases and the same 150-text-field payload:
4d1fb9a0f22e5b0d1eac5d23The first patched run removed 150.84s (-55.9%); the
1eac5d23run was 166.06s faster than the old head (-61.6%). All runs produced identical create/readback counts. This directly closes the identified PR-attributable fixed-wait regression.I also reran the original
base_table_032prompt through the agent withGPT-5.4,runs=1,jobs=1, separate fresh equivalent Bases, and the then-current mergedmainas the baseline:7363eb54bcb3ceb7The final current trace used one array call, skipped the two field reference documents on the simple-text fast path, bounded the create result to 334 characters, bounded the optional readback result to 158 characters, and completed without pagination or quoting retries. The weighted-token point estimate moved +2.2% while raw tokens, peak context, output tokens, and tool calls all fell; the two runs had different cache-hit rates (87.8% vs 84.1%), so this isolated weighted movement does not support PR causality. Earlier current-tree trials exposed and then closed two attributable token risks: a 14.6KB expanded batch result and a 27.9KB unfiltered field-list readback.
The agent A/B above evaluated
bcb3ceb7. Current head6680508erestores the existing full-success response contract and field-list default of 100, preserves presented typed-error extensions behind collision-safe batch-ledger aliases, makes same-name handling command-specific, and documents caller-timeout reconciliation. The evaluated success trace explicitly projected both field-create and field-list output with--jqand never entered partial failure, so these compatibility fixes do not change that trajectory; this preserves the measured mechanism without claiming that the new head itself has been rerun at agent level.The branch merge-base remains upstream
main875d20a2. A clean merge-tree against latestmain426f80fdpasses Base normal and race tests, and the current branch passes the exact CI unit-package race command. Latestmainitself currently reproduces an unrelated+messages-searchaffordance-example failure, so this description does not claim a green latest-main full-repository suite.The current run's control-plane
prepareBase/status callbacks warned, but localresult.json, trace completion, and independent Base readback were all present.This is targeted causal evidence for the changed field-create path, not a replacement for a refreshed 124-case aggregate evaluation.
Review follow-up
fieldsagain; only partial-failurecreateditems keep compactid/name/typeidentity.+field-listnow defaults to 100 again while retaining the 1-200 range,--page-sizealias, and explicit--limit 200support.base:field:create, concealed distributions retain the scope without exposingauth login, and typed recovery extensions such aschallenge_urlsurvive. Colliding extension keys cannot overwriteindex,status,field, orerrorin the batch ledger.retryable:true; Base error1254291now carriesapi/conflict/retryable:trueand canonical wait guidance. Caller-timeout recovery reads back before resubmission and marks same-name hits as ambiguous when no pre-write snapshot exists.base_table_028: current guidance now has an explicit unsupported terminal state and forbids plain storage placeholders or false completion. The replacement tip remains 36 English words, equal to the prior tip, and contains no translation-specific wording. This current-head behavior still needs an agent benchmark before claiming the original task is fixed.base_table_087: removed the contract test's blacklist of the old date-plus-status template and placeholder names. The remaining contract checks atomicCondition.valuerules, the DSL SSOT link, guide size, and absence of real case IDs/Base URLs.Test Plan
1254291retryable write-conflict partial-failure testgo test ./shortcuts/base -count=1go test -race ./shortcuts/base -count=1make unit-testmake buildgo vet ./...go mod tidyleavesgo.modandgo.sumunchangedEarlier benchmark context
Three normalized runs were completed over Base evaluation cases 096, 028, and 087 on pre-generalization head
c88ec548. Case 096 exercised one-call batch creation of 10 fields in 2/3 runs; the third run found copied target fields already present and skipped the requested write. Case 087 returned the requested overdue count in 3/3 runs, using direct+data-queryin 2/3 and a record-list fallback in 1/3. Case 028 did not produce automatic translation in any run: one unsupported type was rejected and two runs created plain-text placeholders. The whole-case grader was 4/9 in each run, with several broadernewly createdexpectations also affected by pre-existing copied state. The generalized 028 terminal boundary and 087 atomic guide at current head have not yet received the corresponding agent-level benchmark.Related Issues
Co-authored-by: BASE Infra Harness ai@base-infra-harness.noreply.local
AI-SHA256: de5306bfc038a81dbc4a57b2301c2c053aba673bf3b7f5d4472adda2baaded12
Summary by CodeRabbit
--jsonnow accepts either a single JSON object or a non-empty JSON array.Condition.valueshapes and date/empty handling notes.field-create/reference docs (and quick-route entries) to cover multi-field--jsonusage and batch response/failure details.