I’m trying to get the exit code for shell tool execution completion from the SDK tool.execution_complete event.
The SDK types suggest this should be available through terminal content on the tool result:
// node_modules/@github/copilot-sdk/dist/generated/session-events.d.ts
export interface ToolExecutionCompleteEvent {
data: ToolExecutionCompleteData;
type: "tool.execution_complete";
}
export interface ToolExecutionCompleteData {
result?: ToolExecutionCompleteResult;
success: boolean;
toolCallId: string;
}
export interface ToolExecutionCompleteResult {
content: string;
contents?: ToolExecutionCompleteContent[];
detailedContent?: string;
structuredContent?: {
[k: string]: unknown | undefined;
};
}
export interface ToolExecutionCompleteContentTerminal {
cwd?: string;
exitCode?: number;
text: string;
type: "terminal";
}
Given that shape, I expected the shell command exit code to be available from the completed tool event payload like this:
session.on("tool.execution_complete", event => {
const terminalContent = event.data.result?.contents?.find(
content => content.type === "terminal"
);
const exitCode = terminalContent?.exitCode;
});
In other wordsL event.data.result?.contents?.find(c => c.type === "terminal")?.exitCode
Actual behavior seems to be tool.execution_complete just returning flattened text in event.data.result
event.data.result = {
content: "...<shellId: 0 completed with exit code 0>",
detailedContent: "...<shellId: 0 completed with exit code 0>"
}
Should the built-in shell/bash tool populate ToolExecutionCompleteResult.contents with a ToolExecutionCompleteContentTerminal block containing exitCode and cwd?

I’m trying to get the exit code for shell tool execution completion from the SDK
tool.execution_completeevent.The SDK types suggest this should be available through terminal content on the tool result:
Given that shape, I expected the shell command exit code to be available from the completed tool event payload like this:
In other wordsL
event.data.result?.contents?.find(c => c.type === "terminal")?.exitCodeActual behavior seems to be
tool.execution_completejust returning flattened text inevent.data.resultShould the built-in shell/bash tool populate ToolExecutionCompleteResult.contents with a ToolExecutionCompleteContentTerminal block containing exitCode and cwd?