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 TypeMethodDescriptionagentId()Gets the stable per-agent-instance id for the agent trajectory that issued this request, ornullwhen no agent is in scope.A 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.Gets the runtime classification for the interaction that produced this request, ornullwhen the runtime did not classify it.booleanWhether the runtime has cancelled this in-flight request.Gets the id of the parent agent when this request was issued by a subagent, ornullfor root-agent and non-agent requests.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
-
agentId
Gets the stable per-agent-instance id for the agent trajectory that issued this request, ornullwhen no agent is in scope.- Returns:
- the agent id, or
null
-
parentAgentId
Gets the id of the parent agent when this request was issued by a subagent, ornullfor root-agent and non-agent requests.- Returns:
- the parent agent id, or
null
-
interactionType
Gets the runtime classification for the interaction that produced this request, ornullwhen the runtime did not classify it.- Returns:
- the interaction type, 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
-