Preserve bodyless upstream statuses in managed-service responses

perfloop-oss/opencomputer · Value Kind Confusion

https://perfloop.ai/t/oss/case_a0b2mgzjct

Verdict

VERIFIED · settled 2026-11-15

What happened: The check fails before this change and passes with it.

Hypothesis

Valid bodyless service responses become exceptions when the agent rebuilds the proxy envelope. A local check through the public API reproduces this for upstream statuses 204, 205, and 304. Production exposure and affected call frequency remain unknown.

The contract in docs/agents/services.mdx:213-216 promises the service's status, headers, and body as fetch would return them. callService forwards a successful proxy response to unwrapServiceResponse. After the numeric-status and string-body checks, line 956 always passes the string to the Response constructor. An empty string is still a present body; these three statuses require an absent body. Non-successful proxy responses exit before this code and are not implicated.

The new native test agent/src/call-service-status.hunt.test.ts ran with `npm --prefix agent test` on Node 24.22.3. Its complete finite search covered 797 envelopes: every integer status 200-599, bodies empty or "x" where HTTP permits them, and one fixed explicit header map. It recorded exactly three failures, for 204, 205, and 304. The reduced deterministic test, `Hunt replay: callService preserves an empty upstream 204`, used one 200 JSON proxy response containing {"status":204,"headers":{},"body":""}. The same command exited 1 with `TypeError [Error]: Response constructor: Invalid response status code 204` at unwrapServiceResponse; all 21 pre-existing tests passed. A reference Response constructed with null and status 204 had a null body. No network calls were made, and scratch test files were removed.

Current upstream main still contains the same helper. The inspected open change https://github.com/diggerhq/opencomputer/pull/817 modifies managed-service provider routing, not response reconstruction; the other inspected agent patches do not repair this behavior. File history was inspected within a bounded 500-commit fetch. Closure feedback contained no related cases.

The Case should establish that all three final no-body statuses resolve with their upstream status, headers, a null body, and empty text. It should retain ordinary 200/404 reconstruction and proxy-error and malformed-envelope pass-through. Native regression-test placement is provisional. A response-construction assertion is the smallest useful first check; failure to preserve these observables would reject the proposed repair, while production prevalence remains an unmeasured limit.

Change to test: Use upstream status to distinguish an absent response body from an empty text body when reconstructing managed-service replies. Preserve the existing ordinary-response and pass-through contracts, with the native regression-test layout treated as provisional.

Where it lives

perfloop-oss/opencomputer · agent/src/index.ts

Evidence

The check fails before this change and passes with it: `For successful managed-service proxy envelopes with upstream status 204, 205, or 304, an empty string body, and optional valid string headers, callService in the agent package and CLI-generated runtime resolves with the upstream status and headers, a null body, and empty text.`

Checks: 1 of 1 passed. Verification: no defect found.

Timeline