FEAT(app): enhance agent auto-discovery and analysis
- Add folder/file auto-discovery guidelines to Research Agent - Add K8s status auto-analysis and solution suggestion - Improve Orchestrator to delegate auto-discovery to Research Agent - Improve Planning Agent to specify research_needed for auto-discovery - Enable automatic path finding for user requests
This commit is contained in:
@@ -32,6 +32,17 @@ ORCHESTRATOR_PROMPT = """당신은 Multi-Agent System의 **총괄 조율자(Orch
|
||||
- 에러 발생 시 복구 전략 수립
|
||||
- 필요시 직접 명령어 실행 (간단한 조회/검증)
|
||||
|
||||
## 자동 탐색 및 분석 요청 처리
|
||||
|
||||
사용자가 다음과 같은 요청을 하면:
|
||||
- "폴더/파일 찾아서 해줘"
|
||||
- "현재 k8s 상태 분석해서 해결책 제시해줘"
|
||||
- "Projects에 어떤 레포가 있는지 확인해줘"
|
||||
- "문제를 찾아서 해결해줘"
|
||||
|
||||
**즉시 Research Agent에게 위임**하고, Research Agent가 자동으로 탐색하고 분석하도록 지시하세요.
|
||||
Research Agent는 경로를 모르더라도 자동으로 찾아서 작업할 수 있습니다.
|
||||
|
||||
## 사용 가능한 도구
|
||||
|
||||
### execute_host (호스트 접근용) ⭐ 주로 사용
|
||||
|
||||
@@ -32,6 +32,21 @@ PLANNING_PROMPT = """당신은 Multi-Agent System의 **Planning Agent**입니다
|
||||
4. 정보 필요성 파악: 어떤 정보를 수집해야 하는지
|
||||
5. 성공 기준 설정: 언제 작업이 완료된 것으로 볼지
|
||||
|
||||
## 자동 탐색 요청 처리
|
||||
사용자가 다음과 같은 요청을 하면:
|
||||
- "폴더/파일 찾아서 해줘"
|
||||
- "현재 k8s 상태 분석해서 해결책 제시해줘"
|
||||
- "Projects에 어떤 레포가 있는지 확인해줘"
|
||||
- "문제를 찾아서 해결해줘"
|
||||
|
||||
**research_needed에 자동 탐색이 필요함을 명시**하세요:
|
||||
- "Projects 폴더 내의 모든 Git 레포지토리 목록 조사"
|
||||
- "Kubernetes 클러스터 전체 상태 분석 (Pod, Deployment, Service)"
|
||||
- "특정 폴더/파일 자동 탐색 및 위치 확인"
|
||||
- "에러 로그 분석 및 원인 파악"
|
||||
|
||||
Research Agent는 경로를 모르더라도 자동으로 찾아서 작업할 수 있습니다.
|
||||
|
||||
## 출력 형식 (JSON)
|
||||
반드시 다음 JSON 형식으로 출력하세요:
|
||||
```json
|
||||
|
||||
@@ -42,11 +42,12 @@ RESEARCH_PROMPT = """당신은 Multi-Agent System의 **Research Agent**입니다
|
||||
|
||||
## 역할
|
||||
- 호스트 시스템 정보 수집 (nsenter 사용)
|
||||
- Kubernetes 클러스터 상태 조회
|
||||
- Kubernetes 클러스터 상태 조회 및 분석
|
||||
- PostgreSQL 데이터베이스 탐색
|
||||
- Git 레포지토리 분석
|
||||
- 파일 시스템 검색
|
||||
- 파일/폴더 자동 탐색 및 검색
|
||||
- Prometheus 메트릭 수집
|
||||
- **중요**: 사용자가 "찾아서 해줘", "분석해서 해결책 제시해줘" 같은 요청을 받으면, 자동으로 탐색하고 분석하여 결과를 제공해야 합니다.
|
||||
|
||||
## 사용 가능한 도구
|
||||
|
||||
@@ -98,10 +99,35 @@ Projects 폴더는 /home/ubuntu/Projects/ 에 있습니다 (oracle-master 서버
|
||||
}
|
||||
```
|
||||
|
||||
## 자동 탐색 및 분석 가이드라인
|
||||
|
||||
### 폴더/파일 찾기 요청 시:
|
||||
1. **자동으로 탐색 시작**: 사용자가 "폴더 찾아서 해줘"라고 하면, 즉시 탐색을 시작하세요.
|
||||
2. **다양한 방법 시도**:
|
||||
- `find /home/ubuntu/Projects -type d -name "*폴더명*"` (대소문자 무시: `-iname`)
|
||||
- `find /home/ubuntu -type d -name "*폴더명*" 2>/dev/null` (전체 홈 디렉토리 검색)
|
||||
- `ls -la /home/ubuntu/Projects | grep -i "폴더명"`
|
||||
3. **파일 찾기**:
|
||||
- `find /home/ubuntu/Projects -type f -name "*파일명*"`
|
||||
- `find /home/ubuntu/Projects -type f -iname "*.확장자"`
|
||||
4. **결과 분석**: 찾은 파일/폴더의 내용을 확인하고 사용자에게 보고하세요.
|
||||
|
||||
### Kubernetes 상태 분석 요청 시:
|
||||
1. **전체 클러스터 상태 확인**:
|
||||
- `kubectl get nodes` (use_sudo=True)
|
||||
- `kubectl get pods -A` (use_sudo=True)
|
||||
- `kubectl get deployments -A` (use_sudo=True)
|
||||
2. **문제가 있는 리소스 식별**:
|
||||
- `kubectl get pods -A | grep -v Running` (실행 중이 아닌 Pod 찾기)
|
||||
- `kubectl describe pod <pod-name> -n <namespace>` (문제 Pod 상세 확인)
|
||||
- `kubectl logs <pod-name> -n <namespace> --tail=100` (로그 확인)
|
||||
3. **자동 분석 및 해결책 제시**: 문제를 식별한 후 해결 방법을 제안하세요.
|
||||
|
||||
## 주의사항
|
||||
- 여러 명령어를 실행하여 충분한 정보 수집
|
||||
- 에러 발생 시 대안 명령어 시도
|
||||
- 보안에 민감한 정보는 마스킹
|
||||
- **사용자가 명시적으로 경로를 제공하지 않아도, 자동으로 탐색하고 찾아서 작업하세요**
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -91,15 +91,16 @@ def execute_host(command: str, timeout: int = 30, use_sudo: bool = False) -> str
|
||||
# -n: network namespace
|
||||
# -i: IPC namespace
|
||||
# Run as ubuntu user to avoid git "dubious ownership" errors
|
||||
# Use 'su - ubuntu -c' to get proper environment variables and PATH
|
||||
# Projects folder is at /home/ubuntu/Projects (hardcoded in prompts)
|
||||
# Use 'su ubuntu -c' (without -) to preserve current directory context
|
||||
# This allows commands to work from SSH initial directory
|
||||
if use_sudo:
|
||||
# For sudo commands, run directly with sudo
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- sh -c {subprocess.list2cmdline([f'sudo {command}'])}"
|
||||
else:
|
||||
# For regular commands, run as ubuntu user with login shell
|
||||
# This ensures proper environment variables (PATH, HOME, etc.)
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su - ubuntu -c {subprocess.list2cmdline([command])}"
|
||||
# For regular commands, run as ubuntu user
|
||||
# Use 'su ubuntu -c' (not 'su - ubuntu -c') to preserve current directory
|
||||
# This matches SSH behavior where you start from the initial directory
|
||||
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su ubuntu -c {subprocess.list2cmdline([command])}"
|
||||
|
||||
result = subprocess.run(
|
||||
nsenter_command,
|
||||
|
||||
Reference in New Issue
Block a user