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
    • agentId

      @Nullable public String agentId()
      Gets the stable per-agent-instance id for the agent trajectory that issued this request, or null when no agent is in scope.
      Returns:
      the agent id, or null
    • parentAgentId

      @Nullable public String parentAgentId()
      Gets the id of the parent agent when this request was issued by a subagent, or null for root-agent and non-agent requests.
      Returns:
      the parent agent id, or null
    • interactionType

      @Nullable public String interactionType()
      Gets the runtime classification for the interaction that produced this request, or null when the runtime did not classify it.
      Returns:
      the interaction type, 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