Repository navigation
Conversation
…tVariables, preserve outputs - Whitelist `state`, `setupSessionContext`, and `context_variables` in evalNormalizer's VALID_AGENT_FIELDS for agent.create_session so the normalizer no longer strips fields needed for auth bypass and session context injection. - Translate YAML TestSpec `contextVariables` into `context_variables` on the agent.create_session step in yamlSpecTranslator, enabling YAML specs to inject context variables without raw JSON payloads. - Include `outputs[]` array in RunEvalResult's --json output so CI pipelines retain agent responses, topic routing, and planner state for debugging.
Contributor
|
FYI: adopted in #357 |
nico-pappagianis
added a commit
that referenced
this pull request
Sep 8, 2026
…s @W-24014400@ (#483) @ W-24014400@ ## What Adds a new `--context-variables-json` flag to `sf agent preview` and `sf agent preview start` so callers can send **typed** context variables (Boolean, Number, Object, List, Json) to the preview API, not just `Text`. ## Why `--context-variables` (the existing `Name=Value` flag) hard-codes every value as type `Text`. A boolean-gated route (for example `available when @variables.probeGate == True`) never opens, because the runtime compares the string `"True"` against the boolean `True`. See W-24014400. The new flag matches the preview API's own `Variable` schema (a discriminated union keyed on `type`), so a value is sent with the correct JSON type on the wire. ## How - New `contextVariablesJsonFlag` in `src/flags.ts`, plus `parseContextVariablesJson` (validates JSON shape and that each `value` matches its declared `type`) and `mergeContextVariables` (merges the text-form and JSON-form variables; on a duplicate name the JSON entry wins, keeping the text entry's position). - Both `agent:preview` and `agent:preview:start` accept both flags together. - Deliberately no `delimiter` on the JSON flag, so commas inside a List/Object/JSON value are safe (unlike `--context-variables`, which splits on `,`). - Help text and command snapshot updated. ## Notes - Depends on the typed `ContextVariable` discriminated union in `@salesforce/agents` (PR #356). This branch currently builds against a local `yarn link` of that SDK; once #356 releases, bump the `@salesforce/agents` version here to drop the link. - Draft: pending local e2e validation against a real org. ## Tests `yarn test` green (30 flags tests, including `parseContextVariablesJson` and `mergeContextVariables` coverage).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@W-21514105@
Addresses 3 confirmed gaps in
sf agent test run-evaldiscovered through empirical testing against the Einstein Evaluation API:state+setupSessionContext+context_variablesinevalNormalizer.ts— the normalizer'sstripUnrecognizedFieldspass currently removes these fields fromagent.create_session, making it impossible to test post-auth business topics or inject session context without--no-normalizecontextVariablestocontext_variablesinyamlSpecTranslator.ts— theTestCasetype already supportscontextVariablesbuttranslateTestCase()silently drops themoutputs[]in--jsonresult inrun-eval.ts—buildResultSummary()only returns evaluations, discarding the fulloutputs[]array with agent responses, topic routing, and planner state needed for CI debuggingEmpirical Evidence
Testing with a Salesforce Agentforce agent that requires authentication before routing to business topics:
--no-normalize(state preserved)account_validation(auth gate)product_help(correct business topic)Changes
src/evalNormalizer.tsstate,setupSessionContext,context_variablestoVALID_AGENT_FIELDSwhitelistsrc/yamlSpecTranslator.tstestCase.contextVariables→context_variablesoncreate_sessionstepsrc/commands/agent/test/run-eval.tsoutputs[]toRunEvalResulttype andbuildResultSummary()test/evalNormalizer.test.tstest/yamlSpecTranslator.test.tsschemas/agent-test-run__eval.jsonoutputsfieldTest plan
yarn buildsucceedsyarn test:only— 214/214 passing (6 new tests)test:json-schemapasses with regenerated schemacontextVariables→ confirmcontext_variablesin payload--jsonoutput includesoutputs[]per test