[Bug] Compiler drops nested empty objects from variable defaults
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
从 packages/compiler/src/ast-helpers.ts 开始,重点查看 extractDictExpression() 及其调用方,这些调用方会提取对象默认值和数组值。使用提供的源代码重现问题,并检查 output.agent_version.state_variables。当嵌套的空对象在 payload 和 items 的默认值中都得以保留,并且这些情况有回归测试覆盖时,即完成。
由索引模型根据 Issue 内容生成。
描述
Description
Empty objects inside object and list variable defaults disappear during compilation. This removes object properties and changes list lengths and element positions without a diagnostic.
Steps to Reproduce
- Check out
salesforce/agentscriptatace15eb2dc75564fd9e214385ac045c539056770(currentmain). - Parse the source below with
@agentscript/parser, convert it withnew Dialect().parse(mappingNode, AgentforceSchema), and run the AgentforcedefaultRules()throughLintEnginewithagentforceSchemaContext. - Pass the parsed value to the compiler's
compile()and inspectoutput.agent_version.state_variables.
Expected Behavior
The payload default remains {"empty": {}, "full": {"n": 1}}, and the items default remains [{}, {"n": 1}, {}].
Actual Behavior
The compiler emits:
{"developer_name": "payload", "default": {"full": {"n": 1}}}
{"developer_name": "items", "default": [{"n": 1}]}
The parser, schema, lint engine, and compiler return no diagnostics for this source. A standalone mutable object = {} retains its empty default, and a list[string] = ["a", "b"] retains both elements.
Environment
- Node.js: 22.20.0
- pnpm: 10.34.6
- OS: macOS 27.0.1, arm64
- Package:
@agentscript/compiler3.26.1, source checkout at the commit above - Parser: default JavaScript backend
Minimal Reproduction
config:
agent_name: "TestBot"
agent_type: "AgentforceServiceAgent"
access:
default_agent_user: "[email protected]"
variables:
payload: mutable object = {"empty": {}, "full": {"n": 1}}
items: mutable list[object] = [{}, {"n": 1}, {}]
start_agent main:
description: "Test"
reasoning:
instructions: ->
| {[email protected]} {[email protected]}
Additional Context
extractDictExpression() in packages/compiler/src/ast-helpers.ts returns undefined for an empty dictionary. Its caller omits dictionary values that are undefined, and extractExpressionValue() filters them out of arrays. The same helper handles default extraction, so an empty dictionary is treated as a missing value when nested.
Reproduced offline through parse → schema → lint → compile, with assertions on both corrupted defaults and the standalone-object/string-list controls. The existing compiler suite passes (1,113 passed, 3 skipped), so it does not catch these cases. The standard dependency build was blocked by the missing tree-sitter CLI; the required TypeScript packages were built directly. No fix is included in this report.
- 主要语言
- TypeScript
- 星标
- 272
- 派生
- 55
- 平均合并
- 12 小时 18 分钟
- 30 天内合并 PR
- 5
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
salesforce/agentscript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 80/100
salesforce/agentscript#103 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
salesforce/agentscript#102 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 61/100
salesforce/agentscript#85 ·
维护者通常 1 天内回复
-
README Quick Start fails on macOS: Node 26 incompatibility and missing tree-sitter CLI prerequisite可能重新可做 @dsorajisto 于 169 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 半天 新手友好度 75/100
salesforce/agentscript#33 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
salesforce/agentscript#99 ·
维护者通常 1 天内回复
查看 salesforce/agentscript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
marmelab/react-admin#11431 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
db-ux-design-system/core-web#8655 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
stripe/react-stripe-js#728 ·
-
[Upload Grade C dataset] the pop-up changes it's size while uploading the document => Jumping effect未关闭bug
难度 2/5 1-3 小时 新手友好度 66/100
epam/statgpt-admin-frontend#305 ·
维护者通常 1 天内回复