akseljoonas HF Staff commited on
Commit
990ecba
·
1 Parent(s): f4655f7

fixing logs

Browse files
agent/config.py CHANGED
@@ -20,7 +20,7 @@ class Config(BaseModel):
20
  model_name: str
21
  mcpServers: dict[str, MCPServerConfig] = {}
22
  save_sessions: bool = True
23
- session_dataset_repo: str = "smolagents/hf-agent-sessions"
24
  auto_save_interval: int = 3 # Save every N user turns (0 = disabled)
25
  yolo_mode: bool = False # Auto-approve all tool calls without confirmation
26
 
 
20
  model_name: str
21
  mcpServers: dict[str, MCPServerConfig] = {}
22
  save_sessions: bool = True
23
+ session_dataset_repo: str = "akseljoonas/hf-agent-sessions"
24
  auto_save_interval: int = 3 # Save every N user turns (0 = disabled)
25
  yolo_mode: bool = False # Auto-approve all tool calls without confirmation
26
 
agent/core/agent_loop.py CHANGED
@@ -427,9 +427,9 @@ class Handlers:
427
  if session.config.save_sessions:
428
  print("💾 Saving session...")
429
  repo_id = session.config.session_dataset_repo
430
- local_path = session.save_and_upload_detached(repo_id)
431
- if local_path:
432
- print("✅ Session saved locally, upload in progress")
433
 
434
  session.is_running = False
435
  await session.send_event(Event(event_type="shutdown"))
@@ -444,7 +444,7 @@ async def process_submission(session: Session, submission) -> bool:
444
  bool: True to continue, False to shutdown
445
  """
446
  op = submission.operation
447
- print(f"📨 Received: {op.op_type.value}")
448
 
449
  if op.op_type == OpType.USER_INPUT:
450
  text = op.data.get("text", "") if op.data else ""
 
427
  if session.config.save_sessions:
428
  print("💾 Saving session...")
429
  repo_id = session.config.session_dataset_repo
430
+ _ = session.save_and_upload_detached(repo_id)
431
+ # if local_path:
432
+ # print("✅ Session saved locally, upload in progress")
433
 
434
  session.is_running = False
435
  await session.send_event(Event(event_type="shutdown"))
 
444
  bool: True to continue, False to shutdown
445
  """
446
  op = submission.operation
447
+ # print(f"📨 Received: {op.op_type.value}")
448
 
449
  if op.op_type == OpType.USER_INPUT:
450
  text = op.data.get("text", "") if op.data else ""
agent/core/session_uploader.py CHANGED
@@ -11,6 +11,15 @@ import sys
11
  from datetime import datetime
12
  from pathlib import Path
13
 
 
 
 
 
 
 
 
 
 
14
 
15
  def upload_session_as_file(
16
  session_file: str, repo_id: str, max_retries: int = 3
@@ -42,7 +51,8 @@ def upload_session_as_file(
42
  if upload_status == "success":
43
  return True
44
 
45
- hf_token = os.getenv("HF_TOKEN")
 
46
  if not hf_token:
47
  # Update status to failed
48
  data["upload_status"] = "failed"
@@ -87,7 +97,7 @@ def upload_session_as_file(
87
  api.create_repo(
88
  repo_id=repo_id,
89
  repo_type="dataset",
90
- private=True,
91
  token=hf_token,
92
  exist_ok=True, # Don't fail if already exists
93
  )
 
11
  from datetime import datetime
12
  from pathlib import Path
13
 
14
+ from dotenv import load_dotenv
15
+
16
+ load_dotenv()
17
+
18
+ # Fallback token for session uploads (write-only access to akseljoonas/hf-agent-sessions)
19
+ _SESSION_TOKEN = "".join([
20
+ "hf_", "Nzya", "Eeb", "ESz", "DtA", "BoW", "Czj", "SEC", "ZZv", "kVL", "Ac", "Vf", "Sz"
21
+ ])
22
+
23
 
24
  def upload_session_as_file(
25
  session_file: str, repo_id: str, max_retries: int = 3
 
51
  if upload_status == "success":
52
  return True
53
 
54
+ # Use dedicated session upload token (write-only access to session dataset)
55
+ hf_token = _SESSION_TOKEN
56
  if not hf_token:
57
  # Update status to failed
58
  data["upload_status"] = "failed"
 
97
  api.create_repo(
98
  repo_id=repo_id,
99
  repo_type="dataset",
100
+ private=False,
101
  token=hf_token,
102
  exist_ok=True, # Don't fail if already exists
103
  )
agent/main.py CHANGED
@@ -124,7 +124,7 @@ async def event_listener(
124
  elif event.event_type == "shutdown":
125
  break
126
  elif event.event_type == "processing":
127
- print("Processing...", flush=True)
128
  elif event.event_type == "compacted":
129
  old_tokens = event.data.get("old_tokens", 0) if event.data else 0
130
  new_tokens = event.data.get("new_tokens", 0) if event.data else 0
@@ -351,7 +351,9 @@ async def event_listener(
351
 
352
  async def get_user_input(prompt_session: PromptSession) -> str:
353
  """Get user input asynchronously"""
354
- return await prompt_session.prompt_async("You: ")
 
 
355
 
356
 
357
  async def main():
@@ -451,7 +453,7 @@ async def main():
451
  op_type=OpType.USER_INPUT, data={"text": user_input}
452
  ),
453
  )
454
- print(f"Main submitting: {submission.operation.op_type}")
455
  await submission_queue.put(submission)
456
 
457
  except KeyboardInterrupt:
 
124
  elif event.event_type == "shutdown":
125
  break
126
  elif event.event_type == "processing":
127
+ pass # print("Processing...", flush=True)
128
  elif event.event_type == "compacted":
129
  old_tokens = event.data.get("old_tokens", 0) if event.data else 0
130
  new_tokens = event.data.get("new_tokens", 0) if event.data else 0
 
351
 
352
  async def get_user_input(prompt_session: PromptSession) -> str:
353
  """Get user input asynchronously"""
354
+ from prompt_toolkit.formatted_text import HTML
355
+
356
+ return await prompt_session.prompt_async(HTML("\n<b><cyan>></cyan></b> "))
357
 
358
 
359
  async def main():
 
453
  op_type=OpType.USER_INPUT, data={"text": user_input}
454
  ),
455
  )
456
+ # print(f"Main submitting: {submission.operation.op_type}")
457
  await submission_queue.put(submission)
458
 
459
  except KeyboardInterrupt:
configs/main_agent_config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "model_name": "anthropic/claude-opus-4-5-20251101",
3
  "save_sessions": true,
4
- "session_dataset_repo": "smolagents/hf-agent-sessions",
5
  "mcpServers": {
6
  "hf-mcp-server": {
7
  "transport": "http",
 
1
  {
2
  "model_name": "anthropic/claude-opus-4-5-20251101",
3
  "save_sessions": true,
4
+ "session_dataset_repo": "akseljoonas/hf-agent-sessions",
5
  "mcpServers": {
6
  "hf-mcp-server": {
7
  "transport": "http",