Class CopilotRequestContext
java.lang.Object
com.github.copilot.CopilotRequestContext
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 Summary
Modifier and TypeMethodDescriptionA future that completes when the runtime cancels this in-flight request (for example because the agent turn was aborted upstream).headers()Gets the request headers, multi-valued.booleanWhether the runtime has cancelled this in-flight request.Gets the opaque runtime-minted request id, stable across the request lifecycle.Gets the id of the runtime session that triggered this request, ornullwhen the request was issued outside any session (for example the startup model catalog).Gets the transport the runtime would otherwise use.url()Gets the absolute request URL.withHeaders(Map<String, List<String>> headers) Returns a copy of this context with different request headers.Returns a copy of this context with a different request URL.
-
Method Details
-
requestId
Gets the opaque runtime-minted request id, stable across the request lifecycle.- Returns:
- the request id
-
sessionId
Gets the id of the runtime session that triggered this request, ornullwhen the request was issued outside any session (for example the startup model catalog).- Returns:
- the session id, or
null
-
transport
Gets the transport the runtime would otherwise use.- Returns:
- the transport
-
url
-
headers
-
withUrl
Returns a copy of this context with a different request URL.- Parameters:
url- the replacement request URL- Returns:
- the copied context
-
withHeaders
Returns a copy of this context with different request headers.- Parameters:
headers- the replacement request headers- Returns:
- the copied context
-
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:
trueonce the request has been cancelled
-