Skip to content

docs: clarify abort-on-function-call example#1843

Open
Rohan5commit wants to merge 1 commit intoopenai:masterfrom
Rohan5commit:docs/abort-example-clarification-20260426
Open

docs: clarify abort-on-function-call example#1843
Rohan5commit wants to merge 1 commit intoopenai:masterfrom
Rohan5commit:docs/abort-example-clarification-20260426

Conversation

@Rohan5commit
Copy link
Copy Markdown

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Clarify the Abort on a function call example so it no longer calls finalFunctionCall() after runner.abort(), and document that the final* helpers reject once the run has been aborted.

Additional context & links

@Rohan5commit Rohan5commit requested a review from a team as a code owner April 26, 2026 03:08
Copilot AI review requested due to automatic review settings April 26, 2026 03:08
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc00784557

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread helpers.md

const finalFunctionCall = await runner.finalFunctionCall();
console.log('Final function call:', finalFunctionCall);
await runner.done().catch(() => {});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle only abort errors in done() catch

This line suppresses all failures from runner.done(), not just the expected APIUserAbortError from runner.abort(). In the example, network/auth/API errors would be silently ignored and execution would continue as if the run ended normally, which can mislead users copying this pattern. Catching and filtering only abort errors (and rethrowing others) would keep the abort example accurate without hiding real failures.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates helpers.md to clarify how aborting a runTools() flow behaves, specifically that calling runner.abort() ends the run and causes final* helpers to reject, and adjusts the “Abort on a function call” example accordingly.

Changes:

  • Refines the narrative around aborting a runner and the consequences for final* helpers.
  • Updates the example to capture the terminating tool invocation inside the tool function and wait on runner.done().
  • Adds an abort event handler in the example output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread helpers.md

const finalFunctionCall = await runner.finalFunctionCall();
console.log('Final function call:', finalFunctionCall);
await runner.done().catch(() => {});
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await runner.done().catch(() => {}); swallows all errors (network/API errors, parsing errors, etc.), not just the expected abort. This can lead readers to silently ignore failures. Catch the error and only ignore APIUserAbortError (or check error.name === 'APIUserAbortError'), and rethrow anything else.

Suggested change
await runner.done().catch(() => {});
try {
await runner.done();
} catch (error) {
if ((error as { name?: string })?.name !== 'APIUserAbortError') {
throw error;
}
}

Copilot uses AI. Check for mistakes.
Comment thread helpers.md
Comment on lines 615 to 618
function: function updateDatabase(props, runner) {
runner.abort()
terminatingCall = props;
runner.abort();
},
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example terminatingCall is assigned props, which are the tool/function arguments, not the full function/tool call (name/id/raw arguments). The variable name and log message (“Function call that ended the run”) are misleading; consider renaming to reflect that it’s arguments, or capture the actual tool call object via the appropriate event and log that instead.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abort on a function call example is confusing

3 participants