# Focused, Closed, and Open Execution Modes in AgentPlatform

> Understand Focused Closed and Open execution modes in Embabel AgentPlatform. Choose the right mode for deterministic control or flexible agent composition.

- Repository: [Embabel/embabel-agent](https://github.com/embabel/embabel-agent)
- Tags: deep-dive
- Published: 2026-08-08

---

**The Embabel AgentPlatform provides three distinct execution modes—Focused (caller-selected agents), Closed (intent-matched agents), and Open (dynamically composed agents)—that trade deterministic control for flexibility depending on whether the caller, the platform, or an AI planner decides which code executes.**

The `embabel/embabel-agent` repository implements these execution strategies through the core `AgentPlatform` API to support diverse AI deployment patterns. Choosing between **Focused**, **Closed**, and **Open execution modes** determines how agents are selected, bound, and executed at runtime. This guide examines the technical implementation, determinism characteristics, and source code architecture behind each mode as defined in the project's [[`README.md`](https://github.com/embabel/embabel-agent/blob/main/README.md)](https://github.com/embabel/embabel-agent/blob/main/README.md#L124-L140) and implemented in [`AgentPlatform.kt`](https://github.com/embabel/embabel-agent/blob/main/AgentPlatform.kt).

## Execution Mode Overview

The three modes represent a spectrum of control versus flexibility. **Focused** mode offers the highest determinism by allowing the caller to specify the exact agent class. **Closed** mode introduces dynamic selection by matching incoming intents to registered agents while keeping execution bounded. **Open** mode enables the platform to synthesize novel agents by composing capabilities from across the codebase, maximizing flexibility at the cost of predictability.

## Focused Execution Mode

**Focused** mode is the most deterministic and straightforward execution strategy. The caller explicitly selects a concrete agent class or bean and invokes it directly with the required input parameters.

This mode is ideal for code-driven flows where the execution path must remain constant, such as HTTP endpoints that trigger specific agents to process requests. Because the runtime performs no intent classification or goal discovery, the same agent executes reliably on every invocation.

In [`AgentPlatform.kt`](https://github.com/embabel/embabel-agent/blob/main/AgentPlatform.kt), this corresponds to the `runAgent` method:

```kotlin
// Focused – the caller knows exactly which agent to run
val resultFocused = agentPlatform.runAgent(
    agentClass = MyTravelPlannerAgent::class,
    input = TravelRequest(origin = "NYC", destination = "Paris")
)

```

The platform instantiates the specified `MyTravelPlannerAgent` class and executes its actions without additional lookup or planning overhead.

## Closed Execution Mode

**Closed** mode adds a lightweight discovery step while maintaining bounded execution. The platform receives an intent or event string, looks up a matching agent among pre-registered candidates, and executes only that agent's defined actions.

This approach suits event-driven systems where incoming intents determine which predefined agent should handle the request. While agent selection is dynamic, execution remains deterministic once the match occurs, assuming consistent registration state.

The implementation uses the `runAgentByIntent` method:

```kotlin
// Closed – the platform selects a matching agent based on an intent string
val resultClosed = agentPlatform.runAgentByIntent(
    intent = "plan-travel",
    input = TravelRequest(origin = "NYC", destination = "Paris")
)

```

If multiple agents register for the same intent, the platform applies selection logic, though the execution remains confined to the chosen agent's capabilities.

## Open Execution Mode

**Open** mode unlocks the full expressive power of the framework by enabling dynamic agent composition. The platform analyzes the user's high-level goal, searches all known capabilities across the codebase, and constructs a brand-new agent on the fly that stitches together necessary actions and conditions.

This mode supports open-ended tasks where the system must discover novel plans, such as generating a weekend itinerary by combining transportation, lodging, and dining capabilities from disparate agents. However, this flexibility reduces determinism, as the platform may generate different execution graphs on successive runs.

Implemented via the `runGoal` method:

```kotlin
// Open – the platform builds a brand-new agent to fulfil a high-level goal
val resultOpen = agentPlatform.runGoal(
    goal = "plan-a-weekend-getaway",
    input = GoalInput(location = "San Francisco", budget = 500)
)

```

The additional planning work required for goal decomposition and capability matching makes this mode potentially slower than Focused or Closed execution.

## Source Code Architecture

The execution modes are defined in the repository's [[`README.md`](https://github.com/embabel/embabel-agent/blob/main/README.md)](https://github.com/embabel/embabel-agent/blob/main/README.md#L124-L140) and implemented across several key files:

- **[`AgentPlatform.kt`](https://github.com/embabel/embabel-agent/blob/main/AgentPlatform.kt)** (`embabel-agent-api/src/main/kotlin/com/embabel/agent/api/`): Defines the core interface exposing `runAgent`, `runAgentByIntent`, and `runGoal` methods that implement the three modes.
- **[`AgentPlatformAutoConfiguration.java`](https://github.com/embabel/embabel-agent/blob/main/AgentPlatformAutoConfiguration.java)** (`embabel-agent-autoconfigure/embabel-agent-platform-autoconfigure/src/main/java/com/embabel/agent/autoconfigure/platform/`): Provides Spring auto-configuration that wires the `AgentPlatform` implementation into the application context.
- **[`McpExecutionMode.kt`](https://github.com/embabel/embabel-agent/blob/main/McpExecutionMode.kt)** (`embabel-agent-mcp/embabel-agent-mcpserver/src/main/kotlin/com/embabel/agent/mcpserver/domain/Types.kt#L27`): Demonstrates how execution mode concepts extend to MCP server contexts through the `SYNC` and `ASYNC` enum variants.

## Summary

- **Focused mode** provides maximum determinism by requiring the caller to specify the exact agent class via `runAgent`, eliminating runtime discovery overhead.
- **Closed mode** balances flexibility and control by using `runAgentByIntent` to dynamically match intents to registered agents while keeping execution bounded to the selected agent.
- **Open mode** enables AI-driven planning through `runGoal`, allowing the platform to compose novel agents from available capabilities at the cost of reduced determinism and increased latency.
- All three modes are implemented in the core `AgentPlatform` interface and configured through Spring auto-configuration classes.

## Frequently Asked Questions

### What is the most deterministic execution mode in AgentPlatform?

**Focused mode** is the most deterministic because the caller explicitly provides the agent class, and the platform executes no intent classification or goal discovery logic. The same agent runs reliably on every invocation with no dynamic selection variability.

### When should I use Closed mode instead of Focused mode?

Use **Closed mode** when you need a single entry point to serve multiple predefined agents based on runtime intent, such as handling different event types through a unified API. While **Focused mode** requires the caller to know the specific agent class beforehand, **Closed mode** allows the platform to route requests dynamically using `runAgentByIntent`.

### How does Open mode differ from simply calling multiple agents in sequence?

**Open mode** uses `runGoal` to dynamically analyze the high-level objective and construct a novel execution plan by discovering and composing capabilities from across the entire codebase. Unlike sequential agent calls where the programmer defines the workflow, **Open mode** allows the platform to invent new agent compositions and alternative execution paths that may not have been explicitly programmed.

### Are there performance differences between the three execution modes?

Yes. **Focused mode** offers the fastest execution because it bypasses all discovery and planning logic. **Closed mode** adds minimal overhead for intent-to-agent lookup. **Open mode** incurs the highest latency due to goal decomposition, capability search, and dynamic agent construction, though this cost buys maximum flexibility for complex, open-ended tasks.