-
Notifications
You must be signed in to change notification settings - Fork 366
feat: add 'docker agent debug skills' command #2881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ import ( | |
| "github.com/docker/docker-agent/pkg/team" | ||
| "github.com/docker/docker-agent/pkg/teamloader" | ||
| "github.com/docker/docker-agent/pkg/telemetry" | ||
| "github.com/docker/docker-agent/pkg/tools" | ||
| skillstool "github.com/docker/docker-agent/pkg/tools/builtin/skills" | ||
| ) | ||
|
|
||
| type debugFlags struct { | ||
|
|
@@ -43,6 +45,12 @@ func newDebugCmd() *cobra.Command { | |
| Args: cobra.ExactArgs(1), | ||
| RunE: flags.runDebugToolsetsCommand, | ||
| }) | ||
| cmd.AddCommand(&cobra.Command{ | ||
| Use: "skills <agent-file>|<registry-ref>", | ||
| Short: "Debug the skills of an agent", | ||
| Args: cobra.ExactArgs(1), | ||
| RunE: flags.runDebugSkillsCommand, | ||
| }) | ||
| titleCmd := &cobra.Command{ | ||
| Use: "title <agent-file>|<registry-ref> <question>", | ||
| Short: "Generate a session title from a question", | ||
|
|
@@ -118,26 +126,76 @@ func (f *debugFlags) runDebugToolsetsCommand(cmd *cobra.Command, args []string) | |
| continue | ||
| } | ||
|
|
||
| tools, err := agent.Tools(ctx) | ||
| agentTools, err := agent.Tools(ctx) | ||
| if err != nil { | ||
| slog.ErrorContext(ctx, "Failed to query tools", "name", agent.Name(), "error", err) | ||
| continue | ||
| } | ||
|
|
||
| if len(tools) == 0 { | ||
| if len(agentTools) == 0 { | ||
| out.Printf("No tools for %s\n", agent.Name()) | ||
| continue | ||
| } | ||
|
|
||
| out.Printf("%d tool(s) for %s:\n", len(tools), agent.Name()) | ||
| for _, tool := range tools { | ||
| out.Printf("%d tool(s) for %s:\n", len(agentTools), agent.Name()) | ||
| for _, tool := range agentTools { | ||
| out.Println(" +", tool.Name, "-", tool.Description) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (f *debugFlags) runDebugSkillsCommand(cmd *cobra.Command, args []string) (commandErr error) { | ||
| telemetry.TrackCommand(cmd.Context(), "debug", append([]string{"skills"}, args...)) | ||
| defer func() { // do not inline this defer so that commandErr is not resolved early | ||
| telemetry.TrackCommandError(cmd.Context(), "debug", append([]string{"skills"}, args...), commandErr) | ||
| }() | ||
|
|
||
| ctx := cmd.Context() | ||
|
|
||
| t, err := f.loadTeam(ctx, args[0]) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer stopToolSets(t) | ||
|
|
||
| out := cli.NewPrinter(cmd.OutOrStdout()) | ||
|
|
||
| for _, name := range t.AgentNames() { | ||
| agent, err := t.Agent(name) | ||
| if err != nil { | ||
| slog.ErrorContext(ctx, "Failed to get agent", "name", name, "error", err) | ||
| continue | ||
| } | ||
|
|
||
| var skillsToolset *skillstool.ToolSet | ||
| for _, ts := range agent.ToolSets() { | ||
| if st, ok := tools.As[*skillstool.ToolSet](ts); ok { | ||
| skillsToolset = st | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if skillsToolset == nil || len(skillsToolset.Skills()) == 0 { | ||
| out.Printf("No skills for %s\n", agent.Name()) | ||
| continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test comment on Skills() guard line |
||
| } | ||
|
|
||
| loadedSkills := skillsToolset.Skills() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
var loadedSkills []skills.Skill
if skillsToolset != nil {
loadedSkills = skillsToolset.Skills()
}
if len(loadedSkills) == 0 {
out.Printf("No skills for %s\n", agent.Name())
continue
} |
||
| out.Printf("%d skill(s) for %s:\n", len(loadedSkills), agent.Name()) | ||
| for _, skill := range loadedSkills { | ||
| marker := "" | ||
| if skill.IsFork() { | ||
| marker = " [forked]" | ||
| } | ||
| out.Println(" +", skill.Name+marker, "-", skill.Description) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (f *debugFlags) runDebugTitleCommand(cmd *cobra.Command, args []string) (commandErr error) { | ||
| telemetry.TrackCommand(cmd.Context(), "debug", append([]string{"title"}, args...)) | ||
| defer func() { // do not inline this defer so that commandErr is not resolved early | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| agents: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| root: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| model: openai/gpt-3.5-turbo | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| description: A helpful AI assistant | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| instruction: | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| You are a knowledgeable assistant. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test |
||
| skills: true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test comment on line 7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every other fixture in |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test