[Bug] Compiler drops nested empty objects from variable defaults
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with packages/compiler/src/ast-helpers.ts, especially extractDictExpression() and its callers that extract object defaults and array values. Reproduce the issue with the provided source and inspect output.agent_version.state_variables. Done when nested empty objects remain in both the payload and items defaults, with regression coverage for those cases.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 279
- Forks
- 55
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 7
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from salesforce/agentscript
-
[Bug] Compiler drops nested None values from object and list defaultsPossibly taken @amazingjoe claimed this 16 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
salesforce/agentscript#103 ·
Maintainers usually reply within 1 day
-
[Bug] Compiler drops unary-plus numeric defaultsPossibly taken @BichengWang claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
salesforce/agentscript#116 ·
Maintainers usually reply within 1 day
-
[query] how to use pre/post_tool_call on agentforce?May be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 52/100
salesforce/agentscript#42 · 1 comment ·
Maintainers usually reply within 1 day
All issues in salesforce/agentscript
Similar issues
-
verified whatsapp
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
focusreactive/payload-plugins#279 ·
Maintainers usually reply within 1 day
-
openidconnect: option to use client_secret_post (client_id with "-" rejected by LemonLDAP::NG 2.21)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day