x402 individual settlement updates#285
Conversation
dixitaniket
commented
Apr 25, 2026
- version bump for og-x402
- adds individual data settlement tx hash and blob id in generated output
There was a problem hiding this comment.
Pull request overview
Updates the SDK to a newer og-x402 version and extends generated LLM outputs to include per-request data settlement metadata (tx hash + Walrus blob id).
Changes:
- Bumped
og-x402dependency version (and lockfile entries). - Added
data_settlement_transaction_hash/data_settlement_blob_idfields to streaming and non-streaming output types. - Plumbed new response headers through the LLM client to populate the new fields (including final streaming chunk).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
uv.lock |
Locks og-x402 to 0.0.2 and updates dependency constraints. |
pyproject.toml |
Bumps og-x402 dependency floor to the new version range. |
src/opengradient/types.py |
Adds new data settlement metadata fields to StreamChunk and TextGenerationOutput. |
src/opengradient/client/llm.py |
Extracts settlement metadata from response headers and attaches it to outputs / final stream chunk. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return TextGenerationOutput( | ||
| transaction_hash="external", | ||
| data_settlement_transaction_hash=response.headers.get(X402_DATA_SETTLEMENT_TX_HASH_HEADER), | ||
| data_settlement_blob_id=response.headers.get(X402_DATA_SETTLEMENT_BLOB_ID_HEADER), | ||
| completion_output=result.get("completion"), |
There was a problem hiding this comment.
New behavior: the completion response now populates data_settlement_transaction_hash and data_settlement_blob_id from HTTP response headers. There are existing unit tests for LLM.completion, but none assert the header-to-output mapping when these headers are present—adding a test that sets these headers on the fake response would prevent regressions.
| if chunk.is_final: | ||
| chunk.data_settlement_transaction_hash = response.headers.get(X402_DATA_SETTLEMENT_TX_HASH_HEADER) | ||
| chunk.data_settlement_blob_id = response.headers.get(X402_DATA_SETTLEMENT_BLOB_ID_HEADER) |
There was a problem hiding this comment.
New behavior: the final streaming StreamChunk is mutated to include data_settlement_transaction_hash / data_settlement_blob_id from the response headers. The streaming tests currently validate TEE metadata on the final chunk but don't validate these new settlement fields—please add coverage to ensure they’re set correctly when the headers are provided.
| print_llm_completion_result( | ||
| model_cid, completion_output.transaction_hash, completion_output.completion_output, is_vanilla=False, result=completion_output | ||
| model_cid, | ||
| completion_output.data_settlement_transaction_hash, | ||
| completion_output.completion_output, | ||
| is_vanilla=False, | ||
| result=completion_output, | ||
| ) |
There was a problem hiding this comment.
The CLI is now passing data_settlement_transaction_hash into print_llm_completion_result, but the printer still only shows a transaction hash for is_vanilla flows and otherwise prints just Source: OpenGradient TEE. If the goal is to surface individual settlement metadata in the generated CLI output, update the print path for TEE results to display the settlement tx hash (and blob id when available) as well.
| result.chat_output, | ||
| is_vanilla=False, | ||
| result=result, | ||
| ) |
There was a problem hiding this comment.
Same as completion: the non-streaming chat CLI now forwards data_settlement_transaction_hash, but the output formatter for TEE mode does not print it. To match the PR intent, the CLI should display settlement tx hash / blob id (when present) for TEE chat results too.
| ) | |
| ) | |
| settlement_tx_hash = getattr(result, "data_settlement_transaction_hash", None) | |
| settlement_blob_id = getattr(result, "data_settlement_blob_id", None) | |
| if settlement_tx_hash: | |
| click.echo(f"Settlement tx hash: {settlement_tx_hash}") | |
| if settlement_blob_id: | |
| click.echo(f"Settlement blob id: {settlement_blob_id}") |