Skip to content

Add first-class in-process WordPress REST request runtime primitive #440

@chubes4

Description

@chubes4

Problem

wp-gym still works around REST replay by writing a temporary PHP wrapper that constructs WP_REST_Request, calls rest_do_request(), and parses the JSON output. That is generic WordPress runtime behavior, not an eval-specific concern.

The current Codebox http-response observation is useful for preview HTTP requests, but it does not replace the in-process REST execution path needed for deterministic WordPress API scenarios where callers need the same semantics as rest_do_request().

Desired Codebox primitive

Add a generic Codebox runtime command or observation, for example:

  • wordpress.rest-request, or
  • ObservationSpec.type = "wordpress-rest-response"

The primitive should accept:

  • HTTP method.
  • REST path, with /wp-json normalization handled generically.
  • Headers.
  • Optional request body.
  • Optional response body inclusion policy.

It should return structured JSON with:

  • status.
  • headers.
  • normalized response data/body.
  • error diagnostics when WordPress returns or throws an error.
  • artifact refs when response bodies are too large to inline.

Acceptance criteria

  • A caller can execute a REST route inside the same disposable WordPress runtime without writing PHP wrapper files.
  • The command/observation is generic and does not mention wp-gym, rewards, graders, scenarios, task sets, or model evals.
  • Runtime policy gates the primitive like other WordPress runtime commands.
  • Smoke coverage proves a registered REST route can be called and returns structured output.
  • wp-gym can remove its stepRestWithCodeboxPhp() fallback after consuming this primitive.

Downstream evidence

Current workaround lives in wp-gym/src/index.js in stepRestWithCodeboxPhp().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions