Skip to content

[FEATURE]: Unify shell initialization behavior between user shell and agent bash tool #17792

@bakabaka9405

Description

@bakabaka9405

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

There is an inconsistency between the user-invoked shell (!) and the agent bash tool.
At the moment:

  • the user ! shell loads shell init files such as ~/.bashrc
  • the agent bash tool does not
    As a result, the same command can work in the user shell but fail in the agent shell because functions, aliases, exports, or PATH changes from shell init are only available in one path.

Reproduction

Example ~/.bashrc:

myfunc() {
  echo ok
}
export -f myfunc

Then compare:

  1. Run myfunc through the user shell (!)
  2. Run the equivalent command through the agent bash tool
    Actual behavior
  • User ! shell can access definitions and environment initialized by shell startup files
  • Agent bash tool cannot

Expected behavior

These two shell execution paths should behave consistently.
Possible acceptable outcomes:

  • both load shell init files in the same way, or
  • both avoid loading shell init files, or
  • a config/flag makes the behavior explicit and shared between both paths

Notes

The current implementation appears to use different logic for these paths:

  • packages/opencode/src/session/prompt.ts
    user shell path explicitly sources shell init files for some shells
  • packages/opencode/src/tool/bash.ts
    agent bash tool uses spawn(..., { shell }) without equivalent shell init loading
    This creates surprising differences between manual shell usage and agent-executed shell commands.

Request

Please unify the shell initialization logic between:

  • user ! shell
  • agent bash tool
    If exact unification is not desired, please provide a documented configuration option that controls shell init behavior consistently for both paths.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

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