@@ -257,11 +257,12 @@ func TestAuditToolPassesGithubRepositoryAsRepoFlag(t *testing.T) {
257257 }
258258}
259259
260- // TestAuditToolErrorEnvelopeSetsIsErrorTrue verifies that audit command failures
261- // returned as JSON envelopes are marked with IsError=true in the MCP response.
262- func TestAuditToolErrorEnvelopeSetsIsErrorTrue (t * testing.T ) {
260+ // TestAuditToolErrorEnvelopeSetsIsErrorFalse verifies that audit command failures
261+ // returned as JSON envelopes use IsError=false so callers receive graceful JSON
262+ // rather than a fatal MCP protocol error.
263+ func TestAuditToolErrorEnvelopeSetsIsErrorFalse (t * testing.T ) {
263264 mockExecCmd := func (ctx context.Context , args ... string ) * exec.Cmd {
264- cmd := exec .CommandContext (ctx , os .Args [0 ], "-test.run=TestAuditToolErrorEnvelopeSetsIsErrorTrueHelperProcess " )
265+ cmd := exec .CommandContext (ctx , os .Args [0 ], "-test.run=TestAuditToolErrorEnvelopeHelperProcess " )
265266 cmd .Env = append (os .Environ (), "GH_AW_AUDIT_HELPER_PROCESS=1" )
266267 return cmd
267268 }
@@ -278,7 +279,7 @@ func TestAuditToolErrorEnvelopeSetsIsErrorTrue(t *testing.T) {
278279 })
279280 require .NoError (t , err , "audit tool should return result envelope without protocol error" )
280281 require .NotNil (t , result , "result should not be nil" )
281- assert .True (t , result .IsError , "audit error envelope should set IsError=true " )
282+ assert .False (t , result .IsError , "audit error envelope should set IsError=false (graceful JSON error) " )
282283 require .NotEmpty (t , result .Content , "result should contain text content" )
283284
284285 textContent , ok := result .Content [0 ].(* mcp.TextContent )
@@ -290,9 +291,12 @@ func TestAuditToolErrorEnvelopeSetsIsErrorTrue(t *testing.T) {
290291 errorMessage , ok := envelope ["error" ].(string )
291292 require .True (t , ok , "error envelope should include string error field" )
292293 assert .Contains (t , errorMessage , "failed to audit workflow run" , "error envelope should include contextual prefix" )
294+ suggestions , hasSuggestions := envelope ["suggestions" ]
295+ assert .True (t , hasSuggestions , "error envelope should include suggestions" )
296+ assert .NotEmpty (t , suggestions , "suggestions should not be empty" )
293297}
294298
295- func TestAuditToolErrorEnvelopeSetsIsErrorTrueHelperProcess (t * testing.T ) {
299+ func TestAuditToolErrorEnvelopeHelperProcess (t * testing.T ) {
296300 if os .Getenv ("GH_AW_AUDIT_HELPER_PROCESS" ) != "1" {
297301 return
298302 }
@@ -331,9 +335,9 @@ func TestAuditTool_AcceptsDeprecatedMaxTokensParameter(t *testing.T) {
331335 assert .NotContains (t , strings .Join (capturedArgs , " " ), "max_tokens" , "audit command args should ignore max_tokens" )
332336}
333337
334- func TestAuditDiffToolErrorEnvelopeSetsIsErrorTrue (t * testing.T ) {
338+ func TestAuditDiffToolErrorEnvelopeSetsIsErrorFalse (t * testing.T ) {
335339 mockExecCmd := func (ctx context.Context , args ... string ) * exec.Cmd {
336- cmd := exec .CommandContext (ctx , os .Args [0 ], "-test.run=TestAuditDiffToolErrorEnvelopeSetsIsErrorTrueHelperProcess " )
340+ cmd := exec .CommandContext (ctx , os .Args [0 ], "-test.run=TestAuditDiffToolErrorEnvelopeHelperProcess " )
337341 cmd .Env = append (os .Environ (), "GH_AW_AUDIT_DIFF_HELPER_PROCESS=1" )
338342 return cmd
339343 }
@@ -353,7 +357,7 @@ func TestAuditDiffToolErrorEnvelopeSetsIsErrorTrue(t *testing.T) {
353357 })
354358 require .NoError (t , err , "audit-diff tool should return result envelope without protocol error" )
355359 require .NotNil (t , result , "result should not be nil" )
356- assert .True (t , result .IsError , "audit-diff error envelope should set IsError=true " )
360+ assert .False (t , result .IsError , "audit-diff error envelope should set IsError=false (graceful JSON error) " )
357361 require .NotEmpty (t , result .Content , "result should contain text content" )
358362
359363 textContent , ok := result .Content [0 ].(* mcp.TextContent )
@@ -365,9 +369,12 @@ func TestAuditDiffToolErrorEnvelopeSetsIsErrorTrue(t *testing.T) {
365369 errorMessage , ok := envelope ["error" ].(string )
366370 require .True (t , ok , "error envelope should include string error field" )
367371 assert .Contains (t , errorMessage , "failed to diff workflow runs" , "error envelope should include contextual prefix" )
372+ suggestions , hasSuggestions := envelope ["suggestions" ]
373+ assert .True (t , hasSuggestions , "error envelope should include suggestions" )
374+ assert .NotEmpty (t , suggestions , "suggestions should not be empty" )
368375}
369376
370- func TestAuditDiffToolErrorEnvelopeSetsIsErrorTrueHelperProcess (t * testing.T ) {
377+ func TestAuditDiffToolErrorEnvelopeHelperProcess (t * testing.T ) {
371378 if os .Getenv ("GH_AW_AUDIT_DIFF_HELPER_PROCESS" ) != "1" {
372379 return
373380 }
0 commit comments