Skip to content

GUI/Shell Tool Does Not Maintain Working Directory State Between Commands #2

@paulsonak

Description

@paulsonak

Bug Report: Shell Tool Does Not Maintain Working Directory State Between Commands

Summary

The biorouter GUI shell tool does not persist working directory changes between successive tool calls, causing each shell command to execute in the original working directory rather than maintaining directory state from previous commands. The baseline working directory won't change until the app is restarted.

Environment

  • Software: biorouter (BioRouter Desktop application)
  • Extension: Developer extension (shell tool)
  • Operating System: macOS
  • Shell: /bin/zsh
  • Date: 2026-06-04

Expected Behavior

When using the shell tool to change directories (e.g., cd /path/to/directory), subsequent shell commands should execute in the new working directory, maintaining the directory state across tool calls.

Actual Behavior

Each shell command executes in isolation, reverting to the original working directory regardless of previous cd commands. Directory changes do not persist between shell tool invocations.

Steps to Reproduce

  1. Start a new biorouter chat in the GUI. The default directory is what you were using in previous chat(s) (e.g., ~/Directory1)
  2. Use the GUI to select a new working directory from the bottom left folder button (e.g. ~/Directory2)
    a. Ask biorouter what directory it is in and it will tell you Directory2
    b. Ask biorouter to pwd and it will print Directory1
  3. Ask biorouter to change to Directory 2 and it will run: cd ~/Directory2 && pwd
    • Result: Shows `~/Directory2
  4. Ask biorouter to pwd: pwd in a separate shell tool call
    • Result: Shows original directory ~/Directory1
    • Biorouter will notice and explain the discrepancy but not fix the problem

Technical Details

  • Each shell tool call appears to spawn a new process/subshell
  • Working directory changes made in one tool call do not affect subsequent tool calls
  • The behavior is consistent with the documented limitation: "Each shell command runs in its own process"
  • Current workaround requires chaining commands with && in a single tool call

Impact

  • Workflow disruption: Users must repeatedly navigate to desired directories
  • Command complexity: Simple multi-step operations require complex command chaining
  • User confusion: Expected shell behavior (persistent directory state) is not maintained
  • Reduced productivity: Additional overhead for directory management in multi-step tasks

Suggested Solutions

Option 1: Session State Management

Implement a persistent shell session that maintains state across tool calls, similar to how interactive terminal sessions work.

Option 2: Working Directory Context

Add a working_directory parameter to the shell tool that allows specifying the execution directory for each command.

Option 3: Directory State Tracking

Implement internal tracking of directory changes made through cd commands and automatically prepend the appropriate cd command to subsequent shell calls.

Option 4: Enhanced Documentation

If the current behavior is intentional, enhance documentation with clearer examples of multi-command workflows and best practices for directory management.

Workarounds

Currently, users must chain related commands in a single tool call:

cd /target/directory && command1 && command2 && command3

It seems that restarting the app leads to the user's selected directory to be loaded as the working directory (ie the Directory2 is now loaded as default after restarting instead of Directory1)

Priority

Medium - This impacts user experience and workflow efficiency, but workarounds exist. It seems like the quality of model or perhaps loaded skills dictates how easily the chaining workaround can be implemented and remembered.


Please provide the following information

  • OS & Arch: macos 25.5.0 aarch64
  • Interface: UI
  • Version: 1.75.2
  • Extensions enabled: todo, chatrecall, skills, developer, memory, codegraphagent
  • Provider & Model: versa_bedrock – us.anthropic.claude-sonnet-4-20250514-v1:0

Additional context
diagnostics_20260604_108.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions