Skip to content

CopilotResult

CopilotResult(turns: list[Turn] = list(), success: bool = True, error: str | None = None, duration_ms: float = 0.0, usage: list[UsageInfo] = list(), reasoning_traces: list[str] = list(), subagent_invocations: list[SubagentInvocation] = list(), permission_requested: bool = False, permissions: list[dict[str, Any]] = list(), model_used: str | None = None, raw_events: list[Any] = list()) dataclass

Result of running a prompt against GitHub Copilot.

Captures the full event stream from the SDK, including tool calls, reasoning traces, subagent routing, permissions, and token usage.

Example

result = await copilot_run(agent, "Create hello.py") assert result.success assert result.tool_was_called("create_file") assert "hello" in result.final_response.lower()

final_response: str | None property

Get the last assistant response.

all_responses: list[str] property

Get all assistant responses.

all_tool_calls: list[ToolCall] property

Get all tool calls across all turns.

tool_names_called: set[str] property

Get set of all tool names that were called.

total_input_tokens: int property

Total input tokens across all model turns.

total_output_tokens: int property

Total output tokens across all model turns.

total_tokens: int property

Total tokens (input + output) across all model turns.

total_cost_usd: float property

Total cost in USD across all model turns.

token_usage: dict[str, int] property

Token usage dict compatible with pytest-aitest's AgentResult.

cost_usd: float property

Cost in USD, compatible with pytest-aitest's AgentResult.

tool_was_called(name: str) -> bool

Check if a specific tool was called.

tool_call_count(name: str) -> int

Count how many times a specific tool was called.

tool_calls_for(name: str) -> list[ToolCall]

Get all calls to a specific tool.

Turn(role: str, content: str, tool_calls: list[ToolCall] = list()) dataclass

A single conversational turn.

text: str property

Get the text content of this turn.

ToolCall(name: str, arguments: dict[str, Any] | str, result: str | None = None, error: str | None = None, duration_ms: float | None = None, tool_call_id: str | None = None) dataclass

A tool call made by Copilot.

UsageInfo(model: str, input_tokens: int = 0, output_tokens: int = 0, cache_read_tokens: int = 0, cost_usd: float = 0.0, duration_ms: float = 0.0) dataclass

Token usage and cost from a single model turn.

SubagentInvocation(name: str, status: str, duration_ms: float | None = None) dataclass

A subagent invocation observed during execution.