MCPcopy Index your code
hub / github.com/MiniMax-AI/Mini-Agent / execute

Method execute

mini_agent/tools/bash_tool.py:485–532  ·  view source on GitHub ↗

Retrieve output from background shell. Args: bash_id: The unique identifier of the background shell filter_str: Optional regex pattern to filter output lines Returns: BashOutputResult with shell output including stdout, stderr, status, and succes

(
        self,
        bash_id: str,
        filter_str: str | None = None,
    )

Source from the content-addressed store, hash-verified

483 }
484
485 async def execute(
486 self,
487 bash_id: str,
488 filter_str: str | None = None,
489 ) -> BashOutputResult:
490 """Retrieve output from background shell.
491
492 Args:
493 bash_id: The unique identifier of the background shell
494 filter_str: Optional regex pattern to filter output lines
495
496 Returns:
497 BashOutputResult with shell output including stdout, stderr, status, and success flag
498 """
499
500 try:
501 # Get background shell from manager
502 bg_shell = BackgroundShellManager.get(bash_id)
503 if not bg_shell:
504 available_ids = BackgroundShellManager.get_available_ids()
505 return BashOutputResult(
506 success=False,
507 error=f"Shell not found: {bash_id}. Available: {available_ids or 'none'}",
508 stdout="",
509 stderr="",
510 exit_code=-1,
511 )
512
513 # Get new output
514 new_lines = bg_shell.get_new_output(filter_pattern=filter_str)
515 stdout = "\n".join(new_lines) if new_lines else ""
516
517 return BashOutputResult(
518 success=True,
519 stdout=stdout,
520 stderr="", # Background shells combine stdout/stderr
521 exit_code=bg_shell.exit_code if bg_shell.exit_code is not None else 0,
522 bash_id=bash_id,
523 )
524
525 except Exception as e:
526 return BashOutputResult(
527 success=False,
528 error=f"Failed to get bash output: {str(e)}",
529 stdout="",
530 stderr=str(e),
531 exit_code=-1,
532 )
533
534
535class BashKillTool(Tool):

Calls 4

BashOutputResultClass · 0.85
getMethod · 0.80
get_available_idsMethod · 0.80
get_new_outputMethod · 0.80