Skip to content

feat: add agent scorer run support @W-23997055 - #367

Open
nabilnaffar-sf wants to merge 2 commits into
forcedotcom:mainfrom
nabilnaffar-sf:nnaffar/scorer-run
Open

nabilnaffar-sf wants to merge 2 commits into
forcedotcom:mainfrom
nabilnaffar-sf:nnaffar/scorer-run

Conversation

@nabilnaffar-sf

Copy link
Copy Markdown

What does this PR do?

Adds Agent Scorer run support — run an authored scorer against a normalized STDM session and get a typed score back. This is the second of two PRs that split #317.

What issues does this PR fix or reference?

@W-23997055

⚠️ Stacked on the authoring PR — merge that one first.
This branch is built on top of nnaffar/scorer-generate-metadata (the authoring PR). Its run code depends on the ScorerSpec type + vocabulary and the schema-generation wiring introduced there. Until the authoring PR merges into main, the diff shown here against main will include the authoring changes too. The run-only delta is reviewable here: nabilnaffar-sf/agents@nnaffar/scorer-generate-metadata...nnaffar/scorer-run

What's included (run-only delta)

  • Running — runScorer(spec, session, connection) runs a scorer against a normalized STDM SessionView and returns a ScorerResult, dispatched through a pluggable engine registry (registerEngine / getEngine). A PromptTemplate engine is provided, backed by the prompt-templates generations API with bounded, jittered retry for transient LLM-gateway throttling/unavailability and disambiguated failure messages.
  • Session normalization — normalizeSession reshapes STDM/Data Cloud timestamps to the exact format the platform's Input:Session validation accepts, so real captured data scores without hand-editing.
  • STDM session model — the typed SessionView (+ sub-views) and the exported SESSION_VIEW_JSON_SCHEMA, generated from the SessionView type.
  • Public surface — runScorer, engine registry, session view types, and the session-view schema re-exported from the package root.

Verification

  • yarn build (compile + lint) ✅
  • yarn mocha "test/**/*.test.ts" — full suite green (588 passing, 1 pending); test/agentScorerRun.test.ts covers this PR's surface.

Client-side API for authoring Agent Scorers and generating their
deployable metadata from a typed ScorerSpec:

- createScorerDefinition(spec, { outputDir, write }) generates
  aiAgentScorerDefinition and (when needed) genAiPromptTemplate metadata.
- Default prompt content derived from the scorer's output JSON Schema.
- Versioning/parse helpers: parseScorerXml, parseScorerVersions, loadScorerSpec.
- Validation + API-name helpers (validateScorerSpec, isValidScorerApiName,
  labelToApiName) and the exported SCORER_SPEC_JSON_SCHEMA generated from
  the ScorerSpec type (scripts/gen-scorer-schema.mjs).
- Public scorer authoring vocabulary re-exported from the package root.

Scorer run support follows in a separate PR.
Run an authored Agent Scorer against a normalized STDM session:

- runScorer(spec, session, connection) dispatches through a pluggable
  engine registry (registerEngine / getEngine); PromptTemplate engine
  provided, backed by the prompt-templates generations API with bounded,
  jittered retry for transient LLM-gateway throttling/unavailability.
- normalizeSession reshapes STDM timestamps to the format the platform's
  Input:Session validation accepts, so real Data Cloud data scores verbatim.
- Typed STDM SessionView model + exported SESSION_VIEW_JSON_SCHEMA
  (generated from the SessionView type).
- Run-time surface (runScorer, engines, session view types/schema)
  re-exported from the package root.

Stacked on the scorer authoring PR; merge that first.
@nabilnaffar-sf
nabilnaffar-sf requested a review from a team as a code owner September 15, 2026 10:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant