If you are debugging agent lifecycle or subagent behavior, first check docs/AGENT_JOBS.md. Magent uses durable child-agent jobs through spawn_agent, send_agent_message, wait_agent, list_agents, and close_agent; the old one-shot delegate tool is not part of the current surface. Do not diagnose missing sandbox parity as a Magent bug; Codex sandbox behavior is intentionally out of scope.
Problem: Magent requires gptel as a dependency.
Solution:
;; Install gptel from MELPA
(package-install 'gptel)
Problem: Warnings about undefined functions during compilation.
Solution: Ensure all dependencies are installed and in load-path:
make compile # Auto-detects dependencies in ~/.emacs.d/elpa/
Problem: make test-live fails, times out, or reports an async timer error while using the real configured gptel provider.
Live debugging playbook:
emacs --daemon=magent-live-test
emacsclient or make at the isolated server:
emacsclient -s magent-live-test --eval '(emacs-pid)'
make EMACSCLIENT="emacsclient -s magent-live-test" test-live-smoke
emacsclient -s magent-live-test --eval \
'(progn
(setq debug-on-error t)
(load-file "/path/to/magent/test/magent-live-test.el")
(magent-live-test-reload-source)
(list :repo-source (magent-live-test--repo-source-summary)))'
Every path in :repo-source must be under the checkout, for example /path/to/magent/magent.el, not under ~/.emacs.d/elpa/magent/.
Source file ... newer than byte-compiled file; using older file means Emacs tested old code.
make clean
emacsclient responsive and preserve a compact state snapshot while the provider request continues:
emacsclient -s magent-live-test --eval \
'(progn
(setq debug-on-error t)
(load-file "/path/to/magent/test/magent-live-test.el")
(magent-live-test-reload-source)
(magent-live-test-install-trace "/tmp/magent-live-trace.el")
(magent-live-test-run-async
(quote magent-live-test-real-emacs-eval-tool)
"/tmp/magent-live-tool-final.el"))'
cat /tmp/magent-live-tool-final.el
tail -n 80 /tmp/magent-live-trace.el
*Messages**Backtrace**magent-live-test-log**gptel-log*Treat *gptel-log* as sensitive. Redact API keys, bearer tokens, request headers, and provider-specific secrets before sharing or committing any excerpts.
emacsclient -s magent-live-test --eval '(kill-emacs 0)'
If the client cannot connect, identify the emacs --daemon=magent-live-test PID and kill that PID only.
Diagnosis:
(setq debug-on-error t)
emacsclient or make test-live.*Messages* for timer, process filter, and byte-code errors*Backtrace* when debug-on-error opens one*magent-log* or the test-local *magent-live-test-log**gptel-log* for provider/request failures; redact API keys or headers before sharing(progn
(load-file "/path/to/magent/test/magent-live-test.el")
(setq debug-on-error t)
(magent-live-test-run 'magent-live-test-real-emacs-eval-tool))
Solution:
*Backtrace* or *Messages*, then re-run the single failing live test before running the whole live suite.*gptel-log* as sensitive diagnostic material; summarize it or share only redacted snippets.Failure signatures from prior live debugging:
/tmp/magent-live-trace.el. A gptel-curl-get-args :event enter with no matching :event leave usually means gptel hit a serialization error before curl started. Check tool-call names, tool args, and assistant tool_calls history for Lisp symbols or non-JSON-safe values.magent-agent-loop-request-for-current-session.magent-ui-finish-streaming-fontify.emacsclient but make test-live-smoke fails, confirm EMACSCLIENT="emacsclient -s magent-live-test" is set. The Makefile default may target the main Emacs server.load-history, load-path ordering, and .elc files. test/magent-live-test.el uses source loading with nosuffix; keep that behavior when adding files to the live reload list.Known-good verification sequence after fixing live gptel/tool bugs:
make clean
make test-unit
make compile
make clean
make EMACSCLIENT="emacsclient -s magent-live-test" test-live-smoke
Then run both real async diagnostics in the isolated daemon:
(magent-live-test-run-async 'magent-live-test-real-simple-prompt
"/tmp/magent-live-simple-final.el")
(magent-live-test-run-async 'magent-live-test-real-emacs-eval-tool
"/tmp/magent-live-tool-final.el")
Expected final status files include :status passed, :repo-source paths under the checkout, and for the tool test a tool state like (:name "emacs_eval" :result "42") plus final assistant text MAGENT_TOOL_OK=42.
Problem: Request hangs or times out.
Diagnosis:
*magent-log* buffer: C-c m lgptel-model ; Should show your model
gptel-api-key ; Should show your key
M-x gptelSolution:
(setq magent-request-timeout 300)Problem: Tool calls return errors.
Diagnosis:
*magent-log* for error detailsmagent-enable-toolsM-x magent-show-current-agentSolution:
which rgProblem: A child-agent task does not behave like a durable job that can be messaged, waited on, listed, or closed.
Diagnosis:
spawn_agent, send_agent_message, wait_agent, list_agents, and close_agent.docs/AGENT_JOBS.md for the child-agent/job lifecycle contract.#+begin_agent blocks in *magent*, or run M-x magent-show-agent-transcript / C-c m j to view the persisted child transcript.*magent-log* for nested request or tool-call errors.agent-jobs.Solution:
Problem: Tool execution blocked by permissions.
Diagnosis:
Check agent permissions: M-x magent-show-current-agent
Solution:
M-x magent-toggle-by-pass-permission(setq magent-by-pass-permission t)C-c m A and select one with appropriate permissionsProblem: Session state lost between Emacs restarts.
Diagnosis: Check session directory exists and is writable:
magent-session-directory ; Default: ~/.emacs.d/magent-sessions/
Solution:
;; Ensure directory exists
(make-directory magent-session-directory t)
Problem: Streaming appears stuck.
Diagnosis:
*Messages* buffer for errorsC-g in output bufferSolution:
C-c m c then C-c m pProblem: Sections won’t fold/unfold.
Solution:
TAB on section headersS-TAB to toggle all sectionsProblem: Response appears character-by-character.
Solution:
;; Increase batch delay
(setq magent-ui-batch-insert-delay 0.1)
;; Lower async fontification threshold
(setq magent-ui-fontify-threshold 200)
Problem: Emacs memory grows over time.
Solution:
;; Reduce history size
(setq magent-max-history 50)
;; Clear old sessions periodically
(magent-clear-session)
M-x magent-doctor
Runs comprehensive self-check and reports issues.
M-x magent-show-log ; or C-c m l
Shows API request/response log.
M-x describe-variable RET magent-enable-tools
M-x describe-variable RET gptel-model
M-x describe-variable RET gptel-api-key
If issues persist:
M-x magent-doctor and save output*magent-log* and *Messages* buffersM-x emacs-version