Skip to content

Commit a2a68bb

Browse files
authored
feat(agent): guide agents to report missing guidance when grep finds no matches (#1860)
## Summary - When `speakeasy agent context --grep` returns no results, the error message now includes instructions for submitting feedback about missing documentation - Added `missing_guidance` feedback type (stored in metadata) for tracking documentation gaps - This helps agents track and report gaps in the agent context docs when they search for something that doesn't exist ## Example Before: ``` $ speakeasy agent context --grep "bumpMajor" Error: Exit code 1 no matches found for: bumpMajor ``` After: ``` $ speakeasy agent context --grep "bumpMajor" no matches found for: bumpMajor This may indicate missing guidance in the agent context documentation. Please submit feedback so we can improve the docs: speakeasy agent feedback --type missing_guidance --message "Searched for 'bumpMajor' but found no results. Context: <describe what you were trying to accomplish>" Your feedback helps us identify gaps in the documentation. ``` ## Test plan - [x] Build passes - [x] Unit tests pass - [x] Manually tested grep with no matches shows new message - [x] Verified feedback help shows new `missing_guidance` type
1 parent 663b6b3 commit a2a68bb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

cmd/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var agentFeedbackCmd = &model.ExecutableCommand[AgentFeedbackFlags]{
145145
flag.StringFlag{
146146
Name: "type",
147147
Shorthand: "t",
148-
Description: "Feedback type: agent_context or general",
148+
Description: "Feedback type: agent_context, missing_guidance, or general",
149149
DefaultValue: "agent_context",
150150
},
151151
flag.StringFlag{

internal/agent/context.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"io/fs"
7+
"os"
78
"path"
89
"regexp"
910
"sort"
@@ -460,6 +461,14 @@ func Grep(contentFS fs.FS, opts GrepOptions) error {
460461
}
461462

462463
if len(allMatches) == 0 {
464+
fmt.Fprintf(os.Stderr, `This may indicate missing guidance in the agent context documentation.
465+
Please submit feedback so we can improve the docs:
466+
467+
speakeasy agent feedback --type missing_guidance --message "Searched for '%s' but found no results. Context: <describe what you were trying to accomplish>"
468+
469+
Your feedback helps us identify gaps in the documentation.
470+
471+
`, opts.Pattern)
463472
return fmt.Errorf("no matches found for: %s", opts.Pattern)
464473
}
465474

internal/agent/feedback.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ func SubmitFeedback(ctx context.Context, feedbackType, message, contextPath stri
2525
}
2626

2727
metadata := map[string]any{}
28+
if feedbackType == "missing_guidance" {
29+
metadata["feedback_subtype"] = "missing_guidance"
30+
}
2831
if contextPath != "" {
2932
metadata["context_path"] = contextPath
3033
}

0 commit comments

Comments
 (0)