DEV Community

Jordan Huang
Jordan Huang

Posted on

Which Python Did the Agent Launch? A Myth FAQ

Does your agent know which interpreter it launched? I keep hearing confident answers in transcripts.

Those answers fail on a free box. This FAQ names five of them.

I start with a question, not a pitch. Which binary ran your tests?

Why these myths spread

Agents copy commands from old training data. Laptops hide the mess with pyenv.

A free model will invent a runtime. A free server will boot another image.

Chat still says the install worked. Did it actually?

You need receipts from the box. You do not need vibes from the model.

Disclosure: This article was prepared as part of MonkeyCode's product outreach.

I run these checks on throwaway shells. A MonkeyCode free server can be that shell. Free model access can read the receipt and stop guessing. Delete those product lines and the FAQ still stands.

The artifact: a box identity script

Do not debate the model. Ask the process table.

This script is a proposed check. Treat it as unexecuted until you run it.

# proposed: box-identity.sh
set -euo pipefail
echo "host=$(hostname)"
echo "user=$(id -un)"
echo "pwd=$(pwd)"
echo "utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "HOME=$HOME"
echo "VIRTUAL_ENV=${VIRTUAL_ENV:-}"
echo "PYTHONPATH=${PYTHONPATH:-}"
echo "PATH=$PATH"
echo "--- interpreters ---"
for c in python python3 python3.11 python3.12 pypy3
do
  if command -v "$c" >/dev/null 2>&1; then
    echo "which $c=$(command -v "$c")"
    "$c" -c "import sys; print('$c', sys.version.split()[0], sys.executable)"
  else
    echo "missing $c"
  fi
done
echo "--- pip module ---"
python3 -m pip --version || echo "python3 -m pip failed"
echo "--- os ---"
cat /etc/os-release 2>/dev/null || uname -a
Enter fullscreen mode Exit fullscreen mode

Paste that stdout above the next prompt. That output is the contract.

Myth 1: python means 3.12 on every box

The claim

The agent typed python. So the runtime is modern.

Is python even on PATH? Many images ship only python3.

Some still alias python to an old 3.9. Some alias it to nothing.

The check

type python || echo "no python"
type python3 || echo "no python3"
ls -l "$(command -v python3)"
python3 -c "import sys; print(sys.version)"
head -n 1 app.py 2>/dev/null || echo "no app.py yet"
Enter fullscreen mode Exit fullscreen mode

What did type print? That is your answer.

The corrected model

A command name is a PATH lookup. It is not a version pin.

#!/usr/bin/env python can miss tonight. #!/usr/bin/env python3 can hit.

Same repo. Different box. Different night.

Myth 2: Your laptop pins apply on the free server

The claim

You have .python-version at home. You have .nvmrc too.

So the box is 3.11, right? Did anyone copy those files?

The check

[ -f .python-version ] && cat .python-version || echo "no .python-version"
[ -f .tool-versions ] && cat .tool-versions || echo "no .tool-versions"
[ -f .nvmrc ] && cat .nvmrc || echo "no .nvmrc"
command -v pyenv || echo "no pyenv"
command -v nvm || echo "no nvm"
echo "HOME=$HOME"
Enter fullscreen mode Exit fullscreen mode

The agent will invent a pyenv table. command -v will not.

The corrected model

Pins travel only when you copy them. Version managers travel only when you install them.

A free server is another user on another disk. It is not your laptop in cheap disguise.

Myth 3: pip install targeted the interpreter you printed

The claim

You printed sys.version with python3. Then you ran pip install httpx.

Same world, right? Often it is not.

Bare pip can bind another site-packages. That bug is old. Agents still hit it.

The check

python3 -m pip --version
pip3 -V || echo "no pip3"
python3 -c "import sys; print('\n'.join(sys.path))"
python3 -c "import httpx; print(httpx.__file__)" || echo "httpx missing here"
Enter fullscreen mode Exit fullscreen mode

Did the import fail after a "successful" pip? You installed elsewhere.

The corrected model

Call pip as a module. Never trust a naked pip name.

Put this in the agent preamble:

Install only with: python3 -m pip install -r requirements.txt
Never invoke pip or pip3 as a bare command.
After install, import the package with the same python3.
Enter fullscreen mode Exit fullscreen mode

Will the model obey every time? No. The import check is the gate.

Myth 4: Replaying the prompt replays the environment

The claim

Same prompt. Same vendor. Same artifact.

A free server can be a fresh boot. Caches vanish. Workdirs reset.

Does the model store site-packages? The chat does not store PATH.

The check

python3 -m pip freeze > freeze.txt
python3 -c "import sys; print(sys.executable)" > exe.txt
pwd > pwd.txt
{ sha256sum freeze.txt exe.txt 2>/dev/null || shasum -a 256 freeze.txt exe.txt; }
git rev-parse HEAD 2>/dev/null || echo "not a git repo"
Enter fullscreen mode Exit fullscreen mode

Keep those files. Or paste them into the ticket.

The corrected model

A prompt is not a lockfile. A transcript is not freeze output.

If you cannot hash the environment, you cannot replay the run. This is a replay receipt. This is not a supply-chain audit.

Myth 5: The free model already knows the image

The claim

The model listed /usr/bin/python3.12 from memory. Did it look?

It predicted. Prediction is not ls.

The check

ls -l /usr/bin/python* 2>/dev/null || echo "no /usr/bin/python*"
python3 -c "import sysconfig; print(sysconfig.get_paths())"
cat /etc/os-release 2>/dev/null || uname -a
Enter fullscreen mode Exit fullscreen mode

The corrected model

The box is the source of truth. The model is a guesser with a shell tool.

Feed it identity output first. Then let it write code.

Do not let it write code first. Do not let it invent the runtime later.

A 15-minute test plan

This plan is proposed. I am not reporting numbers from your box.

  1. Run box-identity.sh and save identity-1.txt.
  2. Ask the agent to install one canary package.
  3. Import that package with python3.
  4. Import it with python if that name exists.
  5. Diff the two import results.
  6. Write python3 -m pip freeze into freeze.txt.
  7. Re-run the identity script into identity-2.txt.
  8. Diff the two identity files.

If step 4 succeeds and step 3 fails, you hit myth 3. If identity drifts, you hit myth 4.

If the agent quotes 3.12 and the file says 3.9, you hit myth 1. Stop the session when the receipt and the chat diverge.

Decision table

Use this before you trust a "tests passed" line.

If you see this Do not assume Check instead
Agent says Python 3.12 The binary is 3.12 python3 -c "import sys; print(sys.version)"
pip install succeeded This interpreter has the package python3 -c "import pkg"
Prompt was replayed Disk and PATH replayed freeze.txt plus hostname plus pwd
Shebang has env python PATH finds 3.x head -n 1 plus type python
Free box still feels warm State matches last session Re-run box-identity.sh

Print the table. Stick it next to your prompt template.

A preamble I paste before tools run

Treat this block as text. It is not magic.

Before writing or installing:
1. Run box-identity.sh and paste stdout.
2. Use only python3 -m pip.
3. Prefer python3 over python when both exist.
4. Write freeze.txt after installs.
5. Stop if os-release and uname both fail.
Enter fullscreen mode Exit fullscreen mode

The preamble is a hint. The script is the gate.

Where free models and free servers fit

I need a throwaway shell for identity checks. I need a model that can read that stdout.

MonkeyCode's free model access and free server option fit that loop. I paste the script. I read the receipt. I only then ask for application code.

I do not treat that box as CI. I do not treat that model as a lockfile.

If you already have a VM, use yours. This FAQ does not require their product.

If you try the script, keep the receipt in the PR. That is my only ask.

Limitations

This does not prove package integrity. pip freeze is not pip-audit.

This does not pin hashes. Use a real lock tool before you ship.

This does not survive a rebuild unless you store the receipt. This does not fix a model that skips tools. You still read stdout.

Who should skip this approach:

  • Folks with a managed golden image and enforced toolchains
  • Folks who never let an agent touch a shell
  • Folks who need production SLOs from a free box

A free box is a canary. It is not prod. It is not your laptop.

What I believe now

The agent does not pick Python. PATH does.

The free model does not remember the disk. You do.

If you cannot print the interpreter, you cannot trust the install. Run the script. Then argue with the transcript.

Top comments (0)