#3872: improve bash-tools.exec.ts code quality
agents
- Better error messages and type safety
- Extract magic numbers to constants
- Stricter input validation
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR refines the `exec` tool implementation in `src/agents/bash-tools.exec.ts` by extracting a few “magic numbers” into named constants (PTY default cols/rows and the timeout finalize window), tightening the `command` input validation to reject blank/whitespace-only commands, and slightly improving PTY-related error messaging. These changes are localized to the exec tool/process execution path and don’t affect other agents/tools.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The diff is small and localized, and the changes are straightforward refactors (constants) plus stricter validation (`command?.trim()`) and an error-message tweak; no behavior changes beyond rejecting whitespace-only commands and using named constants for existing values.
- src/agents/bash-tools.exec.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#12871: fix: use bash and warn about shell injection (issue #12836)
by ambicuity · 2026-02-09
80.7%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
78.6%
#6110: refactor: simplify boolean logic using nullish coalescing
by T1mn · 2026-02-01
78.4%
#8888: fix: increase tool result/error context limits
by joetomasone · 2026-02-04
78.3%
#11854: fix: resolve per-agent tools.exec config in pi-tools
by Yida-Dev · 2026-02-08
78.1%
#9273: Add files via upload
by cyrilliu1974 · 2026-02-05
78.0%
#11300: feat(exec): make shell configurable via tools.exec.shell
by imjszhang · 2026-02-07
77.8%
#7252: docs: align config examples and tool docs with current runtime
by nice-and-precise · 2026-02-02
77.3%
#6819: fix(tui): handle unstructured tool results and errors in tool execu...
by TreyDong · 2026-02-02
77.0%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
76.4%