massgen 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of massgen might be problematic. Click here for more details.
- massgen/__init__.py +1 -1
- massgen/agent_config.py +33 -7
- massgen/api_params_handler/_api_params_handler_base.py +3 -0
- massgen/api_params_handler/_chat_completions_api_params_handler.py +4 -0
- massgen/api_params_handler/_claude_api_params_handler.py +4 -0
- massgen/api_params_handler/_gemini_api_params_handler.py +4 -0
- massgen/api_params_handler/_response_api_params_handler.py +4 -0
- massgen/backend/azure_openai.py +9 -1
- massgen/backend/base.py +4 -0
- massgen/backend/base_with_custom_tool_and_mcp.py +25 -5
- massgen/backend/claude_code.py +9 -1
- massgen/backend/docs/permissions_and_context_files.md +2 -2
- massgen/backend/gemini.py +35 -6
- massgen/backend/gemini_utils.py +30 -0
- massgen/backend/response.py +2 -0
- massgen/chat_agent.py +9 -3
- massgen/cli.py +291 -43
- massgen/config_builder.py +163 -18
- massgen/configs/README.md +69 -14
- massgen/configs/debug/restart_test_controlled.yaml +60 -0
- massgen/configs/debug/restart_test_controlled_filesystem.yaml +73 -0
- massgen/configs/tools/code-execution/docker_with_sudo.yaml +35 -0
- massgen/configs/tools/custom_tools/computer_use_browser_example.yaml +56 -0
- massgen/configs/tools/custom_tools/computer_use_docker_example.yaml +65 -0
- massgen/configs/tools/custom_tools/computer_use_example.yaml +50 -0
- massgen/configs/tools/custom_tools/crawl4ai_example.yaml +55 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_file_generation_multi.yaml +61 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_file_generation_single.yaml +29 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_image_generation_multi.yaml +51 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_image_generation_single.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_speech_generation_multi.yaml +55 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_speech_generation_single.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_video_generation_multi.yaml +47 -0
- massgen/configs/tools/custom_tools/multimodal_tools/text_to_video_generation_single.yaml +29 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_audio.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_file.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_image.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_video.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/youtube_video_analysis.yaml +59 -0
- massgen/docker/README.md +83 -0
- massgen/filesystem_manager/_code_execution_server.py +22 -7
- massgen/filesystem_manager/_docker_manager.py +21 -1
- massgen/filesystem_manager/_filesystem_manager.py +9 -0
- massgen/filesystem_manager/_path_permission_manager.py +148 -0
- massgen/filesystem_manager/_workspace_tools_server.py +0 -997
- massgen/formatter/_gemini_formatter.py +73 -0
- massgen/frontend/coordination_ui.py +175 -257
- massgen/frontend/displays/base_display.py +29 -0
- massgen/frontend/displays/rich_terminal_display.py +155 -9
- massgen/frontend/displays/simple_display.py +21 -0
- massgen/frontend/displays/terminal_display.py +22 -2
- massgen/logger_config.py +50 -6
- massgen/message_templates.py +283 -15
- massgen/orchestrator.py +335 -38
- massgen/tests/test_binary_file_blocking.py +274 -0
- massgen/tests/test_case_studies.md +12 -12
- massgen/tests/test_code_execution.py +178 -0
- massgen/tests/test_multimodal_size_limits.py +407 -0
- massgen/tests/test_orchestration_restart.py +204 -0
- massgen/tool/__init__.py +4 -0
- massgen/tool/_manager.py +7 -2
- massgen/tool/_multimodal_tools/image_to_image_generation.py +293 -0
- massgen/tool/_multimodal_tools/text_to_file_generation.py +455 -0
- massgen/tool/_multimodal_tools/text_to_image_generation.py +222 -0
- massgen/tool/_multimodal_tools/text_to_speech_continue_generation.py +226 -0
- massgen/tool/_multimodal_tools/text_to_speech_transcription_generation.py +217 -0
- massgen/tool/_multimodal_tools/text_to_video_generation.py +223 -0
- massgen/tool/_multimodal_tools/understand_audio.py +211 -0
- massgen/tool/_multimodal_tools/understand_file.py +555 -0
- massgen/tool/_multimodal_tools/understand_image.py +316 -0
- massgen/tool/_multimodal_tools/understand_video.py +340 -0
- massgen/tool/_web_tools/crawl4ai_tool.py +718 -0
- massgen/tool/docs/multimodal_tools.md +1368 -0
- massgen/tool/workflow_toolkits/__init__.py +26 -0
- massgen/tool/workflow_toolkits/post_evaluation.py +216 -0
- massgen/utils.py +1 -0
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/METADATA +101 -69
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/RECORD +82 -46
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/WHEEL +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/entry_points.txt +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {massgen-0.1.2.dist-info → massgen-0.1.4.dist-info}/top_level.txt +0 -0
massgen/message_templates.py
CHANGED
|
@@ -302,6 +302,8 @@ IMPORTANT: You are responding to the latest message in an ongoing conversation.
|
|
|
302
302
|
original_system_message: Optional[str] = None,
|
|
303
303
|
enable_image_generation: bool = False,
|
|
304
304
|
enable_audio_generation: bool = False,
|
|
305
|
+
enable_file_generation: bool = False,
|
|
306
|
+
enable_video_generation: bool = False,
|
|
305
307
|
has_irreversible_actions: bool = False,
|
|
306
308
|
enable_command_execution: bool = False,
|
|
307
309
|
) -> str:
|
|
@@ -311,6 +313,8 @@ IMPORTANT: You are responding to the latest message in an ongoing conversation.
|
|
|
311
313
|
original_system_message: The agent's original system message to preserve
|
|
312
314
|
enable_image_generation: Whether image generation is enabled
|
|
313
315
|
enable_audio_generation: Whether audio generation is enabled
|
|
316
|
+
enable_file_generation: Whether file generation is enabled
|
|
317
|
+
enable_video_generation: Whether video generation is enabled
|
|
314
318
|
has_irreversible_actions: Whether agent has write access to context paths (requires actual file delivery)
|
|
315
319
|
enable_command_execution: Whether command execution is enabled for this agent
|
|
316
320
|
"""
|
|
@@ -335,21 +339,165 @@ Present the best possible coordinated answer by combining the strengths from all
|
|
|
335
339
|
# Add image generation instructions only if enabled
|
|
336
340
|
if enable_image_generation:
|
|
337
341
|
presentation_instructions += """For image generation tasks:
|
|
338
|
-
|
|
339
|
-
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
|
|
343
|
+
**MANDATORY WORKFLOW - You MUST follow these steps in order:**
|
|
344
|
+
|
|
345
|
+
Step 1: **Check for existing images (REQUIRED)**
|
|
346
|
+
- First, list all files in the Shared Reference directory (temp_workspaces) to find ALL images from EVERY agent
|
|
347
|
+
- Look for image files (.png, .jpg, .jpeg, .gif, .webp, etc.) in each agent's workspace subdirectory
|
|
348
|
+
|
|
349
|
+
Step 2: **Understand ALL existing images (REQUIRED if images exist)**
|
|
350
|
+
- For EACH image file you found, you MUST call the **understand_image** tool to extract its key visual elements, composition, style, and quality
|
|
351
|
+
- Do this for images from yourself AND from other agents - analyze ALL images found
|
|
352
|
+
- DO NOT skip this step even if you think you know the content
|
|
353
|
+
|
|
354
|
+
Step 3: **Synthesize and generate final image (REQUIRED)**
|
|
355
|
+
- If existing images were found and analyzed:
|
|
356
|
+
* Synthesize ALL image analyses into a single, detailed, combined prompt
|
|
357
|
+
* The combined prompt should capture the best visual elements, composition, style, and quality from all analyzed images
|
|
358
|
+
* Call **image_to_image_generation** with this synthesized prompt and ALL images to create the final unified image
|
|
359
|
+
- If NO existing images were found:
|
|
360
|
+
* Generate a new image based directly on the original task requirements
|
|
361
|
+
* Call **text_to_image_generation** with a prompt derived from the original task
|
|
362
|
+
|
|
363
|
+
Step 4: **Save and report (REQUIRED)**
|
|
364
|
+
- Save the final generated image in your workspace
|
|
365
|
+
- Report the saved path in your final answer
|
|
366
|
+
|
|
367
|
+
**CRITICAL**: You MUST complete Steps 1-4 in order. Do not skip checking for existing images. Do not skip calling
|
|
368
|
+
understand_image on found images. This is a mandatory synthesis workflow.
|
|
369
|
+
"""
|
|
370
|
+
# presentation_instructions += """For image generation tasks:
|
|
371
|
+
# - Extract image paths from the existing answer and resolve them in the shared reference.
|
|
372
|
+
# - Gather all agent-produced images (ignore non-existent files).
|
|
373
|
+
# - IMPORTANT: If you find ANY existing images (from yourself or other agents), you MUST call the understand_image tool
|
|
374
|
+
# to analyze EACH image and extract their key visual elements, composition, style, and quality.
|
|
375
|
+
# - IMPORTANT: Synthesize insights from all analyzed images into a detailed, combined prompt that captures the best elements.
|
|
376
|
+
# - IMPORTANT: Call text_to_image_generation with this synthesized prompt to generate the final image.
|
|
377
|
+
# - IMPORTANT: Save the final output in your workspace and output the saved path.
|
|
378
|
+
# - If no existing images are found, generate based on the original task requirements.
|
|
379
|
+
# """
|
|
343
380
|
# Add audio generation instructions only if enabled
|
|
344
381
|
if enable_audio_generation:
|
|
345
382
|
presentation_instructions += """For audio generation tasks:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
-
|
|
351
|
-
-
|
|
352
|
-
|
|
383
|
+
|
|
384
|
+
**MANDATORY WORKFLOW - You MUST follow these steps in order:**
|
|
385
|
+
|
|
386
|
+
Step 1: **Check for existing audios (REQUIRED)**
|
|
387
|
+
- First, list all files in the Shared Reference directory (temp_workspaces) to find ALL audio files from EVERY agent
|
|
388
|
+
- Look for audio files (.mp3, .wav, .flac, etc.) in each agent's workspace subdirectory
|
|
389
|
+
|
|
390
|
+
Step 2: **Understand ALL existing audios (REQUIRED if audios exist)**
|
|
391
|
+
- For EACH audio file you found, you MUST call the **understand_audio** tool to extract its transcription
|
|
392
|
+
- Do this for audios from yourself AND from other agents - analyze ALL audios found
|
|
393
|
+
- DO NOT skip this step even if you think you know the content
|
|
394
|
+
|
|
395
|
+
Step 3: **Synthesize and generate final audio (REQUIRED)**
|
|
396
|
+
- If existing audios were found and analyzed:
|
|
397
|
+
* Synthesize ALL audio transcriptions into a single, detailed, combined transcription
|
|
398
|
+
* The combined transcription should capture the best content from all analyzed audios
|
|
399
|
+
* Call **text_to_speech_transcription_generation** with this synthesized transcription to create the final unified audio
|
|
400
|
+
- If NO existing audios were found:
|
|
401
|
+
* Generate a new audio based directly on the original task requirements
|
|
402
|
+
* Call **text_to_speech_transcription_generation** with a transcription derived from the original task
|
|
403
|
+
|
|
404
|
+
Step 4: **Save and report (REQUIRED)**
|
|
405
|
+
- Save the final generated audio in your workspace
|
|
406
|
+
- Report the saved path in your final answer
|
|
407
|
+
|
|
408
|
+
**CRITICAL**: You MUST complete Steps 1-4 in order. Do not skip checking for existing audios. Do not skip calling
|
|
409
|
+
understand_audio on found audios. This is a mandatory synthesis workflow.
|
|
410
|
+
"""
|
|
411
|
+
# presentation_instructions += """For audio generation tasks:
|
|
412
|
+
# - Extract audio paths from the existing answer and resolve them in the shared reference.
|
|
413
|
+
# - Gather ALL audio files produced by EVERY agent (ignore non-existent files).
|
|
414
|
+
# - IMPORTANT: If you find ANY existing audios (from yourself or other agents), you MUST call the **understand_audio** tool to extract each audio's transcription.
|
|
415
|
+
# - IMPORTANT: Synthesize transcriptions from all audios into a detailed, combined transcription.
|
|
416
|
+
# - IMPORTANT: You MUST call the **text_to_speech_transcription_generation** tool with this synthesized transcription to generate the final audio.
|
|
417
|
+
# - IMPORTANT: Save the final output in your workspace and output the saved path.
|
|
418
|
+
# - If no existing audios are found, generate based on the original task requirements.
|
|
419
|
+
# """
|
|
420
|
+
# Add file generation instructions only if enabled
|
|
421
|
+
if enable_file_generation:
|
|
422
|
+
presentation_instructions += """For file generation tasks:
|
|
423
|
+
|
|
424
|
+
**MANDATORY WORKFLOW - You MUST follow these steps in order:**
|
|
425
|
+
|
|
426
|
+
Step 1: **Check for existing files (REQUIRED)**
|
|
427
|
+
- First, list all files in the Shared Reference directory (temp_workspaces) to find ALL files from EVERY agent
|
|
428
|
+
- Look for files of the requested type in each agent's workspace subdirectory
|
|
429
|
+
|
|
430
|
+
Step 2: **Understand ALL existing files (REQUIRED if files exist)**
|
|
431
|
+
- For EACH file you found, you MUST call the **understand_file** tool to extract its content, structure, and key elements
|
|
432
|
+
- Do this for files from yourself AND from other agents - analyze ALL files found
|
|
433
|
+
- DO NOT skip this step even if you think you know the content
|
|
434
|
+
|
|
435
|
+
Step 3: **Synthesize and generate final file (REQUIRED)**
|
|
436
|
+
- If existing files were found and analyzed:
|
|
437
|
+
* Synthesize ALL file contents into a single, detailed, combined content
|
|
438
|
+
* The combined content should capture the best elements, structure, and information from all analyzed files
|
|
439
|
+
* Call **text_to_file_generation** with this synthesized content to generate the final unified file
|
|
440
|
+
- If NO existing files were found:
|
|
441
|
+
* Generate a new file based directly on the original task requirements
|
|
442
|
+
* Call **text_to_file_generation** with content derived from the original task
|
|
443
|
+
|
|
444
|
+
Step 4: **Save and report (REQUIRED)**
|
|
445
|
+
- Save the final generated file in your workspace
|
|
446
|
+
- Report the saved path in your final answer
|
|
447
|
+
|
|
448
|
+
**CRITICAL**: You MUST complete Steps 1-4 in order. Do not skip checking for existing files. Do not skip calling
|
|
449
|
+
understand_file on found files. This is a mandatory synthesis workflow.
|
|
450
|
+
"""
|
|
451
|
+
# presentation_instructions += """For file generation tasks:
|
|
452
|
+
# - Extract file paths from the existing answer and resolve them in the shared reference.
|
|
453
|
+
# - Gather ALL files produced by EVERY agent (ignore non-existent files).
|
|
454
|
+
# - IMPORTANT: If you find ANY existing files (from yourself or other agents), you MUST call the **understand_file** tool to extract each file's content.
|
|
455
|
+
# - IMPORTANT: Synthesize contents from all files into a detailed, combined content.
|
|
456
|
+
# - IMPORTANT: You MUST call the **text_to_file_generation** tool with this synthesized content to generate the final file.
|
|
457
|
+
# - IMPORTANT: Save the final output in your workspace and output the saved path.
|
|
458
|
+
# - If no existing files are found, generate based on the original task requirements.
|
|
459
|
+
# """
|
|
460
|
+
# Add video generation instructions only if enabled
|
|
461
|
+
if enable_video_generation:
|
|
462
|
+
presentation_instructions += """For video generation tasks:
|
|
463
|
+
|
|
464
|
+
**MANDATORY WORKFLOW - You MUST follow these steps in order:**
|
|
465
|
+
|
|
466
|
+
Step 1: **Check for existing videos (REQUIRED)**
|
|
467
|
+
- First, list all files in the Shared Reference directory (temp_workspaces) to find ALL videos from EVERY agent
|
|
468
|
+
- Look for video files (.mp4, .avi, .mov, etc.) in each agent's workspace subdirectory
|
|
469
|
+
|
|
470
|
+
Step 2: **Understand ALL existing videos (REQUIRED if videos exist)**
|
|
471
|
+
- For EACH video file you found, you MUST call the **understand_video** tool to extract its description, visual features, and
|
|
472
|
+
key elements
|
|
473
|
+
- Do this for videos from yourself AND from other agents - analyze ALL videos found
|
|
474
|
+
- DO NOT skip this step even if you think you know the content
|
|
475
|
+
|
|
476
|
+
Step 3: **Synthesize and generate final video (REQUIRED)**
|
|
477
|
+
- If existing videos were found and analyzed:
|
|
478
|
+
* Synthesize ALL video descriptions into a single, detailed, combined prompt
|
|
479
|
+
* The combined prompt should capture the best visual elements, composition, motion, and style from all analyzed videos
|
|
480
|
+
* Call **text_to_video_generation** with this synthesized prompt to create the final unified video
|
|
481
|
+
- If NO existing videos were found:
|
|
482
|
+
* Generate a new video based directly on the original task requirements
|
|
483
|
+
* Call **text_to_video_generation** with a prompt derived from the original task
|
|
484
|
+
|
|
485
|
+
Step 4: **Save and report (REQUIRED)**
|
|
486
|
+
- Save the final generated video in your workspace
|
|
487
|
+
- Report the saved path in your final answer
|
|
488
|
+
|
|
489
|
+
**CRITICAL**: You MUST complete Steps 1-4 in order. Do not skip checking for existing videos. Do not skip calling
|
|
490
|
+
understand_video on found videos. This is a mandatory synthesis workflow.
|
|
491
|
+
"""
|
|
492
|
+
# presentation_instructions += """For video generation tasks:
|
|
493
|
+
# - Extract video paths from the existing answer and resolve them in the shared reference.
|
|
494
|
+
# - Gather ALL videos produced by EVERY agent (ignore non-existent files).
|
|
495
|
+
# - IMPORTANT: If you find ANY existing videos (from yourself or other agents), you MUST call the **understand_video** tool to extract each video's description and key features.
|
|
496
|
+
# - IMPORTANT: Synthesize descriptions from all videos into a detailed, combined prompt capturing the best elements.
|
|
497
|
+
# - IMPORTANT: You MUST call the **text_to_video_generation** tool with this synthesized prompt to generate the final video.
|
|
498
|
+
# - IMPORTANT: Save the final output in your workspace and output the saved path.
|
|
499
|
+
# - If no existing videos are found, generate based on the original task requirements.
|
|
500
|
+
# """
|
|
353
501
|
|
|
354
502
|
# Add irreversible actions reminder if needed
|
|
355
503
|
# TODO: Integrate more general irreversible actions handling in future (i.e., not just for context file delivery)
|
|
@@ -378,6 +526,93 @@ Present the best possible coordinated answer by combining the strengths from all
|
|
|
378
526
|
else:
|
|
379
527
|
return presentation_instructions
|
|
380
528
|
|
|
529
|
+
def post_evaluation_system_message(
|
|
530
|
+
self,
|
|
531
|
+
original_system_message: Optional[str] = None,
|
|
532
|
+
) -> str:
|
|
533
|
+
"""System message for post-evaluation phase after final presentation.
|
|
534
|
+
|
|
535
|
+
The winning agent evaluates its own answer with a fresh perspective and decides
|
|
536
|
+
whether to submit or restart with specific improvement instructions.
|
|
537
|
+
|
|
538
|
+
Args:
|
|
539
|
+
original_system_message: The agent's original system message to preserve
|
|
540
|
+
"""
|
|
541
|
+
if "post_evaluation_system_message" in self._template_overrides:
|
|
542
|
+
return str(self._template_overrides["post_evaluation_system_message"])
|
|
543
|
+
|
|
544
|
+
evaluation_instructions = """## Post-Presentation Evaluation
|
|
545
|
+
|
|
546
|
+
You have just presented a final answer to the user. Now you must evaluate whether your answer fully addresses the original task.
|
|
547
|
+
|
|
548
|
+
**Your Task:**
|
|
549
|
+
Review the final answer that was presented and determine if it completely and accurately addresses the original task requirements.
|
|
550
|
+
|
|
551
|
+
**Available Tools:**
|
|
552
|
+
You have access to the same filesystem and MCP tools that were available during presentation. Use these tools to:
|
|
553
|
+
- Verify that claimed files actually exist in the workspace
|
|
554
|
+
- Check file contents to confirm they match what was described
|
|
555
|
+
- Validate any technical claims or implementations
|
|
556
|
+
|
|
557
|
+
**Decision:**
|
|
558
|
+
You must call ONE of these tools:
|
|
559
|
+
|
|
560
|
+
1. **submit(confirmed=True)** - Use this when:
|
|
561
|
+
- The answer fully addresses ALL parts of the original task
|
|
562
|
+
- All claims in the answer are accurate and verified
|
|
563
|
+
- The work is complete and ready for the user
|
|
564
|
+
|
|
565
|
+
2. **restart_orchestration(reason, instructions)** - Use this when:
|
|
566
|
+
- The answer is incomplete (missing required elements)
|
|
567
|
+
- The answer contains errors or inaccuracies
|
|
568
|
+
- Important aspects of the task were not addressed
|
|
569
|
+
|
|
570
|
+
Provide:
|
|
571
|
+
- **reason**: Clear explanation of what's wrong (e.g., "The task required descriptions of two Beatles, but only John Lennon was described")
|
|
572
|
+
- **instructions**: Detailed, actionable guidance for the next attempt (e.g.,
|
|
573
|
+
"Provide two descriptions (John Lennon AND Paul McCartney). Each should include:
|
|
574
|
+
birth year, role in band, notable songs, impact on music. Use 4-6 sentences per person.")
|
|
575
|
+
|
|
576
|
+
**Important Notes:**
|
|
577
|
+
- Be honest and thorough in your evaluation
|
|
578
|
+
- You are evaluating your own work with a fresh perspective
|
|
579
|
+
- If you find problems, restarting with clear instructions will lead to a better result
|
|
580
|
+
- The restart process gives you another opportunity to get it right
|
|
581
|
+
"""
|
|
582
|
+
|
|
583
|
+
# Combine with original system message if provided
|
|
584
|
+
if original_system_message:
|
|
585
|
+
return f"""{original_system_message}
|
|
586
|
+
|
|
587
|
+
{evaluation_instructions}"""
|
|
588
|
+
else:
|
|
589
|
+
return evaluation_instructions
|
|
590
|
+
|
|
591
|
+
def format_restart_context(self, reason: str, instructions: str) -> str:
|
|
592
|
+
"""Format restart context for subsequent orchestration attempts.
|
|
593
|
+
|
|
594
|
+
This context is added to agent messages (like multi-turn context) on restart attempts.
|
|
595
|
+
|
|
596
|
+
Args:
|
|
597
|
+
reason: Why the previous attempt was insufficient
|
|
598
|
+
instructions: Detailed guidance for improvement
|
|
599
|
+
"""
|
|
600
|
+
if "format_restart_context" in self._template_overrides:
|
|
601
|
+
override = self._template_overrides["format_restart_context"]
|
|
602
|
+
if callable(override):
|
|
603
|
+
return override(reason, instructions)
|
|
604
|
+
return str(override).format(reason=reason, instructions=instructions)
|
|
605
|
+
|
|
606
|
+
return f"""<PREVIOUS ATTEMPT FEEDBACK>
|
|
607
|
+
The previous orchestration attempt was restarted because:
|
|
608
|
+
{reason}
|
|
609
|
+
|
|
610
|
+
**Instructions for this attempt:**
|
|
611
|
+
{instructions}
|
|
612
|
+
|
|
613
|
+
Please address these specific issues in your coordination and final answer.
|
|
614
|
+
<END OF PREVIOUS ATTEMPT FEEDBACK>"""
|
|
615
|
+
|
|
381
616
|
# =============================================================================
|
|
382
617
|
# COMPLETE MESSAGE BUILDERS
|
|
383
618
|
# =============================================================================
|
|
@@ -509,10 +744,36 @@ Based on the coordination process above, present your final answer:"""
|
|
|
509
744
|
messages.append({"role": "user", "content": self.enforcement_message()})
|
|
510
745
|
return messages
|
|
511
746
|
|
|
512
|
-
def command_execution_system_message(
|
|
513
|
-
|
|
747
|
+
def command_execution_system_message(
|
|
748
|
+
self,
|
|
749
|
+
docker_mode: bool = False,
|
|
750
|
+
enable_sudo: bool = False,
|
|
751
|
+
) -> str:
|
|
752
|
+
"""Generate concise command execution instructions when command line execution is enabled.
|
|
753
|
+
|
|
754
|
+
Args:
|
|
755
|
+
docker_mode: Whether commands execute in Docker containers
|
|
756
|
+
enable_sudo: Whether sudo is available in Docker containers
|
|
757
|
+
"""
|
|
514
758
|
parts = ["## Command Execution"]
|
|
515
759
|
parts.append("You can run command line commands using the `execute_command` tool.\n")
|
|
760
|
+
|
|
761
|
+
if docker_mode:
|
|
762
|
+
parts.append("**IMPORTANT: Docker Execution Environment**")
|
|
763
|
+
parts.append("- You are running in a Linux Docker container (Debian-based)")
|
|
764
|
+
parts.append("- Base image: Python 3.11-slim with Node.js 20.x")
|
|
765
|
+
parts.append("- Pre-installed: git, curl, build-essential, pytest, requests, numpy, pandas")
|
|
766
|
+
parts.append("- Use `apt-get` for system packages (NOT brew, dnf, yum, etc.)")
|
|
767
|
+
|
|
768
|
+
if enable_sudo:
|
|
769
|
+
parts.append("- **Sudo is available**: You can install packages with `sudo apt-get install <package>`")
|
|
770
|
+
parts.append("- Example: `sudo apt-get update && sudo apt-get install -y ffmpeg`")
|
|
771
|
+
else:
|
|
772
|
+
parts.append("- Sudo is NOT available - use pip/npm for user-level packages only")
|
|
773
|
+
parts.append("- For system packages, ask the user to rebuild the Docker image with needed packages")
|
|
774
|
+
|
|
775
|
+
parts.append("")
|
|
776
|
+
|
|
516
777
|
parts.append("If a `.venv` directory exists in your workspace, it will be automatically used.")
|
|
517
778
|
|
|
518
779
|
return "\n".join(parts)
|
|
@@ -527,6 +788,8 @@ Based on the coordination process above, present your final answer:"""
|
|
|
527
788
|
enable_image_generation: bool = False,
|
|
528
789
|
agent_answers: Optional[Dict[str, str]] = None,
|
|
529
790
|
enable_command_execution: bool = False,
|
|
791
|
+
docker_mode: bool = False,
|
|
792
|
+
enable_sudo: bool = False,
|
|
530
793
|
) -> str:
|
|
531
794
|
"""Generate filesystem access instructions for agents with filesystem support.
|
|
532
795
|
|
|
@@ -539,6 +802,8 @@ Based on the coordination process above, present your final answer:"""
|
|
|
539
802
|
enable_image_generation: Whether image generation is enabled
|
|
540
803
|
agent_answers: Dict of agent answers (keys are agent IDs) to show workspace structure
|
|
541
804
|
enable_command_execution: Whether command line execution is enabled
|
|
805
|
+
docker_mode: Whether commands execute in Docker containers
|
|
806
|
+
enable_sudo: Whether sudo is available in Docker containers
|
|
542
807
|
"""
|
|
543
808
|
if "filesystem_system_message" in self._template_overrides:
|
|
544
809
|
return str(self._template_overrides["filesystem_system_message"])
|
|
@@ -704,7 +969,10 @@ Based on the coordination process above, present your final answer:"""
|
|
|
704
969
|
|
|
705
970
|
# Add command execution instructions if enabled
|
|
706
971
|
if enable_command_execution:
|
|
707
|
-
command_exec_message = self.command_execution_system_message(
|
|
972
|
+
command_exec_message = self.command_execution_system_message(
|
|
973
|
+
docker_mode=docker_mode,
|
|
974
|
+
enable_sudo=enable_sudo,
|
|
975
|
+
)
|
|
708
976
|
parts.append(f"\n{command_exec_message}")
|
|
709
977
|
|
|
710
978
|
return "\n".join(parts)
|