Enhance the agents API#3761
Merged
Merged
Conversation
Add a Commands []string field to api.Agent so clients can enumerate the slash commands defined on the root of each loaded config. Populated from cfg.Agents.First().Commands (already merged with any UseCommands references by config.Load), sorted alphabetically, and omitted from the JSON when empty for backward compatibility.
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The changes are correct and well-implemented:
Commands []stringwithomitempty— older clients silently ignore the new field; newer clients pointing at an older server see an absent list. Backward-compatible by design, no coordinated release required.- Map iteration +
slices.Sort— Go map iteration is non-deterministic; collecting keys then sorting produces a deterministic, stable API response. Correct approach. - Nil-vs-empty handling — when the root agent has no commands the
commandsvariable staysnil, whichomitemptyomits from JSON output. No spurious empty arrays emitted to clients. cfg.Agents.First()as root — correct choice for the root agent whose slash commands are the ones clients enumerate.- Test coverage —
TestServer_ListAgentsexercises both the empty-commands (single-agent) and populated-commands (multi-agent) cases with a sorted assertion matching the sorted output.
trungutt
marked this pull request as ready for review
July 20, 2026 15:26
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The PR cleanly exposes root-agent command names in /api/agents. The implementation correctly:
- Extracts map keys from
root.Commandsand sorts them deterministically withslices.Sort - Guards against the empty-commands case with
if len(root.Commands) > 0, leavingcommandsasnilso theomitemptytag suppresses the field when there are no commands - Avoids a double call to
cfg.Agents.First()by caching the result inroot - Adds test coverage for the happy path (multi-agent config with commands, single-agent configs without)
No confirmed or likely bugs found.
Sayt-0
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance the agents API.