Skip to main content

Overview

getCtxWindow() retrieves a previously created and registered context window by its index name. This function works in conjunction with createCtxWindow().
Use this to access context windows that were registered using createCtxWindow().

Signature

Parameters

namespace
string
required
The unique identifier of the context window to retrieve. Must match the namespace used when creating the context window with createCtxWindow().

Return Value

ContextWindow
object
The registered context window instance

Errors

Throws an error if no context window with the specified namespace exists in the registry.

Examples

Basic Usage

Using Across Modules

Safe Retrieval with Error Handling

Multiple Context Windows

Express.js Middleware Pattern

Lazy Loading Pattern

Best Practices

1. Check Before Retrieving

Always verify a context window exists before retrieving:

2. Use Constants for Index Names

Define index names as constants to avoid typos:

3. Centralize Access

Create a service layer for accessing context windows:

Common Patterns

Singleton Pattern

Factory Pattern

Error Handling

Debugging Tips

List All Context Windows

Log on Retrieval

createCtxWindow

Create and register a context window

hasCtxWindow

Check if a context window exists

ask()

Query a context window

Utility Functions

Registry management functions