Class CopilotRequestContext

java.lang.Object
com.github.copilot.CopilotRequestContext

public final class CopilotRequestContext extends Object
The per-request context handed to every CopilotRequestHandler hook. It exposes the routing and cancellation details of a single intercepted request so overrides can observe or rewrite it.
Since:
1.0.0
  • Method Details

    • requestId

      public String requestId()
      Gets the opaque runtime-minted request id, stable across the request lifecycle.
      Returns:
      the request id
    • sessionId

      @Nullable public String sessionId()
      Gets the id of the runtime session that triggered this request, or null when the request was issued outside any session (for example the startup model catalog).
      Returns:
      the session id, or null
    • transport

      public CopilotRequestTransport transport()
      Gets the transport the runtime would otherwise use.
      Returns:
      the transport
    • url

      public String url()
      Gets the absolute request URL.
      Returns:
      the URL
    • headers

      public Map<String, List<String>> headers()
      Gets the request headers, multi-valued.
      Returns:
      the headers (never null)
    • withUrl

      public CopilotRequestContext withUrl(String url)
      Returns a copy of this context with a different request URL.
      Parameters:
      url - the replacement request URL
      Returns:
      the copied context
    • withHeaders

      public CopilotRequestContext withHeaders(Map<String, List<String>> headers)
      Returns a copy of this context with different request headers.
      Parameters:
      headers - the replacement request headers
      Returns:
      the copied context
    • cancellation

      public CompletableFuture<Void> cancellation()
      A future that completes when the runtime cancels this in-flight request (for example because the agent turn was aborted upstream). Subclasses that issue their own I/O should pass it through so the upstream call is torn down too.
      Returns:
      the cancellation future
    • isCancelled

      public boolean isCancelled()
      Whether the runtime has cancelled this in-flight request.
      Returns:
      true once the request has been cancelled