fix(daemon): stop --dev-src-dir errors from suggesting paths that don't exist - #3869
Conversation
…'t exist A mistyped or wrong --dev-src-dir was always diagnosed as "you passed the checkout root", and the remedy blindly joined hub/agents/<id>/python onto whatever was typed. A typo became a longer typo; another agent's source dir became a suggestion to nest it inside itself. Neither suggested path existed. The remedy now only names a concrete path when that path is on disk, and a path shaped like another agent's source dir is reported as the wrong-agent error it is, naming that agent. Otherwise the message states the expected shape rather than inventing a path. Closes #3852
|
Verdict: Approve with suggestions The fix is correct and well-scoped. 🟢 Nit — issue number in docstrings (one pattern, four files): Four docstrings reference 🔍 Technical detailsThe four occurrences:
The fourth test ( Suggested rewrites:
Everything else — the three-branch logic, the existence gate on |
itomek
left a comment
There was a problem hiding this comment.
A bad --dev-src-dir now gets an error that points somewhere real. Before, any path that wasn't the expected shape got "pass '/hub/agents//python' instead" — a path blindly joined onto whatever was typed, so a typo became a longer typo and pointing at another agent's source tree suggested nesting it inside itself.
The corrected path is named only when it exists on disk; pointing at a different agent's dev-src dir is now reported as the wrong-agent error it is, with gaia daemon start-agent <that-agent> as the alternative. Four tests cover it, including the sibling-exists and sibling-missing branches.
Note on CI
This PR's checks had only ever run CodeQL — a branch pushed with GITHUB_TOKEN does not trigger the other workflows. Updated the branch from main to fire them; unit tests and lint pass on the current code. An earlier self-hosted Windows job failure was the runner losing contact with the server, not this change — it passed on rerun.
Anyone who mistyped
--dev-src-dirongaia daemon start-agentwas told to retype the same typo withhub/agents/<id>/pythonstapled on the end — a path that had never existed. Point it at another agent's source directory and the "fix" was to nest that directory inside itself, when the real mistake was naming the wrong agent. Now the error only names a concrete path when that path is actually on disk, calls out a wrong-agent path as exactly that, and otherwise just states the shape it expects.Closes #3852
Test plan
python -m pytest tests/unit/test_daemon_dev_anchor_spec.py -qpassespython util/lint.py --allpassesgaia daemon start-agent email --mode dev --dev-src-dir /tmp/not-a-checkout→ message states the expectedhub/agents/email/pythonshape and suggests checking for a typo, with no invented path--dev-src-dir <checkout>/hub/agents/chat/python→ message says it's thechatagent's source directory and offersgaia daemon start-agent chat--dev-src-dir <checkout>(a real checkout root) → still names the exact<checkout>/hub/agents/email/pythonpath to pass instead🔍 Technical details
Root cause —
resolve_caller_dev_src_dirinsrc/gaia/daemon/sidecars/spec.pybuilt its remedy withagent_dev_src_dir(resolved, agent_id), an unconditional<input>/hub/agents/<id>/pythonjoin with no existence check, and hardcoded "not the checkout root" as the diagnosis for every non-matching shape.Change — the message is now built by
_dev_src_dir_shape_error(), which branches three ways:_dev_src_dir_agent_id()(new) matcheshub/agents/<any-id>/pythonwith the agent slot wildcarded → report the wrong-agent error, naming the other agent andgaia daemon start-agent <other>; the siblinghub/agents/<requested>/pythonpath is named only whenis_dir().hub/agents/<id>/pythonshape and suggest checking for a typo. No fabricated path.Verified — all four cases exercised against a temp tree; output for (a) checkout root, (b) unrelated dir, (c) another agent's source dir, (d) a directory that is not a checkout of this repo:
Tests —
tests/unit/test_daemon_dev_anchor_spec.py: the repo-root test now creates the realhub/agents/email/pythonso it keeps covering the genuine checkout-root case under the existence gate;..._rejects_unrelated_shapegained positive remedy-text assertions plus a check that the fabricated joined path is absent; two new tests cover the other-agent case with and without an existing sibling.python util/lint.py --all— black/isort/pylint/flake8/bandit pass. Fulltests/unit/run: 11928 passed; the 17 failures / 62 errors are pre-existing in this container (missing optional deps likefitz, and the uninstall-command suite's HOME assumptions) and reproduce identically onmainwith the change stashed.