FIX(app): hardcode Projects folder path

- execute_host가 su ubuntu -c를 사용하도록 변경 (현재 디렉토리 유지)
- 모든 에이전트 프롬프트에 /home/ubuntu/Projects 경로 하드코딩
- tool_name에 따라 올바른 도구(execute_bash/execute_host) 선택하도록 수정
This commit is contained in:
2025-12-24 14:20:30 +09:00
parent 6703476cef
commit d6d85eefd4
8 changed files with 49 additions and 12 deletions

View File

@@ -100,7 +100,12 @@ def backend_code_node(state: AgentState) -> AgentState:
tool_args = tool_call.get('args', {})
try:
tool_func = bash_tools[0]
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **{tool_name}({tool_args.get('command', '')[:50]}...)**:\n{tool_result}")
except Exception as e:

View File

@@ -100,7 +100,12 @@ def frontend_code_node(state: AgentState) -> AgentState:
tool_args = tool_call.get('args', {})
try:
tool_func = bash_tools[0]
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **{tool_name}({tool_args.get('command', '')[:50]}...)**:\n{tool_result}")
except Exception as e:

View File

@@ -59,6 +59,7 @@ INFRASTRUCTURE_PROMPT = """당신은 Multi-Agent System의 **Infrastructure Code
### execute_host (호스트 작업용) ⭐ 주로 사용:
nsenter를 통해 호스트에 직접 접근합니다.
Projects 폴더는 /home/ubuntu/Projects/ 에 있습니다.
- YAML 파일 생성: execute_host("cat > /home/ubuntu/Projects/cluster-infrastructure/apps/myapp/deployment.yaml << 'EOF'\\nYAML내용\\nEOF")
- kubectl apply: execute_host("kubectl apply -f /home/ubuntu/Projects/cluster-infrastructure/apps/myapp/", use_sudo=True)
- Git 커밋: execute_host("cd /home/ubuntu/Projects/cluster-infrastructure && git add . && git commit -m 'Add myapp'")
@@ -104,7 +105,12 @@ def infrastructure_code_node(state: AgentState) -> AgentState:
tool_args = tool_call.get('args', {})
try:
tool_func = bash_tools[0]
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **{tool_name}({tool_args.get('command', '')[:50]}...)**:\n{tool_result}")
except Exception as e:

View File

@@ -21,9 +21,9 @@ ORCHESTRATOR_PROMPT = """당신은 Multi-Agent System의 **총괄 조율자(Orch
## ⚠️ 시스템 환경
- **실행 위치**: Docker 컨테이너 (/app/)
- **호스트 접근**: SSH 필요 (ubuntu@172.17.0.1)
- **Projects 경로**: /home/ubuntu/Projects/ (호스트)
- **Kubernetes**: kubectl은 호스트에서만 작동 (SSH + sudo 필요)
- **호스트 접근**: nsenter를 통한 직접 접근 (SSH 필요)
- **Projects 경로**: /home/ubuntu/Projects/ (oracle-master 서버)
- **Kubernetes**: kubectl은 호스트에서만 작동 (sudo 필요)
## 역할
- 사용자 요청을 분석하고 적절한 에이전트에게 작업 위임
@@ -117,7 +117,12 @@ def orchestrator_node(state: AgentState) -> AgentState:
tool_args = tool_call.get('args', {})
try:
tool_func = bash_tools[0]
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **Orchestrator {tool_name}({tool_args.get('command', '')[:50]}...)**:\n{tool_result}")
except Exception as e:

View File

@@ -60,6 +60,7 @@ nsenter를 통해 호스트 네임스페이스에 직접 접근합니다. SSH보
- execute_host("kubectl logs mas-xxx -n mas --tail=50", use_sudo=True)
**Projects 폴더 탐색:**
Projects 폴더는 /home/ubuntu/Projects/ 에 있습니다 (oracle-master 서버).
- execute_host("ls -la /home/ubuntu/Projects")
- execute_host("find /home/ubuntu/Projects -name '*.git' -type d")
- execute_host("cat /home/ubuntu/Projects/mas/README.md")
@@ -133,7 +134,12 @@ def research_node(state: AgentState) -> AgentState:
# 도구 실행
try:
tool_func = bash_tools[0] # execute_bash
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **{tool_name}({tool_args.get('command', '')})**:\n{tool_result}")
except Exception as e:

View File

@@ -140,7 +140,12 @@ def review_node(state: AgentState) -> AgentState:
tool_args = tool_call.get('args', {})
try:
tool_func = bash_tools[0]
# tool_name에 따라 올바른 도구 선택
from tools.bash_tool import execute_bash, execute_host
if tool_name == "execute_host":
tool_func = execute_host
else:
tool_func = execute_bash
tool_result = tool_func.invoke(tool_args)
tool_outputs.append(f"\n🔧 **Review {tool_name}({tool_args.get('command', '')[:50]}...)**:\n{tool_result}")
except Exception as e:

View File

@@ -65,6 +65,8 @@ def execute_host(command: str, timeout: int = 30, use_sudo: bool = False) -> str
This works by entering the host's namespaces directly from the container.
Much faster than SSH and no authentication needed!
NOTE: Projects folder is located at /home/ubuntu/Projects/ on oracle-master server.
Args:
command: Command to run on the host system
@@ -89,13 +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' for user commands, 'sudo' for privileged commands
# 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
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su - ubuntu -c {subprocess.list2cmdline([command])}"
# 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,