flue icon indicating copy to clipboard operation
flue copied to clipboard

Public OpenAPI omits Durable Streams GET/HEAD routes exposed by runtime

Open MicroMilo opened this issue 5 months ago • 1 comments

1. Problem

The mounted Flue runtime exposes Durable Streams read endpoints as part of its public route surface, but the public /openapi.json contract does not include those read endpoints.

Source anchors:

  • packages/runtime/src/runtime/flue-app.ts:257 to packages/runtime/src/runtime/flue-app.ts:263 lists the mounted public routes, including:
    • GET/HEAD /agents/:name/:id
    • GET/HEAD /runs/:runId
  • packages/runtime/src/runtime/flue-app.ts:283 to packages/runtime/src/runtime/flue-app.ts:292 registers /agents/:name/:id, with non-POST requests routed to agentRouteHandler.
  • packages/runtime/src/runtime/flue-app.ts:295 to packages/runtime/src/runtime/flue-app.ts:296 registers /runs/:runId through runStreamReadHandler.
  • packages/runtime/test/routing.test.ts:208 to packages/runtime/test/routing.test.ts:234 currently asserts that public OpenAPI contains only:
    • /workflows/{name} with post
    • /agents/{name}/{id} with post

This creates a contract drift between runtime behavior and the machine-readable OpenAPI contract. The runtime exposes stream read routes, while /openapi.json advertises only POST invocation routes.

Reproduction

Use a runtime manifest with one HTTP-enabled agent and one HTTP-enabled workflow, mount flue() under /api, then request /api/openapi.json.

Current observed OpenAPI paths:

{
  "/workflows/{name}": ["post"],
  "/agents/{name}/{id}": ["post"]
}

Missing from the OpenAPI contract:

  • GET/HEAD /agents/{name}/{id}
  • GET/HEAD /runs/{runId}

I also verified this with a minimal local Vitest repro against the latest synced main commit aefd6ec791f3f88f5ed37b23ab9b4c0f0e5203a3. The repro passed by confirming:

  • body.paths["/runs/{runId}"] is absent.
  • body.paths["/agents/{name}/{id}"] only contains post.
  • body.paths["/workflows/{name}"] only contains post.

Impact

This does not prevent users from manually calling the runtime stream routes. The runtime route still exists.

The impact is on integrations that rely on /openapi.json as the machine-readable public API contract:

  • OpenAPI-generated clients will not contain a method for reading run events.
  • API explorers and generated SDK docs will not show the stream read entry points.
  • Contract validators or allowlists based on OpenAPI may treat GET /runs/:runId as an undeclared request.
  • Users can start a workflow or agent invocation from the OpenAPI-visible POST route, but cannot discover the follow-up event stream route from the same machine-readable contract.

So the issue is not a broken handler; it is an incomplete public API contract for the runtime surface already exposed by Flue.

2. Existing issue / PR coverage

I checked existing open and closed issues and PRs using the affected route names, files, and behavior keywords.

Searches included:

  • openapi /runs
  • flue-app openapi Durable Streams
  • routing.test.ts openapi agents workflows
  • streamUrl openapi agents runs

Relevant result:

  • PR #130, "Add run registry, admin API, and manual SDK scaffold", is related but does not cover this issue. It added run registry/admin API/SDK work and touched runtime OpenAPI areas, but the current public /openapi.json still omits the GET/HEAD stream read routes.

Coverage conclusion: not covered.

3. Should this be fixed?

Yes, this is worth fixing if /openapi.json is intended to describe the public mounted runtime API.

The fix is focused and low-risk: either document the stream read routes in OpenAPI, or explicitly decide that these routes are intentionally outside the OpenAPI public contract and adjust the route comments and POST descriptions accordingly.

Given the current runtime comments and route behavior, documenting the routes in OpenAPI appears to be the more consistent direction.

4. Proposed fix / PR draft

Add OpenAPI route specs for the Durable Streams read endpoints:

  • GET /agents/:name/:id
  • HEAD /agents/:name/:id, if the OpenAPI integration supports documenting HEAD separately
  • GET /runs/:runId
  • HEAD /runs/:runId, if supported

Implementation direction:

app.get(
  '/agents/:name/:id',
  describeRoute(agentStreamReadRouteSpec() as DescribeRouteOptions),
  validated('param', AgentRouteParamSchema),
  agentRouteHandler,
);

app.get(
  '/runs/:runId',
  describeRoute(runStreamReadRouteSpec() as DescribeRouteOptions),
  runStreamReadHandler,
);

Keep the existing app.all(...) handlers after the documented GET/HEAD routes so the current method fallback and canonical error envelope behavior remains intact.

The runStreamReadRouteSpec() should document:

  • path parameter: runId
  • query parameter: meta
  • stream read semantics for Durable Streams
  • relevant error envelopes, including not found and method not allowed

The agentStreamReadRouteSpec() should document:

  • path parameters: name, id
  • stream read semantics for the attached agent interaction
  • relevant error envelopes

Tests should update the current OpenAPI assertion in packages/runtime/test/routing.test.ts so the spec is expected to include the stream routes:

expect(body.paths).toMatchObject({
  '/workflows/{name}': { post: expect.any(Object) },
  '/agents/{name}/{id}': {
    post: expect.any(Object),
    get: expect.any(Object),
  },
  '/runs/{runId}': {
    get: expect.any(Object),
  },
});

Suggested validation:

pnpm --filter @flue/runtime test -- --run packages/runtime/test/routing.test.ts -t "openapi.json"
pnpm --filter @flue/runtime test
pnpm --filter @flue/runtime check:types

Non-goals:

  • Do not change Durable Streams runtime behavior.
  • Do not change the invocation POST route behavior.
  • Do not change admin API behavior.

MicroMilo avatar Jun 16 '26 09:06 MicroMilo

Resolved in 586569f6 by removing the incomplete public /openapi.json route for now. The document described only invocation POSTs while omitting Durable Streams reads, run metadata, and channels, so generated clients and policy tooling could incorrectly treat it as the complete mounted API contract. The documented HTTP routes and @flue/sdk remain available; public OpenAPI can return when it accurately covers the full surface.

FredKSchott avatar Jun 23 '26 06:06 FredKSchott