Skip to content

agent-shell-get-config does not work in an agent-shell-command-prefix function #577

@lucius-martius

Description

@lucius-martius

Description

The code example in the readme describes the following to get a command-prefix specific for an agent type:

agent-shell/README.org

Lines 486 to 492 in 30fe4bd

(setq agent-shell-command-prefix
(lambda (buffer)
(let ((config (agent-shell-get-config buffer)))
(pcase (map-elt config :identifier)
('claude-code '("docker" "exec" "claude-dev" "--"))
('gemini-cli '("docker" "exec" "gemini-dev" "--"))
(_ '("devcontainer" "exec" "."))))))

This currently does not work and (agent-shell-get-config buffer) always returns nil inside such a function.

(Correction: The function seems to get called twice, with (agent-shell-get-config buffer) returning nil the first time and the proper config the second time. This is still a valid issue however.)

The reason is likely that agent-shell--state is only filled after the client-maker has already been called, which in turn eventually calls the function in agent-shell-command-prefix with an empty agent-shell--state form:

agent-shell/agent-shell.el

Lines 2743 to 2750 in 30fe4bd

(let ((command (map-elt (funcall (map-elt config :client-maker) (current-buffer)) :command)))
(unless (executable-find command)
(kill-buffer shell-buffer)
(error "%s" (agent-shell--make-missing-executable-error
:executable command
:install-instructions (map-elt config :install-instructions)))))
;; Initialize buffer-local state
(setq-local agent-shell--state (agent-shell--make-state

So either the readme is wrong/outdated and we need to get the agent identifier in a different way (though I can't think of a non-hacky way off the top of my head), or this is a bug/regression.

Sidenote: A function that returns a command-prefix unconditionally works as expected.

Checklist

  • I agree to communicate with the author myself (not AI-generated).
  • I've read the README's Filing issues section.
  • I'm running the latest versions (fill in below).
    • agent-shell version: 20260507.1212
    • acp.el version: 20260503.1815
    • ACP package (e.g. claude-agent-acp) version: any
    • Agent CLI (e.g. claude, gemini) version: any
  • For requesting new agent support, I'm including a link to the ACP-capable agent or related ACP package.
  • For issues, I'm including ACP traffic (as per README).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions