Skip to content

docs: add tool confirmation flow example to agents chat()#2543

Merged
ks93 merged 6 commits intomasterfrom
docs/tool-confirmation-flow
Mar 31, 2026
Merged

docs: add tool confirmation flow example to agents chat()#2543
ks93 merged 6 commits intomasterfrom
docs/tool-confirmation-flow

Conversation

@andeplane
Copy link
Copy Markdown
Contributor

Summary

  • Adds a Handle tool confirmation example to AgentsAPI.chat() showing the full ToolConfirmationCallToolConfirmationResult flow for integration tools (Call Function, Run Python code, Call REST API)
  • Improves ToolConfirmationCall docstring to explain which tools trigger confirmation and what to do with it
  • Improves ToolConfirmationResult docstring to explain usage and the importance of passing the cursor

Context

Users calling Atlas AI agents via the SDK are confused when they receive a ToolConfirmationCall action in the response and don't know how to handle it. The existing docstring examples only covered basic chat and client-side tool actions — this adds the missing confirmation flow.

Relates to feedback from: topic-ai-agents Slack thread (Nov 2025).

Test plan

  • Verify doctests pass: python -m pytest --doctest-modules cognite/client/_api/agents/
  • Confirm the new example renders correctly in the SDK docs

🤖 Generated with Claude Code

Add a docstring example showing how to detect and respond to a
ToolConfirmationCall when using integration tools (Call Function,
Run Python code, Call REST API) that require explicit user approval.

Also improve ToolConfirmationCall and ToolConfirmationResult docstrings
to explain which tools trigger confirmation and how to use them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.42%. Comparing base (ef5ac04) to head (9ef6f12).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2543      +/-   ##
==========================================
- Coverage   93.43%   93.42%   -0.01%     
==========================================
  Files         478      478              
  Lines       48230    48230              
==========================================
- Hits        45062    45060       -2     
- Misses       3168     3170       +2     
Files with missing lines Coverage Δ
cognite/client/_api/agents/agents.py 100.00% <ø> (ø)
cognite/client/_sync_api/agents/agents.py 100.00% <ø> (ø)
cognite/client/data_classes/agents/chat.py 98.12% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Clarify that some tools require explicit confirmation before execution so the agent chat response flow is easier to understand.
ks93
ks93 previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Contributor

@ks93 ks93 left a comment

Choose a reason for hiding this comment

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

Tested in Jupyter and works.

@ks93 ks93 marked this pull request as ready for review March 31, 2026 02:33
@ks93 ks93 requested review from a team as code owners March 31, 2026 02:33
@ks93 ks93 added the waiting-for-risk-review Waiting for a member of the risk review team to take an action label Mar 31, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the developer experience for the Atlas AI agents SDK by providing clear guidance on how to handle tool confirmation requests. By adding practical examples and clarifying the documentation for confirmation-related classes, it addresses common user confusion regarding the interaction flow for sensitive tools.

Highlights

  • Documentation Update: Added a comprehensive code example to the AgentsAPI.chat() docstring demonstrating the full tool confirmation flow.
  • Clarified Tool Confirmation: Updated docstrings for ToolConfirmationCall and ToolConfirmationResult to better explain the purpose, usage, and required parameters for handling integration tools.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation for agent tool confirmations, adding usage examples and clarifying the purpose of ToolConfirmationCall and ToolConfirmationResult. A review of the new docstring example identified potential logic errors, specifically a possible TypeError if action_calls is None and incorrect cursor management when processing multiple actions within a loop.

ks93 added 3 commits March 30, 2026 19:39
Update the generated sync agents API so it stays aligned with the async agents chat documentation changes and passes sync codegen verification.
Align the agents documentation changes with repo formatting, docstring, and sync codegen requirements so CI passes without hook-generated diffs.
Update the tool confirmation example to guard against missing action calls and batch confirmation results so the cursor usage stays consistent when multiple actions are returned.
@ks93 ks93 enabled auto-merge March 31, 2026 02:50
@ks93 ks93 self-requested a review March 31, 2026 03:04
Copy link
Copy Markdown
Contributor

@ks93 ks93 left a comment

Choose a reason for hiding this comment

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

Works!

Comment on lines +360 to +361
... print(f"Tool: {action.tool_name}, type: {action.tool_type}")
... print(f"Arguments: {action.tool_arguments}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should ideally use the input function

Copy link
Copy Markdown
Contributor

@haakonvt haakonvt left a comment

Choose a reason for hiding this comment

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

🦄

@ks93 ks93 added this pull request to the merge queue Mar 31, 2026
@haakonvt haakonvt self-assigned this Mar 31, 2026
@haakonvt haakonvt added risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action and removed waiting-for-risk-review Waiting for a member of the risk review team to take an action labels Mar 31, 2026
Merged via the queue into master with commit b76c56b Mar 31, 2026
35 of 36 checks passed
@ks93 ks93 deleted the docs/tool-confirmation-flow branch March 31, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk-review-ongoing Risk review is in progress waiting-for-team Waiting for the submitter or reviewer of the PR to take an action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants