Skip to content

Issue 5#6

Open
tedhabeck wants to merge 34 commits intocontextforge-org:mainfrom
tedhabeck:issue-5
Open

Issue 5#6
tedhabeck wants to merge 34 commits intocontextforge-org:mainfrom
tedhabeck:issue-5

Conversation

@tedhabeck
Copy link
Contributor

@tedhabeck tedhabeck commented Mar 10, 2026

Summary

Closes: #5

Changes

This branch represents a significant architectural enhancement enabling plugins to run in isolated Python environments, improving security, dependency management, and plugin compatibility.

Key Enhancements

  1. Plugin Isolation via Virtual Environment (Primary Feature)

    New Core Modules:

    • cpex/framework/isolated/client.py - Client for managing isolated plugin execution
    • cpex/framework/isolated/worker.py - Worker process for executing plugins in isolation
    • cpex/framework/isolated/venv_comm.py - Communication layer between host and isolated environment
  2. Venv Cache Support
    Caching mechanism for virtual environments to improve performance
    Reduces overhead of repeated venv creation

  3. Serialization Support
    Enhanced serialization capabilities for plugin data exchange
    Supports communication between isolated environments

  4. Configuration Support
    New fixture: isolated_plugin.yaml for testing isolated plugin configurations
    Updated loader to support isolated plugin mode

Checks

  • make lint passes
  • make test passes
  • CHANGELOG updated (if user-facing)

Notes (optional)

Performance Optimization Complete ✓

Restructured the isolated venv plugin system to use a long-running worker process instead of forking a new subprocess for each invocation.

Performance Improvements

Before (forking new process each time):

prompt_pre_fetch: 0.147ms avg
prompt_post_fetch: 0.155ms avg
tool_pre_invoke: 0.143ms avg
tool_post_invoke: 0.149ms avg
Average: ~0.148ms per invocation

After (long-running worker process):

prompt_pre_fetch: 0.045ms avg
prompt_post_fetch: 0.047ms avg
tool_pre_invoke: 0.043ms avg
tool_post_invoke: 0.044ms avg
Average: ~0.045ms per invocation
Performance Gain: 3.3x faster (70% reduction in latency)

Example Plugin directory structure with venv configured:

image

tedhabeck added 30 commits March 5, 2026 15:55
…or the PluginPackageInfo class and created 34 unit tests to verify their functionality

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
…_pre_invoke, and agent_post_invoke

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
…ed tests

Signed-off-by: habeck <habeck@us.ibm.com>
…ent.py to run async

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
…gin.

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
Forking a new Python process (~1.2ms per fork_exec)
Initializing the Python interpreter
Loading modules and dependencies
Setting up the subprocess communication pipes

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
…ically, update cli to support creating an isolated plugin.

Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
@tedhabeck tedhabeck marked this pull request as ready for review March 12, 2026 23:01
Signed-off-by: habeck <habeck@us.ibm.com>
Signed-off-by: habeck <habeck@us.ibm.com>
@araujof araujof added enhancement New feature or request framework labels Mar 20, 2026
@araujof araujof added this to the 0.1.0 milestone Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Virtual Environment Isolation

3 participants