I use direnv to bring the development environments for my different projects into scope (I'm on NixOS, but I've also done this for python environments under WSL) for the different agents concerned with them.
I would like to not have to tell the agent to use direnv exec to run everything. The easiest way to do this would seem to be to have a hook, whether when the buffer is created, or before the agent is started, where you can do something like:
(agent-shell-ui-hook . (lambda ()
(message "Running our damned lambda!")
(make-local-variable agent-shell-anthropic-claude-environment)
(setq agent-shell-anthropic-claude-environment (agent-shell-make-environment-variables :inherit-env t))))
but I'm open to some other mechanism.