[GH-ISSUE #13864] Insufficient Visibility of Agent Command Execution Context #34836

Open
opened 2026-04-22 18:45:33 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @EmilioSchi on GitHub (Jan 23, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/13864

Originally assigned to: @ParthSareen on GitHub.

The issue is not that the agent executes incorrect commands, but that the command display is truncated.

Unix shell commands usually place the most important information at the end of the command line (pipes, redirections, destination files, cd, -o <file>, etc.).
Because truncateUTF8() truncates the command after a fixed number of characters from the beginning, the displayed command hides where output is written or which files are modified.

In addition, the agent may execute commands in unknown or implicit working directories. When relative paths are used, this makes it unclear whether files are created or modified in the intended workspace or elsewhere in the filesystem.

As a result:

  • it is unclear what the agent actually does;
  • it is unclear where the agent writes files;
  • the agent may operate in an unknown directory or in an unwanted way.

ollama/x/cmd/run.go

func formatToolShort(toolName string, args map[string]any) string {
	displayName := agent.ToolDisplayName(toolName)
	if toolName == "bash" {
		if cmd, ok := args["command"].(string); ok {
			return fmt.Sprintf("%s: %s", displayName, truncateUTF8(cmd, 50))
		}
	}
	if toolName == "web_search" {
		if query, ok := args["query"].(string); ok {
			return fmt.Sprintf("%s: %s", displayName, truncateUTF8(query, 50))
		}
	}
	return displayName
}
Originally created by @EmilioSchi on GitHub (Jan 23, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/13864 Originally assigned to: @ParthSareen on GitHub. The issue is **not** that the agent executes incorrect commands, but that the **command display is truncated**. Unix shell commands usually place the most important information **at the end** of the command line (pipes, redirections, destination files, `cd`, `-o <file>`, etc.). Because `truncateUTF8()` truncates the command after a fixed number of characters **from the beginning**, the displayed command hides where output is written or which files are modified. In addition, the agent may execute commands in **unknown or implicit working directories**. When relative paths are used, this makes it unclear whether files are created or modified in the intended workspace or elsewhere in the filesystem. As a result: - it is unclear what the agent actually does; - it is unclear where the agent writes files; - the agent may operate in an unknown directory or in an unwanted way. **`ollama/x/cmd/run.go`** ```go func formatToolShort(toolName string, args map[string]any) string { displayName := agent.ToolDisplayName(toolName) if toolName == "bash" { if cmd, ok := args["command"].(string); ok { return fmt.Sprintf("%s: %s", displayName, truncateUTF8(cmd, 50)) } } if toolName == "web_search" { if query, ok := args["query"].(string); ok { return fmt.Sprintf("%s: %s", displayName, truncateUTF8(query, 50)) } } return displayName } ```
GiteaMirror added the feature request label 2026-04-22 18:45:33 -05:00
Author
Owner

@ParthSareen commented on GitHub (Jan 27, 2026):

Thanks for the issue! Will add something for this :)

<!-- gh-comment-id:3804208828 --> @ParthSareen commented on GitHub (Jan 27, 2026): Thanks for the issue! Will add something for this :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#34836