Skip to content

Interview question · Agent Runtime & Sandboxes

A code sandbox needs GitHub access and the generated code must never see the token. Design it.

Reads go through a broker that adds the token outside the sandbox. Writes are safer still if the sandbox never pushes at all: it hands over a patch, and a trusted service checks it and pushes.

hardEssentialNewUpdated Nov 2026

TL;DR: Two paths. For reads (clone, fetch, API reads), the sandbox's Git remote and API base URL point at a broker outside the sandbox, which checks the repository and operation against the session's policy and adds a short-lived, repository-scoped token. For writes, prefer that the sandbox never pushes: it produces a commit bundle or patch, and a trusted service outside checks it (allowed branch, no workflow-file changes, size limits) and pushes with its own credentials, then opens the pull request. Egress allows only the broker, and metadata endpoints are blocked.

How to approach it

Separate reading from writing, because their risks differ: a leaked read token exposes code; a write path can change what runs in CI. Then design each path, the policies, and the network rules that make the broker unavoidable.

A strong answer

Reads through a broker. Inside the sandbox, git remote is https://git-broker.internal/acme/payments.git and the API base URL is https://gh-broker.internal/. The broker, outside the sandbox:

  • checks that the session may read acme/payments (and nothing else);
  • obtains a short-lived installation token scoped to that repository (GitHub App installation tokens last about an hour and can be limited to selected repositories);
  • forwards the request with the token and strips authentication from responses;
  • logs the request with the session id.

Writes outside the sandbox. Letting the sandbox push, even through a broker, means generated code chooses what is pushed. The safer design:

  1. The agent commits inside the sandbox.
  2. The harness exports the commits as a bundle or patch.
  3. A trusted push service checks it, then pushes to a branch and opens a pull request with its own credentials.
BLOCKED_PATHS = (".github/workflows/", ".gitlab-ci.yml", "Dockerfile.ci")

def check_push(session, ref, changed_paths, deletes=False, size_kb=0):
    problems = []
    if not ref.startswith(f"refs/heads/agent/{session}/"):
        problems.append(f"branch {ref} outside agent/{session}/")
    if deletes:
        problems.append("ref deletion not allowed")
    for p in changed_paths:
        if p.startswith(BLOCKED_PATHS):
            problems.append(f"changes {p}, which runs with CI privileges")
    if size_kb > 5_000:
        problems.append("push larger than 5 MB")
    return problems

ok = check_push("s42", "refs/heads/agent/s42/fix-rounding",
                ["src/billing/round.py", "tests/test_round.py"])
bad = check_push("s42", "refs/heads/main", [".github/workflows/deploy.yml"])
print(ok, len(bad))  # => [] 2
print(bad[0])  # => branch refs/heads/main outside agent/s42/

A change to CI workflow files is blocked because workflows run with credentials the agent should never influence; pushes to main are blocked because review happens through the pull request.

Network rules. The sandbox can reach the brokers and an internal package mirror, nothing else. Instance metadata is blocked. DNS resolves only allowed names.

Observability. Every broker request and every push decision is logged with session id and outcome, so an investigation can reconstruct what a session read and tried to write.

What interviewers probe next

"Developers want the agent to run git push naturally." A Git remote that points at the push service gives that experience: the push is received, checked and forwarded, or refused with a clear message, and the sandbox still holds no token.

"Private dependencies need registry tokens during install." Same pattern: the package mirror or registry proxy authenticates outside the sandbox.

"What if the agent needs to read a second repository?" The session's policy lists it explicitly; the broker refuses anything not listed, and the refusal tells the agent what was denied.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

Reads go through a broker and writes through a trusted push service that checks each bundle.

  1. Start here

    What if generated code prints all environment variables to the logs?

How it's scored

Weak: Puts a fine-grained token in the environment.

Hire: A broker or proxy that adds the token outside the sandbox, with scoped tokens.

Strong Hire: Separates read and write paths, uses short-lived repository-scoped tokens via a broker for reads, moves pushes to a trusted service that checks branch, deletions, CI files and size, forces egress through the brokers, blocks metadata, relies on branch protection as a second line, and logs every decision.

Common mistakes

  • Any long-lived token inside the sandbox.
  • Letting generated code push directly, even with a scoped token.
  • Allowing changes to CI workflow files from agent branches.
  • Leaving other egress open, so the broker can be bypassed.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.