Skip to content

feat(sdk-ts): forward target_type and target_id on evaluation requests (6/6)#184

Closed
abhinav-galileo wants to merge 4 commits intoabhi/rfc-1-1-pr5-python-sdk-targetfrom
abhi/rfc-1-1-pr6-ts-sdk-target
Closed

feat(sdk-ts): forward target_type and target_id on evaluation requests (6/6)#184
abhinav-galileo wants to merge 4 commits intoabhi/rfc-1-1-pr5-python-sdk-targetfrom
abhi/rfc-1-1-pr6-ts-sdk-target

Conversation

@abhinav-galileo
Copy link
Copy Markdown
Collaborator

Stacked on top of #183. Kept in draft until the full stack is validated end-to-end.

Summary

  • Exposes optional `targetType` and `targetId` on the generated `EvaluationRequest` type. The outbound schema remaps them to `target_type` / `target_id` on the wire so they match the server's JSON shape.
  • Regenerated the method-name overlay so Speakeasy will produce ergonomic method names for the new `/api/v1/targets` endpoints in future regenerations.
  • Existing call sites are unaffected: both fields default to `undefined` and are omitted from the wire payload when not set.

Regeneration note for reviewers

The `src/generated/evaluation-request.ts` change was made by hand because running `make generate` locally requires an authenticated Speakeasy session (the CLI opens a browser for OAuth). The edit mirrors the pattern Speakeasy uses for other optional + nullable string fields in the same directory (see `step.ts` for reference) and matches the `EvaluationRequest` shape in `server/.generated/openapi.json` after PR1-PR3.

Once `make sdk-ts-generate-check` is run with a live Speakeasy session, any residual cosmetic diff can be dropped in cleanly. The overlay change, on the other hand, is produced by the local Python overlay-generator script and does not require Speakeasy.

Test plan

  • `make sdk-ts-typecheck`, `make sdk-ts-lint`, `make sdk-ts-test` all green (11 tests including 3 new)
  • New Vitest coverage:
    • Omits `target_type` / `target_id` from the wire payload when they are unset
    • Serializes `targetType` / `targetId` as snake_case on the wire when supplied
    • Accepts explicit `null` for both fields
  • Python `make check` still green across models / server / sdk (nothing outside the TS SDK changed)
  • `make sdk-ts-generate-check` - needs interactive Speakeasy auth; reviewer should run locally to confirm zero drift from generator output

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@abhinav-galileo abhinav-galileo force-pushed the abhi/rfc-1-1-pr5-python-sdk-target branch from d6c4da5 to 8652936 Compare April 20, 2026 20:34
@abhinav-galileo abhinav-galileo force-pushed the abhi/rfc-1-1-pr6-ts-sdk-target branch from 8c29414 to 96b15bd Compare April 20, 2026 20:35
EvaluationRequest now accepts optional target_type + target_id. When both
are set, the server resolves the target row via (tenant_id, target_type,
external_id) and merges target_controls into the effective set. Direct
agent controls and policy-derived controls mask any target-level setting;
target_controls with enabled=true contribute otherwise. Missing target
returns 404. No-target requests remain unchanged.
Agent, control, and policy creation now read the effective tenant via a
get_tenant_id dependency backed by a pluggable TenantResolver. Default
resolver reads X-Tenant-Id header and falls back to DEFAULT_TENANT_ID so
callers that omit the header continue to work. Association inserts into
agent_policies and agent_controls record the owning agent's tenant_id.
Deployments with their own tenant identity source can swap the resolver
at startup via set_tenant_resolver. Read paths remain unscoped.
Threads optional target_type / target_id through check_evaluation,
check_evaluation_with_local, and evaluate_controls so callers can opt into
target-bearing evaluation when the server supports it. Fields default to
None so existing call sites are unchanged.
- Regenerated method-name overlay picks up the new /api/v1/targets
  endpoints so Speakeasy produces ergonomic method names for them.
- Manually updates the generated EvaluationRequest model to expose the
  new optional targetType / targetId fields and to remap them to the
  target_type / target_id wire format. This matches what Speakeasy would
  produce from the updated openapi.json; full regeneration requires an
  authenticated Speakeasy session locally.
- Adds Vitest coverage asserting the serialized payload omits target
  fields when unset, serializes them as snake_case when set, and handles
  explicit nulls.
@abhinav-galileo abhinav-galileo force-pushed the abhi/rfc-1-1-pr5-python-sdk-target branch from 8652936 to 42fa1fb Compare April 20, 2026 20:48
@abhinav-galileo abhinav-galileo force-pushed the abhi/rfc-1-1-pr6-ts-sdk-target branch from 96b15bd to 5bb953b Compare April 20, 2026 20:48
@abhinav-galileo abhinav-galileo force-pushed the abhi/rfc-1-1-pr5-python-sdk-target branch from 42fa1fb to aa5acb0 Compare April 20, 2026 20:49
@abhinav-galileo
Copy link
Copy Markdown
Collaborator Author

Superseded - the TS SDK regeneration artifacts this PR originally contained are now part of #180 (targets endpoints) and #181 (evaluation request target fields). The single vitest file was moved into #181 where its subject lives.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant