Skip to content

docs: Motoko pay-as-you-go pricing and flexible outcalls - #448

Open
eichhorl wants to merge 4 commits into
mainfrom
docs/motoko-pay-as-you-go-outcalls
Open

eichhorl wants to merge 4 commits into
mainfrom
docs/motoko-pay-as-you-go-outcalls

Conversation

@eichhorl

Copy link
Copy Markdown
Contributor

Summary

Verification

  • npm run build passes (Node 24, submodules at their pins), and every snippet= region resolves.
  • node scripts/validate.js passes on both changed pages.

The `ic` package gained a builder in 6.0.0 that prices every outcall with
version 2 and takes the expectations that narrow its reservation, and a
builder for `flexible_http_request`. Every statement that Motoko is
version 1 only, or that the expectation setters and flexible outcalls are
Rust only, is no longer true.

The flexible example gains a Motoko tab, and the cycle costs section now
describes one rule for both languages rather than a split. The warning
against setting `pricing_version = 2` by hand goes with it: both builders
overwrite the field, so it can no longer disagree with the amount attached.
The guide said the two byte expectations are the ones to leave alone,
without the exception that matters most: a delivered byte costs about 15
times a downloaded one, so when a transform bounds its own output,
declaring that bound is often the largest single saving, and it is the
case lowering `max_response_bytes` cannot reach.

It also said an under-sized attachment can fail partway without saying
what that looks like. None of the four rejects mentions cycles, and the
likeliest one is the same message a non-deterministic transform produces,
so a reader who hits it has been sent to rewrite the transform instead of
the reservation.

Also drops a "in Rust" that the Motoko builder made wrong.
Pins .sources/examples to dfinity/examples@33af78a, the merge of
dfinity/examples#1490. The HTTPS outcalls guide quotes the Motoko
send_http_flexible regions from it, and the Motoko GET and POST
regions now show the ic 6.0.0 builder.
@eichhorl
eichhorl requested a review from a team as a code owner November 10, 2026 09:54
Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:54
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🤖 Here's your preview: https://dpfyp-oaaaa-aaaam-ahcqa-cai.icp0.io

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The guide still misstates shared-budget behavior and cycle-error semantics and omits the required minimum compiler version.

4 open issues
What changed in this PR

Updates the HTTPS outcall documentation to cover Motoko support for version 2 pricing and flexible outcalls alongside Rust.

Changes:

  • Adds Motoko tabs for flexible requests and response reconciliation.
  • Updates both pages to describe version 2 pricing through the language wrappers.
  • Expands guidance on transformed-response savings and insufficient cycle reservations.

Verified: Checked the reservation and error explanations against the local management-canister reference. Builds and snippet resolution were not rerun.

File Description
docs/​guides/​backends/​https-outcalls.mdx Adds Motoko examples and expands pricing and troubleshooting guidance.
docs/​concepts/​https-outcalls.md Updates wrapper support for version 2 pricing and flexible outcalls.

Review effort: Balanced

Comment thread docs/guides/backends/https-outcalls.mdx Resolved
Comment thread docs/guides/backends/https-outcalls.mdx Resolved
Comment thread docs/guides/backends/https-outcalls.mdx Resolved
Comment thread docs/guides/backends/https-outcalls.mdx Resolved
…rement

Out of cycles fires once the committee's unspent allowance cannot pay for
delivering any response, whether or not the nodes agreed. It is also the
one reject that does name cycles. A transform that exceeds its declared
output only fails the call when the rest of the budget cannot cover the
delivery, and ic 6.0.0 needs moc 2.1.0.
@eichhorl

Copy link
Copy Markdown
Contributor Author

🤖 Feedback addressed. All four Copilot comments were right:

  • Compiler requirement (https-outcalls.mdx:21): the prerequisite now says ic 6.0.0 requires moc 2.1.0, as its mops.toml does. The 1.9.0 toolchain in docs/getting-started/project-structure.mdx is a different page, so it is left for a separate change.
  • Transformed-size expectation (:247): exceeding it is now a risk, not a certainty. Delivery is paid from whatever the nodes leave unspent, so a larger output fails the call only when the rest of the budget cannot cover it. That matches the replica, where delivery is "only covered if the contributing replicas left enough of their allowances unspent".
  • "None of the rejects mentions cycles" (:249): replaced. Only Out of cycles names the cause; the other three look like unrelated failures.
  • Out of cycles implying agreement (:252): removed. In the replica, find_non_flexible_out_of_cycles takes one share per committee member across every response group, and fires once their unspent allowance cannot pay for delivering any response. The bullet now says that, and nothing about agreement.

npm run build and node scripts/validate.js pass.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Unavailable examples and upstream package sources prevent verification of the new Motoko snippets, version requirements, pricing behavior, and rejection diagnostics, requiring maintainer review.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

raymondk pushed a commit to dfinity/icskills that referenced this pull request Nov 13, 2026
…452)

## What changed upstream

The `ic` mops package gained a builder for `http_request` in **6.0.0**
(2026-11-02). It selects pricing version 2 on every call, takes the four
expectations that narrow the cycles it reserves, and ships a counterpart
for `flexible_http_request`. It needs **`moc` 2.1.0** for the
`costHttpRequestV2` primitive it calls. It deliberately does not call
`subnetSelfNodeCount`, which `moc` 2.1.0 also added: that would make
every canister importing `Call` require a replica with
`ic0.subnet_self_node_count`.

Motoko now reaches the same outcall surface as Rust. The skill said the
opposite in eight places.

## What this fixes

The support matrix listed version 2, `flexible_http_request` and
`subnet_self_node_count` as **not available** in Motoko. Seven further
passages repeated it: the version-1-only paragraph, pitfalls 2 and 14,
the Motoko implementation section, the cycle cost section, the
frontmatter `compatibility` field, and both reference files
(`pricing-version-2.md`, `flexible-outcalls.md`).

They now describe one surface for both languages, and name the
dependency versions that reach it. That part matters: `ic` **4.x and 5.x
are still version 1**, so the skill distinguishes them rather than
saying "Motoko does version 2" flatly. On 4.x there is no
`pricing_version` field at all, which is why that code is consistently
version 1 rather than mismatched.

The Motoko example moves from the args-record call to the builder. The
flexible reference also tells Motoko callers to set `replication`:
because `ic` 6.0.0 does not read the subnet size, a call with
`replication` unset reserves for full-size responses.

## Evaluation

`output_evals[9]` was adversarial: *"Adversarial: Motoko has no
pay-as-you-go pricing yet"*, asserting the model should say there is no
version 2 path and should not fabricate a builder. That assertion is now
false, and the eval would fail a correct answer.

It is inverted into a positive capability test under the same prompt:
use the builder, state the version requirement, leave `pricing_version`
and the cycles to it, and do **not** present the 4.x/5.x
`Call.httpRequest(args)` form as the version 2 entry point.

## Verification

The Motoko example in the skill was extracted and compiled against `ic`
6.0.0 with `moc` 2.1.0: builds clean. `node scripts/check-project.js`
passes for all 35 skills (the two warnings are unrelated skills missing
evaluation files). `skill-validator` 1.5.1, the version CI installs,
reports one warning on this skill, a code-language mix that predates
this PR.

## Related

The matching examples landed in dfinity/examples#1490, and the docs
follow in dfinity/developer-docs#448.

One finding worth passing to the `migrating-to-moc-2` skill when it
syncs in: **a project on `moc` 2.x cannot depend on `base`, directly or
transitively.** `base` still ships `ExperimentalStableMemory`, whose
primitives `moc` 2.0 removed, so `mops check` fails on it even when
nothing imports it and `mops build` succeeds. That holds up to and
including the latest `base` 0.16.0; `core` is unaffected. It is why
`daily_planner` could not be migrated in the examples PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

3 participants