Executor-Tyrant-Framework commited on
Commit
a5ce75e
·
verified ·
1 Parent(s): 265e2e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -12,16 +12,19 @@ import traceback
12
 
13
  """
14
  Clawdbot Unified Command Center
15
- GOLDEN COPY [2026-02-03 - Gemini]
16
- FIXED: Removed 'type="messages"' (Gradio 6 compatibility fix).
17
- INTEGRATED: Polyglot Tool Parser, Retry Logic, Zip Extraction, and Safe Agent Loop.
 
 
 
18
  """
19
 
20
  # =============================================================================
21
  # CONFIGURATION & INIT
22
  # =============================================================================
23
 
24
- # Registry of valid tools for the Parser to verify against
25
  AVAILABLE_TOOLS = {
26
  "list_files", "read_file", "search_code", "write_file",
27
  "create_shadow_branch", "shell_execute", "get_stats",
@@ -278,10 +281,21 @@ def agent_loop(message: str, history: list, pending_proposals: list, uploaded_fi
278
 
279
  accumulated_text = ""
280
  staged_this_turn = []
 
 
 
281
 
282
  # 2. Thinking Loop
283
- for iteration in range(5):
284
  try:
 
 
 
 
 
 
 
 
285
  resp = call_model_with_retry(api_messages, MODEL_ID)
286
  content = resp.choices[0].message.content or ""
287
  except Exception as e:
@@ -319,7 +333,7 @@ def agent_loop(message: str, history: list, pending_proposals: list, uploaded_fi
319
  final += "\n\n🛡️ **Proposals Staged.** Check the Gate tab."
320
  safe_props += staged_this_turn
321
 
322
- if not final: final = "🤔 I processed that but have no text response."
323
 
324
  safe_hist.append({"role": "assistant", "content": final})
325
 
@@ -375,7 +389,7 @@ with gr.Blocks(title="🦞 Clawdbot") as demo:
375
  btn_ref = gr.Button("🔄")
376
  file_in = gr.File(label="Upload", file_count="multiple")
377
  with gr.Column(scale=4):
378
- # FIX: Removed 'type="messages"' as Gradio 6.x defaults to this and removed the arg
379
  chat = gr.Chatbot(height=600, avatar_images=(None, "https://em-content.zobj.net/source/twitter/408/lobster_1f99e.png"))
380
  with gr.Row():
381
  txt = gr.Textbox(scale=6, placeholder="Prompt...")
 
12
 
13
  """
14
  Clawdbot Unified Command Center
15
+ PLATINUM COPY [2026-02-03]
16
+ FEATURES:
17
+ - Stamina: 15 Turns + Forced Summarization (No more silence)
18
+ - Polyglot: Understands [TOOL:...] and XML formats
19
+ - Robustness: Retry logic for API timeouts
20
+ - Compatibility: Gradio 6.x native
21
  """
22
 
23
  # =============================================================================
24
  # CONFIGURATION & INIT
25
  # =============================================================================
26
 
27
+ # Registry of valid tools for validation
28
  AVAILABLE_TOOLS = {
29
  "list_files", "read_file", "search_code", "write_file",
30
  "create_shadow_branch", "shell_execute", "get_stats",
 
281
 
282
  accumulated_text = ""
283
  staged_this_turn = []
284
+
285
+ # FEATURE: Stamina Increased to 15
286
+ MAX_ITERATIONS = 15
287
 
288
  # 2. Thinking Loop
289
+ for iteration in range(MAX_ITERATIONS):
290
  try:
291
+ # FEATURE: Forced Surface Protocol
292
+ if iteration == MAX_ITERATIONS - 1:
293
+ print("⚠️ Max iterations reached. Forcing summary.")
294
+ api_messages.append({
295
+ "role": "system",
296
+ "content": "SYSTEM ALERT: You have reached the maximum number of tool steps. STOP using tools. Immediately summarize your findings and answer the user's request based on what you know now."
297
+ })
298
+
299
  resp = call_model_with_retry(api_messages, MODEL_ID)
300
  content = resp.choices[0].message.content or ""
301
  except Exception as e:
 
333
  final += "\n\n🛡️ **Proposals Staged.** Check the Gate tab."
334
  safe_props += staged_this_turn
335
 
336
+ if not final: final = "🤔 I processed that but have no text response. (Check logs for tool outputs)"
337
 
338
  safe_hist.append({"role": "assistant", "content": final})
339
 
 
389
  btn_ref = gr.Button("🔄")
390
  file_in = gr.File(label="Upload", file_count="multiple")
391
  with gr.Column(scale=4):
392
+ # FIX: Removed 'type="messages"'
393
  chat = gr.Chatbot(height=600, avatar_images=(None, "https://em-content.zobj.net/source/twitter/408/lobster_1f99e.png"))
394
  with gr.Row():
395
  txt = gr.Textbox(scale=6, placeholder="Prompt...")