Skip to content

feat(x402): improve 402 html page and its prompts#593

Closed
OisinKyne wants to merge 2 commits into
mainfrom
oisin/402-html-page
Closed

feat(x402): improve 402 html page and its prompts#593
OisinKyne wants to merge 2 commits into
mainfrom
oisin/402-html-page

Conversation

@OisinKyne

@OisinKyne OisinKyne commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Problem to be solved

The prompts on the html payment required UI don't tell the user that an agent service probably needs a task to be parsed, and an inference service is designed to be given to obol buy inference for use as an agent's brain. This PR aims to increase the success of people copying and pasting the prompts into their agents.

Summary

Need to test a little more, but pushing to a pr to start, also opening another pr (#594) for swagger that's intended for 0.11

402 HTML page — type-aware copy
(internal/x402/paymentrequired.go

  • template)
  • New PaymentDisplay fields:
    OfferType, OfferName,
    OfferDescription, Model.
  • buildTypeCopy produces a
    per-type lede + primary "Buy" card
  • secondary prompt cards.
    buildMetaDescription now prefers
    the operator description for
    OG/Twitter previews.
  • Inference offers get a primary
    obol buy inference --seller
    … --model … --budget 1
    --no-verify-identity shell snippet
    (rendered in < pre >), and lede
    framing makes it clear they're
    paying for remote model time, not
    an agent.
  • Agent offers get a primary
    chat-completions request snippet
    with model/messages/X-PAYMENT
    filled in, and lede framing flags
    that agents have
    tools/skills/memory and need a
    real prompt.
  • HTTP offers keep the existing
    single-prompt Obol-agent CTA.
  • Description, when set, renders
    under the Service card and goes
    into the OG meta.

Route + offer plumbing

  • RouteRule
    (internal/x402/config.go) gains
    OfferType and Model.
  • serviceoffer_source.go now
    copies
    spec.registration.description into
    RouteRule.Description (was
    previously a "ServiceOffer " debug
    label) and sets OfferType +
    Model.

CLI

  • --description is now the primary
    flag on sell
    inference|http|agent, with
    --register-description kept as an
    alias. Resume path
    (buildResumeGatewayArgs) emits
    --description. Tests updated.
  • sell inference --model rejects /
    and suggests a -- replacement
  • RouteRule (internal/x402/config.go) gains OfferType and Model.
  • serviceoffer_source.go now copies spec.registration.description into
    RouteRule.Description (was previously a "ServiceOffer " debug label) and
    sets OfferType + Model.

CLI

  • --description is now the primary flag on sell inference|http|agent, with
    --register-description kept as an alias. Resume path
    (buildResumeGatewayArgs) emits --description. Tests updated.
  • sell inference --model rejects / and suggests a -- replacement (the
    LiteLLM wildcard bug the agent hit).

buy.py

  • cmd_pay now accepts --timeout , defaults to 100s (Cloudflare
    free-tier tunnel cap), wired into urllib.request.urlopen.
  • SKILL.md gets two new pitfall entries (timeout default, slash-in-model
    breakage).

Re: the openapi branch: I left it alone — the new fields are intentionally
small so they layer onto richer Swagger-derived copy later without conflict.
When oisin/openapi lands, the description field on the 402 page is the
natural seam to either deep-link to the spec or expand into a multi-card
breakdown.

@OisinKyne OisinKyne changed the title Improve 402 html page feat(x402): improve 402 html page and its prompts Jun 4, 2026
@bussyjd

bussyjd commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Superseded by the consolidated integration PR #598, which merges this branch together with the other PRs ≥ #593 into integration/pr-593-plus for a single reviewable diff. Review hardening fixes ride in #599 (targets the integration branch). Closing in favour of the consolidated review — reopen if you'd prefer to land this one standalone.

@bussyjd bussyjd closed this Jun 5, 2026
OisinKyne added a commit that referenced this pull request Jun 5, 2026
…ning) (#600)

* Work on openapi spec for services

* Improve 402 html page

* Update storefronts

* feat(buy-x402): add --set-default so the agent self-adopts paid/<model> as primary

After a persistent inference buy publishes paid/<remote-model> in LiteLLM, the
agent adopts it as its own primary chat model in-pod via native
'hermes config set model.default' (atomic write, per-request re-read, no restart,
no host CLI, no new RBAC). Includes a LiteLLM /v1/models existence guard, an
auto-refill safety warning, and a PyYAML fallback writer.

Validated by a design+adversarial workflow and a live CLI smoke against a running
obol-agent: buy --set-default flips config.yaml model.default to paid/AEON-7/... and
the next agent chat settled via the x402-buyer pool (spent 0->1) with no restart;
rollback verified.

* Have agent stream responses to keep the tunnel alive

* security(x402): SRI-pin the Scalar bundle on the public /api page

The /api OpenAPI reference is served over the public tunnel and pulls the
@scalar/api-reference bundle from jsdelivr. The integrity hash was left empty
in phase 1, so the browser executed whatever the CDN returned, unverified.

Populate scalarBundleSRI with the sha384 of the pinned 1.34.0 bundle so a
tampered CDN response is blocked. Comment updated to stress the hash must be
re-derived in lockstep with every scalarBundleVersion bump.

* fix(buy-x402): run --set-default existence guard before auto-refill warning

The 'paid/<model> not selectable in LiteLLM' guard ran *after* the
no-auto-refill WARNING. A model that LiteLLM would refuse still printed a
scary 'every chat turn fails when the pool empties' warning describing a
primary-model failure mode that cannot occur when the default was never
switched. Reorder so we refuse first and only warn when we are actually
about to adopt the model.

* security(x402): sanitize ServiceOffer-sourced tokens in 402 copy-paste commands

spec.model.name and metadata.name flow from the ServiceOffer CR into
copy-pasteable 'obol buy inference ...' commands rendered on the public 402
page. A hostile or fat-fingered offer could smuggle shell metacharacters into
a command a reader might paste. Add sanitizeDisplayToken at the render
boundary: CR-sourced tokens must match the model-id/k8s-name charset
(^[A-Za-z0-9._:/-]+$) or collapse to the existing safe placeholder. Real ids
like qwen3.5:9b and anthropic/claude-3-5-sonnet-latest pass through unchanged.

* docs(claude): compress and correct CLAUDE.md; fold in #597 streaming/sell-agent facts

Terse rewrite of project CLAUDE.md (42725 -> 41797 bytes) corrected against the live codebase. Preserves all invariants, the 14 pitfalls, and flag warnings; adds #597's stream:true / statusRecorder.Flush guidance and agent-backed-offer (port 8642) facts so the compressed doc loses nothing rc12 ships.

---------

Co-authored-by: Oisín Kyne <oisin@obol.tech>
Co-authored-by: bussyjd <jd@obol.tech>
Co-authored-by: bussyjd <bussyjd@users.noreply.github.com>
@OisinKyne
OisinKyne deleted the oisin/402-html-page branch July 1, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants