Skip to content

Store large tool results as session dataframes and park slow calls as… - #56

Open
diego-ferrand wants to merge 2 commits into
developmentfrom
TASKS_AND_DATAFRAME
Open

diego-ferrand wants to merge 2 commits into
developmentfrom
TASKS_AND_DATAFRAME

Conversation

@diego-ferrand

Copy link
Copy Markdown
Collaborator

This pull request introduces several new modules and enhancements to the Perfecto MCP configuration, focusing on environment management, session and credential scoping, random ID generation, HTTP client reuse, remote cache serialization, and storage service authentication. Key changes include the addition of flexible environment variable helpers, context management for user/session identity, a robust cache codec for serializing complex types, and improved infrastructure for partitioned storage and cache selection.

The most important changes are:

Session and Identity Context Management

  • Added config/session_context.py, providing context managers and accessors for binding and retrieving the current user identity, session, and credential for each tool call. This enables partitioned storage and task isolation per user/session.
  • Introduced config/call_scope.py to derive stable user and session IDs from tokens and request contexts, ensuring consistent partitioning for storage and cache.

Environment and Configuration Handling

  • Added config/env.py with helpers for reading and validating environment variables (string, int, float, bool) with consistent naming and error handling.

Cache and Storage Infrastructure

  • Implemented config/cache_codec.py for serializing/deserializing complex Python and Pydantic model objects to JSON for remote cache storage, preserving types and supporting non-string dict keys.
  • Refactored config/runtime.py to select between in-memory and HTTP-based storage/cache providers based on environment variables, and to inject storage and cache dependencies into the application runtime. [1] [2] [3] [4]

HTTP Client and Service Authentication

  • Added config/http_clients.py to manage shared, cookie-less httpx.AsyncClient instances for efficient connection reuse and proper cleanup on shutdown.
  • Introduced config/service_auth.py for constructing headers and retrieving service authentication tokens for communication with the hosted storage service.

Utilities

  • Added config/ids.py for generating unambiguous, random base32 IDs used for tasks, dataframes, and chat sessions.

Additionally, the server shutdown logic in config/auth.py was improved to ensure proper closure of cache and HTTP clients.

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.

1 participant