Agent Notes
Local Dev Servers
- Frontend: from
frontend/, runnpm ciif dependencies are missing, thennpm run dev. - Backend: from
backend/, runuv run uvicorn main:app --host ::1 --port 7860. - Frontend URL: http://localhost:5173/
- Backend health check:
curl -g http://[::1]:7860/api - Frontend proxy health check:
curl http://localhost:5173/api
Notes:
- Vite proxies
/apiand/authtohttp://localhost:7860. - If
127.0.0.1:7860is already owned by another local process, binding the backend to::1lets the Vite proxy resolvelocalhostcleanly. - Prefer
npm ciovernpm installfor setup, sincenpm installmay rewritefrontend/package-lock.jsonmetadata depending on npm version. - Non-local LLM calls use
https://router.huggingface.co/v1with the active Hugging Face user's token. Web sessions and the CLI default to GLM 5.2. For local development, setHF_TOKENand optionallyML_INTERN_DEFAULT_MODEL_ID. - When asked to start the local server, export the GitHub CLI token first with
export GITHUB_TOKEN="$(gh auth token)". - When debugging a web app issue tied to a session ID, inspect the session data in
smolagents/ml-intern-sessionsfor additional context.
Development Checks
- Before every commit, run
uv run ruff check .anduv run ruff format --check .. - If formatting fails, run
uv run ruff format ., then re-run the Ruff checks before committing.
Git Workflow
- Before creating any new branch or worktree, switch to
mainand pull the latest changes.
GitHub CLI
- Always use the
ghCLI for GitHub operations such as opening, editing, inspecting, or commenting on PRs and issues. - For multiline PR descriptions, prefer
gh pr edit <number> --body-file <file>over inline--bodyso shell quoting,$env-var names, backticks, and newlines are preserved correctly. - If
ghreports an invalid token or auth failure, retry the command withGH_TOKENandGITHUB_TOKENunset, for exampleenv -u GH_TOKEN -u GITHUB_TOKEN gh pr create ..., soghcan use the stored login token instead of a stale environment token. - In Codex, sandboxed
ghauth checks can report a valid keyring login as invalid when GitHub network access is restricted. Before telling the user to re-authenticate, retry with both env tokens unset and GitHub network access enabled.
GitHub PRs
- Open code changes as GitHub PRs first. Do not push code changes directly to the Hugging Face Space deployment branch or Space remote before the PR has been opened, reviewed, and merged, unless the user explicitly asks to bypass the PR flow.
- After implementing a plan, run the required checks, commit the changes, open a GitHub PR, then start the backend and frontend local dev servers for testing.
Hugging Face Space Deploys
- The Space remote is
spaceand points tohttps://huggingface.co/spaces/smolagents/ml-intern. - Deploy GitHub
mainto the Space from the localspace-mainbranch by mergingorigin/mainintospace-mainwith a single merge commit, then pushingspace-main:mainto thespaceremote. - Keep the Space-only README frontmatter on
space-main;.gitattributesshould containREADME.md merge=oursand the local repo config should includemerge.ours.driver=true. - Local dev commonly uses a personal
HF_TOKEN, but the deployed Space uses HF OAuth tokens. When adding Hub features, make sure the Space READMEhf_oauth_scopesfrontmatter and the backend OAuth request inbackend/routes/auth.pyinclude the scopes required by the Hub APIs being called. A feature can work locally with a broad PAT and still fail in production with 403s if OAuth scopes are missing; after changing scopes, users may need to log out and log in again to receive a fresh token. - Recommended deploy flow:
git pull --ff-only origin main
git switch space-main
git config merge.ours.driver true
git merge --no-ff origin/main -m "Deploy $(date +%Y-%m-%d)" \
-m "Co-authored-by: OpenAI Codex <codex@openai.com>"
git push space space-main:main
git switch main