eca icon indicating copy to clipboard operation
eca copied to clipboard

Improve dynamic spawn_agent prompt

Open michaelwhitford opened this issue 1 month ago • 3 comments

The spawn_agent tool generates a dynamic list of agents to create the prompt. There is a markdown prompt file, and eca appends the lists of agents it builds from markdown files in the ~/.config/eca/agents/ folder. If I replace the prompt for spawn_agent in my local config.json, the list of agents is not appended to my custom prompt. The override for the prompt does not trigger the appending of the list of dynamic agents. So to override the spawn_agent prompt, I have to manually add all the agents to my prompt or else eca will not see them. I would like eca to allow to override the spawn_agent prompt, but still append the list of dynamic agents.

Essentially the spawn_agent prompt is partially generated, and if I use the normal override from config, the generated part is never appended.

The override is at src/eca/features/tools.clj:372 The agent build is at src/eca/features/tools/agent.clj:521

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

michaelwhitford avatar Oct 26 '26 22:10 michaelwhitford

The same bug affects fetch_rule

src/eca/features/tools/fetch_rule.clj:101-116 builds its description the same way (base text plus a list of path-scoped rules). Overriding fetch_rule drops the rules list in the same way.

michaelwhitford avatar Oct 26 '26 22:10 michaelwhitford

And a succinct summary from AI:

Root cause: src/eca/features/tools.clj:371-377 (inside all-tools) replaces the tool's whole :description with the prompts.tools. override, using an or.

For spawn_agent, that description was already built by build-description in src/eca/features/tools/agent.clj:521-531. It's the base text from spawn_agent.md with the "Available agents" list (from all-agents) added to the end. So the override discards the dynamic list along with the base text.

The same bug affects: fetch_rule in src/eca/features/tools/fetch_rule.clj:101-116. Its path-scoped rules list is lost in the same way.

Possible fix: keep the dynamic part separate, for example in a :description-suffix key, and add it after the override is applied.

michaelwhitford avatar Oct 26 '26 22:10 michaelwhitford

thanks for the deep dive, will fix it

ericdallo avatar Nov 05 '26 19:11 ericdallo