Skip to content

Wire request timeout and 429/5xx retry onto Pinecone I/O hot path - #225

Merged
wpak-ai merged 8 commits into
cppalliance:mainfrom
jonathanMLDev:fix/wire-timeout-retry-hot-path
Jul 17, 2026
Merged

Wire request timeout and 429/5xx retry onto Pinecone I/O hot path#225
wpak-ai merged 8 commits into
cppalliance:mainfrom
jonathanMLDev:fix/wire-timeout-retry-hot-path

Conversation

@jonathanMLDev

@jonathanMLDev jonathanMLDev commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add runWithPolicy (withRetry + withTimeout) with transientShouldRetry so app-level timeouts fail fast while 429/502/503/504 and network errors get bounded backoff
  • Apply the policy to search, rerank, describeIndexStats, namespace metadata sampling, and fetchRecordFields
  • Thread requestTimeoutMs from PineconeClient through PineconeIndexSession.getRequestTimeoutMs() into all outbound call sites
  • Deduplicate timeout detection via isAppTimeoutError (shared by search.ts and tool-error.ts)

Test plan

  • npm run ci green (415 tests, 85%+ coverage)
  • Retry/timeout/non-retry tests in retry.test.ts, search.test.ts, rerank.test.ts, indexes.test.ts, pinecone-client.test.ts

Follow-up (not in scope)

Hybrid per-leg search timeouts are logged but still surface as a generic error when both legs fail; TIMEOUT tool-error classification for partial hybrid degradation is unchanged.

Related Issue

Summary by CodeRabbit

  • Reliability Improvements
    • Added consistent, configurable request timeouts across Pinecone search (including hybrid), index reachability checks, namespace metadata sampling, record field fetching, and reranking.
    • Improved retry behavior: retry only transient failures, fail fast for non-retryable errors, and immediately surface app-level timeout errors (including when hybrid legs fail).
    • Hybrid search now propagates timeout errors more precisely instead of falling back to a generic failure.
  • Tooling/Errors
    • Improved timeout classification and standardized tool error message logging for clearer diagnostics.
  • Testing
    • Expanded coverage for timeout propagation, retry/degradation behavior, and SDK conformance edge cases.

@jonathanMLDev jonathanMLDev self-assigned this Jul 15, 2026
@jonathanMLDev
jonathanMLDev requested a review from wpak-ai as a code owner July 15, 2026 21:44
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad0ccc75-245a-4b70-9cec-febd3bcc1968

📥 Commits

Reviewing files that changed from the base of the PR and between 1f79882 and a459d1d.

📒 Files selected for processing (3)
  • src/core/pinecone/indexes.test.ts
  • src/core/pinecone/indexes.ts
  • src/core/pinecone/searchable-index-conformance.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/core/pinecone/indexes.ts
  • src/core/pinecone/indexes.test.ts

📝 Walkthrough

Walkthrough

Pinecone outbound operations now use centralized per-attempt timeouts and transient retries. Configured timeouts propagate through search and reranking, index-session calls are wrapped consistently, and timeout classification uses shared retry utilities. Tests cover retries, non-retryable errors, timeout behavior, propagation, and degradation.

Changes

Pinecone timeout and retry policy

Layer / File(s) Summary
Centralized I/O policy and timeout classification
src/core/server/retry.ts, src/core/server/retry.test.ts, src/core/server/tool-error.ts
Adds timeout classification, transient retry selection, and runWithPolicy orchestration with redacted retry logging; tool errors use the shared timeout predicate.
Index session request policy wiring
src/core/pinecone/indexes.ts, src/core/pinecone/indexes.test.ts, src/core/pinecone/searchable-index-conformance.test.ts
Adds request-timeout access and wraps index statistics, metadata sampling, record fetching, and reachability calls with labeled timeout/retry policy execution while validating SDK receiver binding.
Search and rerank policy integration
src/core/pinecone/search.ts, src/core/pinecone/rerank.ts, src/core/pinecone-client.ts, src/core/pinecone/*test.ts
Propagates configured timeouts into search and reranking, preserves timeout propagation through hybrid queries, and tests retries, timeout behavior, and rerank degradation.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PineconeClient
  participant PineconeIndexSession
  participant runWithPolicy
  participant Pinecone
  PineconeClient->>PineconeIndexSession: getRequestTimeoutMs()
  PineconeClient->>runWithPolicy: execute search or rerank with timeout
  runWithPolicy->>Pinecone: Pinecone request
  Pinecone-->>runWithPolicy: result or transient error
  runWithPolicy-->>PineconeClient: result, retry, or timeout
Loading

Possibly related PRs

Suggested reviewers: wpak-ai, auramindnest, leostar0412, timon0305

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed It clearly summarizes the main change: adding request-timeout handling and transient retry to Pinecone I/O.
Linked Issues check ✅ Passed The PR threads requestTimeoutMs through Pinecone calls and adds bounded retries/timeouts across search, rerank, stats, and metadata sampling.
Out of Scope Changes check ✅ Passed The extra logging and receiver-binding tests support the retry/timeout refactor and don't introduce unrelated behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@98d0164). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/core/pinecone/indexes.ts 93.33% 2 Missing ⚠️
src/core/pinecone/search.ts 90.47% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #225   +/-   ##
=======================================
  Coverage        ?   85.86%           
=======================================
  Files           ?       47           
  Lines           ?     2512           
  Branches        ?      852           
=======================================
  Hits            ?     2157           
  Misses          ?      354           
  Partials        ?        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/core/pinecone/indexes.ts (2)

277-317: 🩺 Stability & Availability | 🔵 Trivial

Startup reachability check inherits default retries, extending failure-detection time.

checkIndexes() is meant to fail fast before the server starts, but each runIo call here uses the default 2 retries with backoff, so an unreachable endpoint could take up to ~3x the per-attempt timeout (default 15s) plus backoff before --check-indexes reports failure. Consider passing a lower retries (e.g., 0) for this specific health-check path if fast failure at startup is preferred over resilience.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/pinecone/indexes.ts` around lines 277 - 317, Update the two runIo
calls in checkIndexes—describeIndexStats-dense and describeIndexStats-sparse—to
pass retries: 0 for this startup reachability check, while leaving runIo
defaults unchanged elsewhere.

64-67: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

runIo silently drops the AbortSignal from runWithPolicy.

runWithPolicy's fn parameter is typed (signal: AbortSignal) => Promise<T>, but runIo calls it as () => fn(), so the signal from withTimeout's AbortController never reaches the wrapped SDK calls. Since all runIo call sites are read-only (stats/fetch/query), this isn't a correctness issue, just means in-flight requests keep running in the background after a timeout is declared (wasted request, no actual cancellation). Consider forwarding the signal for consistency with the policy's cancellation contract, even if unused today.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/pinecone/indexes.ts` around lines 64 - 67, Update the private runIo
method to accept the AbortSignal supplied by runWithPolicy and forward it to the
wrapped callback, preserving the existing timeout and policy options while
maintaining the current call-site behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/pinecone-client.ts`:
- Around line 108-116: Import isAppTimeoutError from the retry module and update
the Promise.allSettled rejection handling in query: when both dense and sparse
searches reject, rethrow whichever rejection is an application timeout before
falling back to the existing generic hybrid-search error.

---

Nitpick comments:
In `@src/core/pinecone/indexes.ts`:
- Around line 277-317: Update the two runIo calls in
checkIndexes—describeIndexStats-dense and describeIndexStats-sparse—to pass
retries: 0 for this startup reachability check, while leaving runIo defaults
unchanged elsewhere.
- Around line 64-67: Update the private runIo method to accept the AbortSignal
supplied by runWithPolicy and forward it to the wrapped callback, preserving the
existing timeout and policy options while maintaining the current call-site
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ddb4027-c7c9-4e88-9aa2-5c5929cf066f

📥 Commits

Reviewing files that changed from the base of the PR and between bd94c14 and 8dc02f7.

📒 Files selected for processing (11)
  • src/core/pinecone-client.test.ts
  • src/core/pinecone-client.ts
  • src/core/pinecone/indexes.test.ts
  • src/core/pinecone/indexes.ts
  • src/core/pinecone/rerank.test.ts
  • src/core/pinecone/rerank.ts
  • src/core/pinecone/search.test.ts
  • src/core/pinecone/search.ts
  • src/core/server/retry.test.ts
  • src/core/server/retry.ts
  • src/core/server/tool-error.ts

Comment thread src/core/pinecone-client.ts
@jonathanMLDev

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/core/pinecone/indexes.ts (1)

64-67: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

AbortSignal from runWithPolicy is never used to cancel the underlying Pinecone call.

runIo, searchIndex, and rerankResults all accept a signal/_signal parameter from runWithPolicy but never pass it to the actual SDK call. On timeout, the promise wrapper rejects but the in-flight HTTP request to Pinecone keeps running; combined with retries, transient outages can pile up multiple abandoned in-flight requests per logical call.

  • src/core/pinecone/indexes.ts#L64-L67: forward the signal into fn if the SDK call site supports an abort option.
  • src/core/pinecone/search.ts#L44-L87: forward _signal into index.search/target.searchRecords if supported.
  • src/core/pinecone/rerank.ts#L27-L53: forward _signal into pc.inference.rerank if supported.

Please check whether @pinecone-database/pinecone v8 SDK calls accept an AbortSignal/similar cancellation option before wiring this through.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/pinecone/indexes.ts` around lines 64 - 67, Verify the
`@pinecone-database/pinecone` v8 SDK cancellation API, then update runIo in
src/core/pinecone/indexes.ts (lines 64-67) to pass runWithPolicy’s AbortSignal
into fn and propagate it through the SDK request options where supported. In
src/core/pinecone/search.ts (lines 44-87), forward _signal to index.search and
target.searchRecords; in src/core/pinecone/rerank.ts (lines 27-53), forward
_signal to pc.inference.rerank. Preserve behavior without inventing unsupported
SDK options, and ensure the signal reaches every supported underlying Pinecone
call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/core/pinecone/indexes.ts`:
- Around line 64-67: Verify the `@pinecone-database/pinecone` v8 SDK cancellation
API, then update runIo in src/core/pinecone/indexes.ts (lines 64-67) to pass
runWithPolicy’s AbortSignal into fn and propagate it through the SDK request
options where supported. In src/core/pinecone/search.ts (lines 44-87), forward
_signal to index.search and target.searchRecords; in src/core/pinecone/rerank.ts
(lines 27-53), forward _signal to pc.inference.rerank. Preserve behavior without
inventing unsupported SDK options, and ensure the signal reaches every supported
underlying Pinecone call.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8025bcb1-d2d4-406a-910e-8978a7f43cfa

📥 Commits

Reviewing files that changed from the base of the PR and between bd94c14 and 4f71749.

📒 Files selected for processing (11)
  • src/core/pinecone-client.test.ts
  • src/core/pinecone-client.ts
  • src/core/pinecone/indexes.test.ts
  • src/core/pinecone/indexes.ts
  • src/core/pinecone/rerank.test.ts
  • src/core/pinecone/rerank.ts
  • src/core/pinecone/search.test.ts
  • src/core/pinecone/search.ts
  • src/core/server/retry.test.ts
  • src/core/server/retry.ts
  • src/core/server/tool-error.ts

Comment thread src/core/pinecone/indexes.ts Outdated
Comment thread src/core/pinecone/indexes.ts
Comment thread src/core/pinecone/indexes.test.ts
@jonathanMLDev
jonathanMLDev requested a review from wpak-ai July 17, 2026 18:04
@wpak-ai
wpak-ai merged commit 8bbcfe2 into cppalliance:main Jul 17, 2026
12 checks passed
@jonathanMLDev
jonathanMLDev deleted the fix/wire-timeout-retry-hot-path branch July 30, 2026 18:02
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.

Wire request timeout + 429/5xx retry/backoff on the live hot path

3 participants