Skip to content

feat(client): add session pooling for connection reuse TAV-4105#152

Merged
pulvedu merged 1 commit into
masterfrom
feat/TAV-4105-session-pooling
Jan 28, 2026
Merged

feat(client): add session pooling for connection reuse TAV-4105#152
pulvedu merged 1 commit into
masterfrom
feat/TAV-4105-session-pooling

Conversation

@tinosattavily
Copy link
Copy Markdown
Contributor

@tinosattavily tinosattavily commented Jan 26, 2026

Summary

  • Add requests.Session() to TavilyClient for HTTP connection pooling
  • Reuse TCP connections and TLS handshakes across API calls
  • Reduces per-request overhead (~100-300ms) for repeated calls
  • Add close() method and context manager support for resource cleanup
  • Remove deprecated get_company_info() method
  • Simplify public methods with direct returns

Test plan

  • Verify existing tests pass
  • Test multiple sequential API calls show connection reuse
  • Confirm no breaking changes to public API

Fixes TAV-4105


Note

Introduces connection pooling via requests.Session() in TavilyClient, with headers/proxies configured once. Adds close() and context manager support for resource cleanup.

  • Switches all HTTP calls in search/extract/crawl/map/research/get_research to self.session and minor refactors (URL/payload vars, timeout clamp)
  • Normalizes error handling (spaces in status lists) and ensures safe defaults with setdefault for results/failed_results
  • Simplifies wrappers to direct returns (crawl, map, research)
  • Removes deprecated get_company_info and unused concurrency import
  • Tests: adds MockSession and Interceptor.Session to support session-based requests in tests/request_intercept.py

Written by Cursor Bugbot for commit 5cdb58d. This will update automatically on new commits. Configure here.

@tinosattavily tinosattavily added feature New feature or enhancement priority-high High priority task size-s Small change labels Jan 26, 2026
@tinosattavily tinosattavily force-pushed the feat/TAV-4105-session-pooling branch 2 times, most recently from 6706b5e to 41d1c8e Compare January 27, 2026 16:41
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on February 21

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread tavily/tavily.py Outdated
- Add requests.Session() for HTTP connection pooling
- Add close() method and context manager support for resource cleanup
- Remove deprecated get_company_info() method
- Simplify public methods with direct returns
- Ensure response key normalization matches async client
- Update test interceptor to support Session mocking

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tinosattavily tinosattavily force-pushed the feat/TAV-4105-session-pooling branch from 41d1c8e to 5cdb58d Compare January 27, 2026 17:39
@pulvedu pulvedu merged commit 1d66aa3 into master Jan 28, 2026
8 checks passed
@pulvedu pulvedu deleted the feat/TAV-4105-session-pooling branch January 28, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or enhancement priority-high High priority task size-s Small change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants