Skip to content

AI adapters create dual divergent interpreter instances #990

@chaliy

Description

@chaliy

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.ts lines 107-108
  • crates/bashkit-js/anthropic.ts lines 121-122
  • crates/bashkit-js/openai.ts lines 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 BashTool describes different state than execution Bash instance
  • Potential information leakage if system prompt reflects stale VFS state

Acceptance Criteria

  • Use a single BashTool instance 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity vulnerability or hardening

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions