Skip to content

Commit 4771932

Browse files
committed
Refine agent prompt to avoid unnecessary tool use and fix gitignore matching for nested paths
Update system prompt rules so the model answers simple questions directly instead of always calling tools. Fix _gitignore_match to correctly handle bare directory patterns and ** globs in nested paths.
1 parent 6b935d0 commit 4771932

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

teaagent/prompt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
{"type":"final","content":"answer"}
1818
1919
Rules:
20-
- Use tools when workspace inspection or execution is needed.
21-
- Use final only when the task is complete or cannot proceed.
20+
- If the task is a simple question or chat that does not require workspace access, respond immediately with a final answer.
21+
- Use tools only when you need to inspect or modify files, run commands, or gather information from the workspace.
22+
- Do not use tools to explore the workspace unless the task specifically requires it.
23+
- Use final when you have enough information to answer, or when the task is complete.
2224
- Do not invent tool names or arguments.
2325
- Destructive tools may be blocked unless the user explicitly enables destructive actions.
2426
"""

teaagent/workspace_tools/_config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ def matcher(rel_path: str) -> bool:
7070

7171

7272
def _gitignore_match(rel_path: str, pattern: str) -> bool:
73+
path_parts = Path(rel_path).parts
7374
if '/' not in pattern and '**' not in pattern:
74-
return fnmatch(Path(rel_path).name, pattern)
75+
if fnmatch(path_parts[-1], pattern):
76+
return True
77+
return any(part == pattern for part in path_parts)
78+
if '**' in pattern:
79+
segments = pattern.split('/')
80+
glob_dir = segments[-1] if segments[-1] != '**' else None
81+
if glob_dir:
82+
return any(part == glob_dir for part in path_parts)
83+
dir_name = segments[-2] if len(segments) >= 2 else segments[0]
84+
return any(part == dir_name for part in path_parts)
7585
return fnmatch(rel_path, pattern)

0 commit comments

Comments
 (0)