发布

  • [OPIK-6102] [BE] [FE] [SDK] feat: add required field to entrypoint parameters (#6443)

    frostbyte_neo 发布于 2026-04-23 15:18:25 +00:00

    • [OPIK-6102] [SDK] feat: add required field to entrypoint parameters

    Detect optional vs required parameters in entrypoint functions by
    inspecting inspect.Parameter.default. Propagate a required boolean
    through the SDK, backend, and frontend so the Agent Playground only
    validates required fields.

    • SDK: extract_params() sets required=False when param has a default
    • SDK: activate.py passes required through to REST API Param
    • SDK: in_process_loop.py strips None optional params before invocation
    • Backend: LocalRunner.Param gets boxed Boolean required field
    • Frontend: isFieldRequired() uses explicit required field, shows
      "(optional)" label, omits empty optional fields from submission

    Implements OPIK-6102: Agent Playground treats optional parameters as required

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • feat(typescript): add required field to entrypoint parameters

    Mirror the Python SDK change for the TypeScript SDK:

    • registry.ts: add required to Param, detect defaults in extractParams()
    • activate.ts: pass required through in toPayload()
    • InProcessRunnerLoop.ts: pass undefined for optional params with no input

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • fix(runner): remove None-stripping for optional params

    Explicit None from the job payload should be forwarded as-is so the
    entrypoint can distinguish "unset" from "caller sent null". The
    frontend already omits empty optional fields from the request.

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • test(typescript): fix trackEntrypoint tests for required field

    Update test expectations to include required: true in extracted params.

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • fix(typescript): only use undefined for truly absent optional params

    Explicit null should flow through to the entrypoint, not be converted
    to undefined. Only substitute undefined when the key is absent from
    inputs entirely, so JS default parameters apply correctly.

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • test(backend): add param required field round-trip tests

    Add two tests to RegisterAgents in LocalRunnersResourceTest:

    • storesAndReturnsParamsWithRequired: verifies required=true and
      required=false round-trip through registration and retrieval
    • storesParamsWithNullRequired: verifies old SDKs that omit required
      produce null on retrieval (backward compat)

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • test(backend): use random values and object assertions in param round-trip tests

    Addresses review feedback: replace hardcoded field names/types with
    randomUUID(), use full Param object comparison via containsExactlyElementsOf,
    and merge the two required-field tests into a parameterised test to eliminate
    copy-paste.

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

    • feat: replace boolean required with ParamPresence enum across full stack

    Replace the required: boolean field with a presence: ParamPresence
    enum ("required" | "optional") on entrypoint parameters. The enum is
    defined once on the Java backend and flows through the OpenAPI spec
    via Fern codegen into both SDKs. This makes the field extensible to
    future values (e.g. "internal") without a boolean→enum migration.

    Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com


    Co-authored-by: Claude Sonnet 4.6 noreply@anthropic.com

    下载附件