Skip to content

refactor(decisions): share one Decision HTTP executor across providers - #197615

Merged
obviyus merged 4 commits into
mainfrom
refactor/decision-http-executor
Nov 12, 2026
Merged

obviyus merged 4 commits into
mainfrom
refactor/decision-http-executor

Conversation

@obviyus

@obviyus obviyus commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Each HTTP Decision provider kept its own copy of the same transport: deadline and timeout signal, admission checks, guarded fetch, env-proxy mode, redirect policy, status-to-reason mapping, bounded JSON read, reflected-credential check, release and error mapping. The copies had drifted. Some rechecked admission after DNS and again after the response read, some mapped 422 differently, some skipped the reflected-credential check, and one raced a local image probe against the abort signal. openclaw/plugin-sdk/decisions-http-runtime already existed, but only OpenAI, Celeris, Nace, Perplexity and Fastino used it.

Solution

One owner: executeDecisionHttp / evaluateDecisionHttp in openclaw/plugin-sdk/decisions-http-runtime. It owns:

  • the deadline and timeout signal
  • one isAdmissible() check when each request starts. A provider with a queue wait or a retry calls the executor again, and that call checks again.
  • guarded fetch with the trusted env-proxy mode, and maxRedirects: 0
  • the shared exact-origin SSRF policy (resolveProviderTransportSsrFPolicy with origin trust), which is the same policy the chat transport uses
  • status mapping: 401/403 → authentication, 429 → rate-limited with retry-after-ms/Retry-After, 400/413/422 → unsupported-input, otherwise transport
  • the bounded JSON read (1 MiB by default), the reflected-credential check, release and cleanup. Release is memoized and also runs when the body is cancelled (responseWithRelease), so a debug-capture tee cannot hold a failed request open.
  • passing cancellation and thrown admission errors through. A decoder that throws gives invalid-response.

Providers keep only their route. That is the base URL and endpoint path, the body (omit it for GET), and a decoder. Optional fields cover real differences:

  • authHeaders: Gemini x-goog-api-key, Parallel x-api-key, and the keyless markers for Rerank and TypeSafe
  • statusReason: OpenRouter's 529
  • maxResponseBytes: Gemini, the ClawRouter catalog, and TypeSafe
  • requestHeaders: the per-body TypeSafe image opt-in header. These values are kept out of credential matching, including when they are also configured under request.headers.

The post-DNS and after-read rechecks are deleted. The host already checks admission after evaluate returns (evaluatePreparedDecisionProvider), and the docs say to check once when the request starts.

executeOpenAIDecision is deleted. ClawRouter now uses evaluateOpenAICompatibleDecision. Neither SDK subpath has shipped in a stable release (both are absent from v2026.11.3).

Providers

Provider Result Prod Δ Test Δ
baseten migrated −173 −49
clawrouter (catalog GET + inference) migrated −159 −182
google migrated (keeps its AI Studio host guard) −114 −58
levanto (decision-execution.ts deleted) migrated −237 −357
liquid-ai (decision-execution.ts deleted) migrated −136 −127
openrouter (decision-execution.ts deleted) migrated −140 −133
parallel migrated −97 −222
rerank migrated: the same request shape, with a provider-owned texts retry; each request checks admission when it starts −146 0
subq (V1 contract) migrated through executeDecisionHttp −114 −40
typesafe (errors.ts deleted) migrated −307 −874
openai / celeris / nace / perplexity / fastino already shared; OpenAI transport tests moved to the helper 0 −72
onnx skipped: local subprocess, not HTTP – –
test/ admission integration tests Levanto, SubQ and TypeSafe DNS-barrier files deleted; Baseten keeps 4 cases and drops replaced; the barrier helper is removed – −1,090
SDK executor + tests +35 +220

Total: +1,008 / −5,579 (net −4,571). Production code is about −1,587 lines and tests about −2,984. No test-lines allocation is needed (check:test-lines-ratchet passes).

Impact and accepted edge cases

  • All migrated providers now use the chat transport's exact-origin trust for custom and local base URLs. Previously the OpenAI-family providers, Baseten, Google, ClawRouter and Levanto allowed private hosts only with allowPrivateNetwork: true. Liquid, OpenRouter, Parallel and Rerank already trusted the configured origin.
  • Providers that accepted header-only auth (Liquid, OpenRouter, Parallel) now require the prepared API-key credential, as the OpenAI-family providers already did. The host always prepares one for these providers.
  • TypeSafe loopback endpoints follow the shared HTTP(S)_PROXY/NO_PROXY rules. They no longer pin localhost DNS. TypeSafe also no longer re-reads its config owner after the cold import. Revocation applies to the next request.
  • Admission is checked when each request starts, and not again after DNS. If a credential is revoked or replaced while an already-started request resolves DNS, that one request still goes out with the credential it started with. The next request sees the change. This matches "a started request may finish". The deleted test/decision-{levanto,subq,typesafe}-admission tests and Baseten's replaced case asserted the old post-DNS recheck.
  • An abort during a Levanto image probe now settles when the local probe returns, not before.
  • A Rerank 413 also triggers the one texts retry. A ClawRouter catalog 400 maps to unsupported-input. Gemini 422 maps to unsupported-input.
  • The OpenAI-family codec, the Baseten codec and the Gemini codec now accept unknown payloads and check the shape themselves.

Evidence

  • oxfmt and oxlint on the changed files: clean
  • Shared executor tests: src/plugin-sdk/decisions-http-runtime.test.ts and src/plugin-sdk/decisions.test.ts (26 tests)
  • Focused provider tests: openai, google, baseten, clawrouter, openrouter, liquid-ai, parallel, rerank, levanto, subq and typesafe, plus src/decisions/rerank.integration.test.ts (real loopback server, keyless/keyed/TEI retry, revocation between request and retry), src/decisions/clawrouter.integration.test.ts and test/decision-index-providers.integration.test.ts: all pass
  • pnpm tsgo:extensions, pnpm tsgo:extensions:test and pnpm tsgo:core:test (through pueue): pass
  • test/decision-baseten-admission.integration.test.ts: a real prepared runtime and the real pooled guard through the shared executor (allowed, auth reflection, header reflection, abort with release); passes
  • Live: src/decisions/registered.live.test.ts with a real GEMINI_API_KEY. The Google route passes end to end: text, PNG, JPEG and WebP through decision_evaluate, with typed answers and outputTokens: 0.

Move every HTTP Decision provider onto executeDecisionHttp in
openclaw/plugin-sdk/decisions-http-runtime. The executor owns the deadline,
one admission check when each request starts, guarded fetch with the trusted
env-proxy mode, no redirects, status classification, the bounded JSON read,
credential-reflection rejection, release, and cancellation pass-through.

Providers keep their endpoint, auth header, request encoding, response
decoding, and real status quirks (OpenRouter 529). Delete the per-provider
transport copies, their post-DNS and after-read admission rechecks, and their
transport tests; test the shared behavior once next to the helper.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

The shared executor checks admission once when each request starts, so the
Levanto, SubQ and TypeSafe DNS-barrier tests and the Baseten mid-flight
credential replacement case test removed behavior. Baseten's integration test
keeps proving the shared executor through the real pooled guard. Also qualify
the TypeSafe mock isolations, prune the mock-export baseline and drop
credential-shaped URL fixtures.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves HTTP Decision providers onto one shared executor while retaining provider-specific routes and codecs.

Example: Gemini returns HTTP 422 for an unsupported Decision request.

  • Before: The provider reports a transport failure.
  • After: The shared executor reports unsupported-input.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The source consolidation is coherent and prior findings are resolved; validation remains incomplete for the changed existing-install behavior.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Decision requests can report inconsistent failures or settle differently depending on the provider.
Reason: The change removes duplicated transport implementations, preserves provider-owned codecs, and records its intentional behavior changes in a maintainer-authored proposal.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it consolidates duplicated transport ownership, and both previously reported defects are fixed.

Priority: P2
Reviewed head: e74ec96fceed2257e0b82fb0c4256441245ee1c9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide sanitized fresh-install and v2026.11.3 upgrade evidence for a TypeSafe loopback evaluation with ambient proxy settings, showing preserved configuration and the resulting request route.
Agent review details

How this fits together

The Decision host supplies prepared credentials, request policy, deadlines, and admission; provider adapters supply protocol details, and the shared executor returns decoded results or classified failures.

flowchart LR
  A[Decision tool] --> B[Prepared Decision host]
  B --> C[Provider adapter]
  C --> D[Shared HTTP executor]
  D --> E[Guarded provider request]
  E --> F[Provider API]
  F --> D
  D --> G[Provider decoder]
Loading

Technical review

Best possible solution:

Keep HTTP policy in the existing SDK executor and native protocol behavior in provider adapters.

Do we have a high-confidence way to reproduce the issue?

This is a consolidation rather than a reported bug reproduction; source inspection confirms the prior fixes, and no target code was executed.

Is this the best way to solve the issue?

Reusing the existing executor provides one transport owner without adding a competing manager, configuration option, or persistence layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dcac94644b3c.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Prior credential-matching finding resolved: Per-request header names are removed from the credential-header copy before matching, including names also present in prepared request metadata. (src/plugin-sdk/decisions-http-runtime.ts:174, e74ec96fceed)
  • Prior capture-cancellation finding resolved: The executor now wraps the response with responseWithRelease and memoizes release; the added regression holds a capture tee open until release cancels its branch. (src/plugin-sdk/decisions-http-runtime.ts:204, e74ec96fceed)
  • Accepted transport tradeoffs: The collaborator-authored PR explicitly accepts request-start admission, exact-origin trust, TypeSafe ambient-proxy behavior, and delayed settlement during the Levanto image probe; these are recorded direction rather than unresolved owner choices. (e74ec96fceed)
  • Stable SDK compatibility boundary: The latest stable package exports contain neither decisions-http-runtime nor decisions-openai-runtime, supporting the PR's claim that the removed executor export has no stable-release compatibility window. (package.json, 847611dcaa3b)
  • Existing TypeSafe upgrade surface: The latest stable TypeSafe client already supports persisted loopback configuration; this PR changes how that existing route uses ambient proxies. (extensions/typesafe/src/client.ts, 847611dcaa3b)
  • Current-head checks remain pending: The refreshed current-head check page reports successful and in-progress checks with no failed check runs; this is not a completed CI verdict. (e74ec96fceed)

Likely related people:

  • Vincent Koc: Raw commit f01f183 adds src/plugin-sdk/decisions-openai-runtime.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f01f18384b9d; files: src/plugin-sdk/decisions-openai-runtime.ts)
  • Ayaan Zaidi: Raw commit 0182580 adds extensions/google/decision-provider.runtime.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0182580ebf7e; files: extensions/google/decision-provider.runtime.ts)

PR surface

Source -1580, Tests -2962, Docs 0, Other -3. Total -4545 across 55 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 26 485 2065 -1580
Tests 24 524 3486 -2962
Docs 4 26 26 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 3 -3
Total 55 1035 5580 -4545

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove merge-risk: 🚨 availability: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a useful shared-runtime consolidation without evidence of an urgent production regression.
  • merge-risk: 🚨 compatibility: The PR changes SDK exports and existing transport behavior, including TypeSafe ambient-proxy handling; the maintainer-authored body explicitly accepts these tradeoffs.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T08:11:47.804Z sha 50927b8 :: needs changes before merge. :: [P2] Exclude per-request headers from prepared credential metadata
  • reviewed 2026-11-12T08:28:22.546Z sha 59ded68 :: needs changes before merge. :: [P2] Preserve capture-aware cancellation in the shared executor

Reviewed November 12, 2026, 3:45 AM ET / 08:45 UTC (Revision 3).

The credential matcher also reads prepared request headers, so a TypeSafe
image opt-in configured under request.headers was collected as a secret and
valid responses containing `true` were rejected. Match against a header copy
without the per-request names.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Nov 12, 2026
With debug capture, the guarded response body is teed, and cancelling one
branch waits for the capture branch. Wrap the response with
responseWithRelease and a memoized release, as the SubQ and TypeSafe copies
did, so a failed request settles promptly. Move that regression to the
executor.

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Nov 12, 2026
@obviyus
obviyus merged commit 81ec452 into main Nov 12, 2026
130 of 131 checks passed
@obviyus
obviyus deleted the refactor/decision-http-executor branch November 12, 2026 08:55
steipete added a commit that referenced this pull request Nov 12, 2026
Complete the consumer cleanup from #197615: keep active module-local declarations private and remove two abandoned test helpers. The canonical export guards reproduce seven failures on the main parent and pass after the cleanup; 62 consumer tests and changed checks pass. Production line count is unchanged.
steipete added a commit that referenced this pull request Nov 12, 2026
Preserve caller context until worker settlement, immediate Talk retirement, and existing auth/write authority across asynchronous preparation. Repair affected real-worker fixtures and retain FIFO assertions at the actual queue entry.

Validated with focused consumer replays, complete affected type/lint checks, and Codex review. The changed-check command retains the independently reproduced main deadcode regression introduced by 81ec452 (#197615); no ignore or baseline exception was added.
roboclaw-bot added a commit that referenced this pull request Nov 12, 2026
…197718)

* test(agents): align OpenAI Decision authority fixtures

Match the transport contract from #197615: explicitly opt out of private-origin trust for the denied route, and allow the already-admitted retired request to finish while retaining host rejection, usage suppression, and request settlement checks.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>

* fix(test): align Decision fixtures with admitted request contracts

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 1350869c-60a2-8c3a-bcb8-4f9d4a5a830a

---------

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
steipete added a commit that referenced this pull request Nov 12, 2026
* test: repair hourly CI fixture boundaries

* test: align Decision fixtures with request-start admission

Retain explicit private-network denial and host suppression of retired results after an admitted transport completes. Attribute the stale expectations to #197615; all eight provider integration cases pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
openclaw#197615)

* refactor(decisions): share one Decision HTTP executor across providers

Move every HTTP Decision provider onto executeDecisionHttp in
openclaw/plugin-sdk/decisions-http-runtime. The executor owns the deadline,
one admission check when each request starts, guarded fetch with the trusted
env-proxy mode, no redirects, status classification, the bounded JSON read,
credential-reflection rejection, release, and cancellation pass-through.

Providers keep their endpoint, auth header, request encoding, response
decoding, and real status quirks (OpenRouter 529). Delete the per-provider
transport copies, their post-DNS and after-read admission rechecks, and their
transport tests; test the shared behavior once next to the helper.

Co-authored-by: obviyus <[email protected]>

* test(decisions): drop per-provider post-DNS admission tests

The shared executor checks admission once when each request starts, so the
Levanto, SubQ and TypeSafe DNS-barrier tests and the Baseten mid-flight
credential replacement case test removed behavior. Baseten's integration test
keeps proving the shared executor through the real pooled guard. Also qualify
the TypeSafe mock isolations, prune the mock-export baseline and drop
credential-shaped URL fixtures.

Co-authored-by: obviyus <[email protected]>

* fix(decisions): keep per-request headers out of credential matching

The credential matcher also reads prepared request headers, so a TypeSafe
image opt-in configured under request.headers was collected as a secret and
valid responses containing `true` were rejected. Match against a header copy
without the per-request names.

Co-authored-by: obviyus <[email protected]>

* fix(decisions): release on body cancel in the shared executor

With debug capture, the guarded response body is teed, and cancelling one
branch waits for the capture branch. Wrap the response with
responseWithRelease and a memoized release, as the SubQ and TypeSafe copies
did, so a failed request settles promptly. Move that regression to the
executor.

Co-authored-by: obviyus <[email protected]>

---------

Co-authored-by: obviyus <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
Complete the consumer cleanup from openclaw#197615: keep active module-local declarations private and remove two abandoned test helpers. The canonical export guards reproduce seven failures on the main parent and pass after the cleanup; 62 consumer tests and changed checks pass. Production line count is unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…penclaw#197718)

* test(agents): align OpenAI Decision authority fixtures

Match the transport contract from openclaw#197615: explicitly opt out of private-origin trust for the denied route, and allow the already-admitted retired request to finish while retaining host rejection, usage suppression, and request settlement checks.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>

* fix(test): align Decision fixtures with admitted request contracts

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 1350869c-60a2-8c3a-bcb8-4f9d4a5a830a

---------

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
* test: repair hourly CI fixture boundaries

* test: align Decision fixtures with request-start admission

Retain explicit private-network denial and host suppression of retired results after an admitted transport completes. Attribute the stale expectations to openclaw#197615; all eight provider integration cases pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: baseten Extension: baseten extensions: clawrouter Extension: clawrouter extensions: google extensions: liquid-ai Plugin: liquid-ai extensions: openai extensions: openrouter extensions: parallel extensions: rerank merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: fastino plugin: levanto Levanto Sage decision provider plugin: subq SubQ Snap decision provider plugin: typesafe rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant