Skip to content

[Draft] Use explicit context managers for Agent and Toolset #2381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

strawgate
Copy link
Contributor

For discussion

Use explicit yielding async context managers for Agent and Toolsets.

This allows toolsets and Agents to be entered and exited more granularly as exitstacks only allow exiting all accumulated context managers at once.

I dont expect this to be merged but just wanted to noodle on it

Copy link
Contributor

hyperlint-ai bot commented Jul 31, 2025

PR Change Summary

Implemented explicit async context managers for Agent and Toolset to enhance connection management.

  • Replaced implicit context manager usage with explicit agent.setup() calls.
  • Improved documentation examples to reflect the new context manager usage.
  • Clarified the efficiency of using explicit context managers in agent runs.

Modified Files

  • docs/mcp/client.md
  • mcp-run-python/README.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@strawgate strawgate force-pushed the explicit_context_managers branch 2 times, most recently from 09cdc83 to 0a21f84 Compare July 31, 2025 13:10
@strawgate strawgate force-pushed the explicit_context_managers branch from 0a21f84 to f72faff Compare July 31, 2025 14:52
@DouweM DouweM marked this pull request as draft August 1, 2025 16:22
@DouweM DouweM self-assigned this Aug 1, 2025
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.

2 participants