Yoan Di Cosmo commited on
Commit
5ede083
·
1 Parent(s): 68dc4d3

cleaned comments

Browse files
Files changed (2) hide show
  1. agent/config.py +0 -12
  2. agent/core/agent_loop.py +0 -7
agent/config.py CHANGED
@@ -25,19 +25,7 @@ class Config(BaseModel):
25
 
26
  # Permission control parameters
27
  confirm_cpu_jobs: bool = True
28
- """
29
- If True, agent must ask for user confirmation before launching CPU-only jobs.
30
- If False, agent can run CPU-only jobs automatically without confirmation.
31
- Default: True (require confirmation for safety)
32
- """
33
-
34
  auto_file_upload: bool = False
35
- """
36
- If True, agent may upload files automatically without additional prompts
37
- (user has given prior permission via this config).
38
- If False, agent must ask for user permission before uploading any file.
39
- Default: False (ask permission for safety)
40
- """
41
 
42
 
43
  def substitute_env_vars(obj: Any) -> Any:
 
25
 
26
  # Permission control parameters
27
  confirm_cpu_jobs: bool = True
 
 
 
 
 
 
28
  auto_file_upload: bool = False
 
 
 
 
 
 
29
 
30
 
31
  def substitute_env_vars(obj: Any) -> Any:
agent/core/agent_loop.py CHANGED
@@ -40,13 +40,11 @@ def _validate_tool_args(tool_args: dict) -> tuple[bool, str | None]:
40
 
41
  def _needs_approval(tool_name: str, tool_args: dict, config: Config | None = None) -> bool:
42
  """Check if a tool call requires user approval before execution."""
43
- # If args are malformed, skip approval (validation error will be shown later)
44
  args_valid, _ = _validate_tool_args(tool_args)
45
  if not args_valid:
46
  return False
47
 
48
  if tool_name == "hf_jobs":
49
- # Check if it's a run or scheduled run operation
50
  operation = tool_args.get("operation", "")
51
  if operation not in ["run", "uv", "scheduled run", "scheduled uv"]:
52
  return False
@@ -57,23 +55,18 @@ def _needs_approval(tool_name: str, tool_args: dict, config: Config | None = Non
57
  is_cpu_job = hardware_flavor in CPU_FLAVORS
58
 
59
  if is_cpu_job:
60
- # Check config: if confirm_cpu_jobs is False, skip approval
61
  if config and not config.confirm_cpu_jobs:
62
  return False
63
- # Otherwise, require approval for CPU jobs
64
  return True
65
 
66
- # For GPU jobs, always require approval (existing behavior)
67
  return True
68
 
69
  # Check for file upload operations (hf_private_repos or other tools)
70
  if tool_name == "hf_private_repos":
71
  operation = tool_args.get("operation", "")
72
  if operation == "upload_file":
73
- # Check config: if auto_file_upload is True, skip approval
74
  if config and config.auto_file_upload:
75
  return False
76
- # Otherwise, require approval for file uploads
77
  return True
78
  # Other operations (create_repo, etc.) always require approval
79
  if operation in ["create_repo"]:
 
40
 
41
  def _needs_approval(tool_name: str, tool_args: dict, config: Config | None = None) -> bool:
42
  """Check if a tool call requires user approval before execution."""
 
43
  args_valid, _ = _validate_tool_args(tool_args)
44
  if not args_valid:
45
  return False
46
 
47
  if tool_name == "hf_jobs":
 
48
  operation = tool_args.get("operation", "")
49
  if operation not in ["run", "uv", "scheduled run", "scheduled uv"]:
50
  return False
 
55
  is_cpu_job = hardware_flavor in CPU_FLAVORS
56
 
57
  if is_cpu_job:
 
58
  if config and not config.confirm_cpu_jobs:
59
  return False
 
60
  return True
61
 
 
62
  return True
63
 
64
  # Check for file upload operations (hf_private_repos or other tools)
65
  if tool_name == "hf_private_repos":
66
  operation = tool_args.get("operation", "")
67
  if operation == "upload_file":
 
68
  if config and config.auto_file_upload:
69
  return False
 
70
  return True
71
  # Other operations (create_repo, etc.) always require approval
72
  if operation in ["create_repo"]: