Troubleshooting a Local AI Coding Agent Deployment and Testing It with Two-Marked-Ruler Geometry Tasks
This guide is for developers deploying an AI coding agent locally. It covers pre-installation checks, how to diagnose common install failures from log messages, how to run the agent with restricted permissions inside an isolated workspace, and how to validate the generated code with two reproducible geometry tasks: constructing a regular heptagon and doubling a cube with a two-marked ruler. These tasks force the agent to handle geometric semantics, numerical solving, a drawing state machine, and animation export—far more revealing than generating a simple form.
1. What You’ll Be Able to Do
This article targets developers who want to run an AI coding agent on their own machine. After reading it, you should be able to do three things: diagnose why an installation failed, confine the agent to a controlled workspace, and use two geometry tasks to verify whether the code it generates passes reviewable acceptance criteria. The two tasks are constructing a regular heptagon with a two-marked ruler and doubling the cube with a two-marked ruler. They require the agent to handle geometric semantics, numerical solving, a drawing state machine, and animation export simultaneously, which exposes problems far more effectively than generating a form.
2. Pre-Installation Checks and Troubleshooting
The generic install command consists of a package manager and the agent’s CLI package:
<package-manager> install -g <cli-name>
The placeholders are defined as follows.
| Placeholder or item | Meaning | Example with npm | Check command |
|---|---|---|---|
| Package manager | Performs the global install | npm, pnpm, etc. | npm --version |
| CLI name | The agent’s CLI package name | Use the official package name of your tool | Run <command> --version after install |
| Runtime | The interpreter or Node.js version the agent depends on | Node.js | node --version |
| C++ compiler | Compiles native modules | g++ or clang++ | g++ --version |
| Build tools | Tools that invoke the compiler | make, python3 | make --version |
Scope: this table assumes an npm-family package manager. If your tool uses a different package manager, just substitute the commands; the checks stay the same.
The first error in the install log determines your troubleshooting direction:
gyp ERR!ornode-gypindicates a native module build failure, usually caused by an outdated C++ compiler.EACCESorpermission deniedindicates no write permission on the global directory. Switch to a user-level install prefix instead of repeatedly forcing global installs with sudo.ETIMEDOUTorENOTFOUNDindicates the network or registry mirror is unreachable. Check your proxy settings and the registry URL first.
If the compiler is too old, switch to a newer toolchain already installed on the system rather than skipping compilation. For example:
export CXX=g++-13export CC=gcc-13<package-manager> install -g <cli-name>
Use ls /usr/bin | grep g++ to see which versions are actually installed. These environment variables only apply to the current terminal session. Close the session after installation to avoid mixing compiler versions long-term.
3. Starting the Web UI and Configuring Permissions
Example start command:
<agent-cli> --profile web
Normal output includes an address like Web UI: http://127.0.0.1:<port>. The service listens on the loopback interface only, so other machines cannot reach it. Keep this default.
After startup, confirm five configuration items:
- Model API key: store it in an environment variable or the system keychain. Never put it in workspace files or logs.
- Workspace: choose a dedicated empty directory, or one containing only test resources.
- Working mode: choose code mode so the agent outputs project artifacts as files.
- Access permissions: choose according to the table below.
- Reasoning model: prioritize stability in multi-step reasoning and instruction following over long contexts; single-turn response speed is a secondary consideration.
The permission tiers are as follows. These are generic tiers; the exact names depend on your tool.
| Tier | Capabilities | Use case | Risk |
|---|---|---|---|
| Read-only | Read workspace files | Code review, design discussion | Low |
| Workspace write | Create and modify files within the workspace | Generate pages, debug scripts | Medium |
| Full access | Execute commands, access the network, read/write other paths | Full verification inside an isolated environment | High |
Before granting full access, confirm you understand three risks. First, command execution may delete files or install unreviewed dependencies. Second, write paths may escape the workspace, for example via symbolic links pointing to system directories. Third, file contents the agent reads are sent to the model service with each request, so directories containing sensitive data must not be exposed to it.
For isolation, use a container that makes the workspace the only writable directory, keeps everything else read-only, and preserves an operation log. For example:
docker run --rm -it \-v "$PWD/workspace:/work" \-w /work \-e MODEL_API_KEY \node:20 bash
Only the workspace directory is mounted here, so the agent inside the container can write only to that directory. The API key is passed in via an environment variable and is not baked into the image. If the agent needs to reach the model service, open only the network addresses that service requires.
4. The Regular Heptagon: Constraint Modeling and Acceptance
Take a square ABCD with side length 2, where A is the lower-left vertex and B is the lower-right vertex. Let m be the perpendicular bisector of the bottom edge AB, which is the line x = 1. Draw circle Γ centered at B with radius equal to the diagonal AC, i.e., 2√2.
The two marks on the ruler are spaced s apart, where s equals the square’s side length, so s = 2. The ruler passes through point A, with the first mark P1 on circle Γ and the second mark P2 on the bisector m.
Let u = (cosθ, sinθ) be the unit vector along the ruler, and write c = cosθ. Since P2 lies on m, P2 = (1, tanθ), and P2 = t2·u with t2 = 1/c. P1 = t1·u lies on the circle; substituting into the circle equation |t1·u − B|² = 8 gives
t1² − 4c·t1 − 4 = 0
Taking the positive root: t1 = 2c + 2√(1 + c²). The mark-spacing constraint is t1 − t2 = 2. Substituting t1 = 1/c + 2 and simplifying yields 2c√(1 + c²) = 1 + 2c − 2c². Squaring both sides and reducing gives
8c³ + 4c² − 4c − 1 = 0
The three roots of this cubic are cos(2π/7), cos(4π/7), and cos(6π/7), approximately 0.6235, −0.2225, and −0.9010. Since P2 must lie on the ray from A, c must be positive. The only valid root is c = cos(2π/7), corresponding to θ = 2π/7, about 51.43°. The pre-squaring condition 1 + 2c − 2c² evaluates to about 1.47 at this root, which is positive, so the result is valid.
In the implementation, keep solving and drawing separate:
- Solver layer: solve for θ, compute the coordinates of A, B, P1, P2, the circle center, and the bisector, and output the point set and line segments.
- Drawing layer: reads only the solver’s output and handles rendering, performing no geometric computation itself.
The acceptance criteria are:
- The residual of the cubic equation is below 1e-9.
- Points A, P1, and P2 are collinear, and |P1P2| deviates from 2 by less than 1e-9.
- The computed θ deviates from 2π/7 by less than 1e-9.
