MCPcopy Index your code
hub / github.com/docker/docker-agent / formatCommandOutput

Function formatCommandOutput

pkg/tools/builtin/shell/shell.go:565–580  ·  view source on GitHub ↗

formatCommandOutput formats command output handling timeout, cancellation, and errors.

(timeoutCtx, ctx context.Context, err error, rawOutput string, timeout time.Duration)

Source from the content-addressed store, hash-verified

563
564// formatCommandOutput formats command output handling timeout, cancellation, and errors.
565func formatCommandOutput(timeoutCtx, ctx context.Context, err error, rawOutput string, timeout time.Duration) string {
566 var output string
567 if timeoutCtx.Err() != nil {
568 if ctx.Err() != nil {
569 output = "Command cancelled"
570 } else {
571 output = fmt.Sprintf("Command timed out after %v\nOutput: %s", timeout, rawOutput)
572 }
573 } else {
574 output = rawOutput
575 if err != nil {
576 output = fmt.Sprintf("Error executing command: %s\nOutput: %s", err, output)
577 }
578 }
579 return cmp.Or(strings.TrimSpace(output), "<no output>")
580}
581
582func (t *ToolSet) Instructions() string {
583 return `## Shell Tools

Callers 1

runNativeCommandMethod · 0.85

Calls 1

ErrMethod · 0.65

Tested by

no test coverage detected