-
Notifications
You must be signed in to change notification settings - Fork 7
AI adapters create dual divergent interpreter instances #990
Copy link
Copy link
Closed
Labels
securitySecurity vulnerability or hardeningSecurity vulnerability or hardening
Description
Summary
All three AI adapters (ai.ts, anthropic.ts, openai.ts) create two separate interpreter instances: a BashTool (for metadata) and a Bash (for execution). Files are written to the Bash instance but not to BashTool. The system prompt comes from BashTool but execution happens on Bash, creating state divergence and wasting resources.
Severity: Medium
Category: Logic Error / Resource Waste
Affected Files
crates/bashkit-js/ai.tslines 107-108crates/bashkit-js/anthropic.tslines 121-122crates/bashkit-js/openai.tslines 124-125
Code
const bashToolInstance = new BashTool(bashOptions);
const bash = new Bash(bashOptions);Impact
- Double memory allocation (two full interpreters per AI session)
- System prompt from
BashTooldescribes different state than executionBashinstance - Potential information leakage if system prompt reflects stale VFS state
Acceptance Criteria
- Use a single
BashToolinstance for both metadata and execution - Or: extract metadata statically without creating a second interpreter
- Test: AI adapter uses single interpreter instance
- Test: System prompt reflects actual execution state
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
securitySecurity vulnerability or hardeningSecurity vulnerability or hardening