Skip to content

Add synchronous /execute endpoint for ML-Commons connector #21

@mingshl

Description

@mingshl

Originally created by @mingshl in mingshl/opensearch-agent-server#18

Description

Add a synchronous POST /execute endpoint that returns a JSON response (not SSE). This is needed for the ML-Commons remote agent connector, which expects a request-response pattern rather than streaming.

Background

The ML-Commons plugin in OpenSearch can call remote agents via a connector. The connector expects a synchronous HTTP endpoint that returns a complete JSON response.

API Design

POST /execute
Content-Type: application/json

{
  "input": "user query",
  "context": [...]
}

Response:
{
  "output": "agent response text",
  "tools_used": [...],
  "metadata": {...}
}

Implementation

  • New route in src/server/ (e.g., execute_routes.py)
  • Reuse existing agent factory and orchestrator
  • Collect all events internally, return final text as JSON
  • Respect auth middleware and rate limiting
  • Add to OpenAPI docs

References

  • Current SSE endpoint: src/server/run_routes.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions