agent-shell icon indicating copy to clipboard operation
agent-shell copied to clipboard

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

Open lucius-martius opened this issue 6 months ago • 3 comments

Description

The code example in the readme describes the following to get a command-prefix specific for an agent type: https://github.com/xenodium/agent-shell/blob/30fe4bd8fd67d9b6e26daa573246cf2cae286bba/README.org?plain=1#L486-L492

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: https://github.com/xenodium/agent-shell/blob/30fe4bd8fd67d9b6e26daa573246cf2cae286bba/agent-shell.el#L2743-L2750

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

  • [x] I agree to communicate with the author myself (not AI-generated).
  • [x] I've read the README's Filing issues section.
  • [x] 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).

lucius-martius avatar May 08 '26 18:05 lucius-martius

Thanks for reporting and providing details.

https://github.com/xenodium/agent-shell/commit/fbb6fd854c79fc176747a10e3382fe5d40ae234e should fix it. Can you try and report back please?

xenodium avatar May 11 '26 17:05 xenodium

It works as expected now. It looks like the function is called three times (not just twice, like I wrote before) and getting the same plist value returned for config each time. Thanks for the quick fix.

lucius-martius avatar May 11 '26 19:05 lucius-martius

It works as expected now.

Glad to hear. Thaks for reporting back. If you're getting value out of agent-shell, consider sponsoring so I can make this project sustainable. I'm easing back into agent-shell since #500 and my available time is competing with other activities that help pay the bills.

xenodium avatar May 11 '26 19:05 xenodium