Skip to content

Generate typed REST request payloads from agent-server OpenAPI schema #164

@neubig

Description

@neubig

Problem

ConversationClient.createConversation() currently accepts CreateConversationPayload = Record<string, unknown>. That makes frontend consumers hand-maintain partial copies of Python/Pydantic request shapes such as StartConversationRequest, or fall back to loose payload typing at exactly the boundary where correctness matters.

This came up while integrating Agent Canvas with openhands-agent-server 1.22.0. The agent server supports starting conversations with agent_settings so the SDK can call create_agent() server-side. Without generated TS types for that request shape, the frontend can only locally type the top-level fields and has to leave SDK-owned nested shapes loose.

Proposal

Generate and export TypeScript request/response types from the agent-server OpenAPI schema, including at least:

  • StartConversationRequest
  • conversation create response / ConversationInfo
  • settings request/response shapes used by the frontend
  • related discriminated SDK models referenced by these REST payloads where OpenAPI can express them

A likely implementation path is to generate types from /openapi.json using a tool such as openapi-typescript, then have the client methods reference those generated request body / response types instead of Record<string, unknown>.

Desired outcome

Consumers should be able to write code like:

import type { StartConversationRequest } from @openhands/typescript-client/...;

const payload: StartConversationRequest = {
  agent_settings: { ... },
  workspace: { kind: LocalWorkspace, working_dir: ... },
  max_iterations: 500,
  stuck_detection: true,
};

and pass that payload to ConversationClient.createConversation() without duplicating the Python SDK model tree in downstream frontends.

Metadata

Metadata

Assignees

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