fix: preserve agent field during command expansion#3007
Open
dgageot wants to merge 2 commits into
Open
Conversation
Preserves all command fields including future additions, avoiding bugs like the Agent field loss that this change addresses.
docker-agent
reviewed
Jun 5, 2026
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The fix in pkg/js/expand.go is correct and well-tested. Copying the types.Command struct and overwriting only the Description and Instruction text fields reliably preserves the Agent field and prevents this class of bug from recurring with future fields.
The new unit test (TestExpandCommandsPreservesAgent) directly covers the regression, and the e2e test (TestExec_CommandTargetsAgent) validates the full routing path end-to-end. No bugs found in the added code.
melmennaoui
approved these changes
Jun 5, 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.
When invoking a slash command that targets a sub-agent via the
agent:field, the routing was incorrectly going to the root agent instead of the named sub-agent. The root cause was inpkg/js/expand.go'sExpandCommandsfunction, which rebuilt thetypes.Commandstruct field-by-field at config-load time and silently dropped theAgentfield. WhenLookupCommandlater tried to route the command, it saw an emptyAgentand never switched agents.This change fixes the bug by preserving the
Agentfield during command expansion. A follow-up refactor makesExpandCommandscopy the struct and overwrite only the expanded text fields (Description,Instruction), ensuring that future fields are preserved automatically and preventing this class of bug from recurring.The fix includes unit tests in
pkg/js/expand_agent_test.goand an end-to-end test ine2e/exec_command_agent_test.gowith a recorded cassette and config fixture, verifying that the instruction reaches the specialist sub-agent directly. All validation checks pass: build, go vet, race tests, and the full test suites for js, cli, runtime, config, and e2e.