W-22203672: add hidden --agent-json flag to agent preview start#405
W-22203672: add hidden --agent-json flag to agent preview start#405EstebanRomero84 merged 15 commits intomainfrom
Conversation
W-22203672 Adds a hidden --agent-json flag that accepts a file path to a pre-compiled AgentJSON, bypassing the compile step in ScriptAgent. Intended for internal developer testing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jshackell-sfdc
left a comment
There was a problem hiding this comment.
see my small suggestion.
Co-authored-by: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com>
|
@andresrivas-sf few comments:
|
| throw new SfError( | ||
| `Failed to read or parse --agent-json file '${filePath}': ${SfError.wrap(error).message}`, | ||
| 'AgentJsonReadError' | ||
| ); |
There was a problem hiding this comment.
can you add telemetry logging similar to line 120?
W-22203672 - Apply jshackell's wording suggestion for flag summary - Add dependsOn authoring-bundle to --agent-json flag - Add telemetry for AgentJsonReadError - Add --agent-json flag to interactive agent preview command - Add NUT tests for --agent-json flag Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
W-22203672 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
W-22203672 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
QA NotesFlag is hidden: When passing an invalid file path the commands display correct error message ✅ When passing a agentJSON using the --agent-json flag, the commands don't call the v1.1/authoring/scripts endpoint to obtain the corresponding agentJSON. I verified it by modifying the original agent script file to have a syntax error. Since the preview session is generated successfully it means the command is using the provided agentJSON. ✅ |
…PI call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…and instanceof narrowing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The static fixture had an empty defaultAgentUser, causing bypassUser to resolve to false and the preview sessions API to reject the request. Patch it at runtime with the real agent user from the shared test session, matching what the compile-then-start path does via string replacement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The preview sessions API rejected "AgentforceAgent" with HTTP 400 "Define a valid value for ''agent_type''". Updated to "customer" which matches the AgentType union type in @salesforce/agents. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
"customer" was also rejected by the preview sessions API. The unit test for --agent-json uses "AgentforceServiceAgent", which matches the value the compile API returns for service-type agents. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…agents to 1.4.0 The preview sessions API rejected all prior agentType values. The bot-meta.xml for the test project's service agent uses "EinsteinServiceAgent", which matches what the compile API returns for this agent type. Also bumps @salesforce/agents to 1.4.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Setting defaultAgentUser to a valid org user made bypassUser=true, which caused the preview sessions API to validate permission sets that aren't assigned, resulting in a 500. An empty defaultAgentUser keeps bypassUser=false and skips that check entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A static fixture's agentVersion is rejected by the preview sessions API with a 500. Compile the agent at test time via Agent.init+compile(), write the real compiledArtifact to a temp file, and pass that as --agent-json. This tests the flag plumbing while ensuring the body is API-compatible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
@W-22203672@
--agent-jsonflag tosf agent preview startaccepting a file path to a pre-compiled AgentJSONScriptAgentviaScriptAgentOptions, skipping the compile steploadAgentJson()helper to keeprun()complexity within lint limitsAgent.init) and error path (invalid JSON throwsAgentJsonReadError)Dependencies
Depends on forcedotcom/agents#271 —
@salesforce/agentsmust be bumped after that merges.Test plan
yarn test:onlypasses (244 tests)sf agent preview start --authoring-bundle MyAgent --simulate-actions --agent-json /path/to/compiled.json --target-org myOrgand confirm session starts without a compile request🤖 Generated with Claude Code