Skip to main content

Overview

context-window provides utility functions to manage context windows in the global registry. These work alongside createCtxWindow() and getCtxWindow().
These functions only affect the in-memory registry, not your Pinecone data.

hasCtxWindow

Check if a context window exists in the registry.

Signature

Parameters

namespace
string
required
The index name to check for

Returns

true if a context window with the given name exists, false otherwise.

Examples

Use Cases

Conditional Initialization:
Safe Retrieval:

deleteCtxWindow

Remove a context window from the registry.

Signature

Parameters

namespace
string
required
The index name of the context window to remove

Returns

true if the context window was deleted, false if it didn’t exist.

Examples

Use Cases

Cleanup After Use:
Session Management:
deleteCtxWindow() only removes the reference from the in-memory registry. It does NOT delete data from Pinecone.

clearCtxWindows

Remove all context windows from the registry.

Signature

Parameters

None

Returns

void

Examples

Use Cases

Application Shutdown:
Test Cleanup:
Reset Application State:
Like deleteCtxWindow(), this only clears the in-memory registry. Pinecone data remains untouched.

listCtxWindows

Get a list of all registered context window names.

Signature

Parameters

None

Returns

Array of index names for all registered context windows.

Examples

Use Cases

Status Endpoint:
Debug Information:
Validation:
Bulk Operations:

Complete Examples

Application Health Check

Session-Based Context Windows

Multi-Tenant Application

Development vs Production

Best Practices

1. Always Check Before Using

2. Use Constants

3. Cleanup When Done

4. Validate on Startup

createCtxWindow

Create and register context windows

getCtxWindow

Retrieve registered context windows

Examples

See complete implementations

Best Practices

Registry management best practices