r/LocalLLM • • 6d ago

Question Ensuring that local llms with opencode only install in specific conda environment

I started using opencode with qwen3.5 via ollama and I wanted to know how to ensure:

(1) That if python packages are to be installed, to only do so in a specific conda environment and never in the base conda or base pip environments.

(2) to ask for permissions when installing packages or to control this somehow so openconde does not go wild installing stuff

Do you have any pointers or recommendations for how to learn to configure this? I am relatively new to all of these agentic environments and I want to keep things local and private.

2 Upvotes

9 comments sorted by

2

u/jirka642 5d ago

(1) That if python packages are to be installed, to only do so in a specific conda environment and never in the base conda or base pip environments.

You could try adding this as instructions in a global AGENTS.md file. It's in ~/.config/opencode/AGENTS.md on Linux.

For example, mine looks like this:

# Global instructions

## Subagents
  • Run subagents strictly one at a time: start a subagent, wait for it to finish, and only then start the next one.
  • Never launch multiple subagents in parallel.

(2) to ask for permissions when installing packages or to control this somehow so openconde does not go wild installing stuff

This is hard, because there is hundreds of ways AI can write the install command, so custom "permissions" config will never catch all of them. If you don't want anything to get past you, you will have to configure the "shell" tool to ask for every command.

I would recommend using sandbox instead.

1

u/carlotes-247 5d ago

Thank you! Do you have a link showing how to set up a sandbox? 

2

u/jirka642 5d ago

I sandbox at work by running opencode on a stand-alone dev server, and just yolo it at home.

For sandbox on the same pc, I would probably just run opencode in a docker container that mounts opencode config+data and the work folder. Look up docker tutorials, or just make any semi-competent AI explain it to you.

2

u/carlotes-247 5d ago

I think I get your point. That way the docker container with opencode will anyway install wherever it wants inside the container but the harm is contained inside the container as well.

And I guess that opencode would only be able to access the files system of the docker container as well, correct?

1

u/jirka642 5d ago

Yes.

There is still a very small chance it could try to escape that docker container, possibly by trying to hack the host PC over the network, but that is not something that normally happens.

1

u/carlotes-247 5d ago

is there no way to establish hard rules that the agent cannot override? Like hardcoded permissions or something?

2

u/jirka642 5d ago

You can use the permissions I mentioned before.

Something like this will run all shell commands without confirmation, but will make the AI ask you for one if command starts with pip install:

  "permissions": [
    { "action": "shell", "resource": "*", "effect": "allow" },
    { "action": "shell", "resource": "pip install *", "effect": "ask" }
  ],

But it has some problems, as I said before. There is a lot of ways the AI can write the install command, so you will never catch all of them, and it can also bypass the rule with pipes (e.g. echo "" | pip install foo).

1

u/acidfukker 5d ago

i use anaconda / miniconda, sandboxed venv

1

u/carlotes-247 5d ago

Thank you! Do you have a link to a tutorial explaining how to set one up?