run (agent)

swarms · ai, automation, agent-execution, streaming, multimodal-inputs, reasoning-flow

Primary entrypoint for executing an agent's reasoning flow on a task, supporting interactive/autonomous modes, image inputs, streaming, and fallback error handling.

    def run(
        self,
        task: Optional[Union[str, Any]] = None,
        img: Optional[str] = None,
        imgs: Optional[List[str]] = None,
        correct_answer: Optional[str] = None,
        streaming_callback: Optional[Callable[[str], None]] = None,
        n: int = 1,
        *args,
        **kwargs,
    ) -> Any:
        """
        Execute the agent's main reasoning/thinking flow (single or multi-step).

        This is the primary entrypoint for running an agent on a given task, optionally with one or more images and with support for both interactive and autonomous flows.

        Core Features:
            - Handles both interactive (asks user) and autonomous (auto-plan/execute) operation modes.
            - Supports passing a single image or batch of images.
        

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key