Skip to content

orchestrator

orchestrator

OrchestratorAgent — multi-turn agent with tool-calling loop.

Supports two modes:

  • function_calling (default): Uses OpenAI-format tool definitions and parses tool_calls from the engine response.
  • structured: Uses a THOUGHT/TOOL/INPUT/FINAL_ANSWER text format (like ReAct) with a canonical system prompt from the orchestrator prompt registry. This is the format used by the SFT/GRPO training pipelines, making the Orchestrator a distinctive trainable agent type.

Classes

OrchestratorAgent

OrchestratorAgent(engine: InferenceEngine, model: str, *, tools: Optional[List[BaseTool]] = None, bus: Optional[EventBus] = None, max_turns: Optional[int] = None, temperature: Optional[float] = None, max_tokens: Optional[int] = None, mode: str = 'function_calling', system_prompt: Optional[str] = None, parallel_tools: bool = True, interactive: bool = False, confirm_callback=None)

Bases: ToolUsingAgent

Multi-turn agent that routes between tools and the LLM.

Implements a tool-calling loop: 1. Send messages with tool definitions to the engine. 2. If the response contains tool_calls, execute them and loop. 3. If no tool_calls, return the final answer. 4. Stop after max_turns iterations.

In structured mode the agent instead uses a THOUGHT: / TOOL: / INPUT: / FINAL_ANSWER: text protocol identical to the format used by the orchestrator SFT/GRPO training pipelines.

Source code in src/openjarvis/agents/orchestrator.py
def __init__(
    self,
    engine: InferenceEngine,
    model: str,
    *,
    tools: Optional[List[BaseTool]] = None,
    bus: Optional[EventBus] = None,
    max_turns: Optional[int] = None,
    temperature: Optional[float] = None,
    max_tokens: Optional[int] = None,
    mode: str = "function_calling",
    system_prompt: Optional[str] = None,
    parallel_tools: bool = True,
    interactive: bool = False,
    confirm_callback=None,
) -> None:
    super().__init__(
        engine,
        model,
        tools=tools,
        bus=bus,
        max_turns=max_turns,
        temperature=temperature,
        max_tokens=max_tokens,
        interactive=interactive,
        confirm_callback=confirm_callback,
    )
    self._mode = mode
    self._system_prompt = system_prompt
    self._parallel_tools = parallel_tools