Skip to content

ohttp tee connection util for relay#290

Merged
adambalogh merged 1 commit into
mainfrom
ani/ohttp
May 28, 2026
Merged

ohttp tee connection util for relay#290
adambalogh merged 1 commit into
mainfrom
ani/ohttp

Conversation

@dixitaniket
Copy link
Copy Markdown
Collaborator

@dixitaniket dixitaniket commented May 26, 2026

  • ohttp connection util for relay client

@adambalogh adambalogh marked this pull request as ready for review May 28, 2026 15:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a resolve(tee_id) API to the TEE connection layer so backend OHTTP relays can pin requests to a specific on-chain TEE while still letting the SDK manage TLS pinning and the x402 HTTP client. StaticTEEConnection.resolve() always returns the configured endpoint; RegistryTEEConnection.resolve() looks up the requested id in the registry, builds (and caches) a pinned client for it, and raises ValueError if it is not active. An LLM.resolve_tee_connection() wrapper exposes this on the public client.

Changes:

  • Add resolve() to TEEConnectionInterface and both implementations, with a shared _normalize_tee_id() helper (lowercases, ensures 0x prefix).
  • Factor RegistryTEEConnection._connect() into a reusable _connect_to_tee(TEEEndpoint) and add a _active_by_tee_id cache for per-id resolutions.
  • Expose LLM.resolve_tee_connection(tee_id) and re-export ActiveTEE from tee_connection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/opengradient/client/tee_connection.py Adds _normalize_tee_id, interface resolve(), static/registry resolve() implementations, and _connect_to_tee refactor with a per-tee-id cache.
src/opengradient/client/llm.py Imports ActiveTEE and exposes LLM.resolve_tee_connection() delegating to self._tee.resolve().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +176
cached = self._active_by_tee_id.get(normalized_tee_id)
if (
cached is not None
and cached.endpoint.rstrip("/") == tee.endpoint.rstrip("/")
):
return cached

resolved = self._connect_to_tee(tee)
self._active_by_tee_id[normalized_tee_id] = resolved
logger.info(
"Resolved selected TEE endpoint from registry: %s (teeId=%s)",
resolved.endpoint,
normalized_tee_id,
)
return resolved
@adambalogh adambalogh merged commit b156036 into main May 28, 2026
10 checks passed
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