agent

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package agent implements the agent loop and MCP client for Orla Agent Mode (RFC 4).

Package agent implements the agent loop and MCP client for Orla Agent Mode (RFC 4).

Package agent implements the agent loop and MCP client for Orla Agent Mode (RFC 4).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteAgentPrompt

func ExecuteAgentPrompt(prompt string, modelOverride string, daemonURL string, profileName string, workflowName string) error

ExecuteAgentPrompt is the main entry point for agent execution It handles the full flow: config loading, executor creation, context/signal handling, and execution prompt: the agent prompt as a single string (should be quoted when called from CLI) modelOverride: optional model override (for backward compatibility) daemonURL: optional daemon URL to connect to (RFC 5) profileName: optional agent profile name from config (RFC 5) workflowName: optional workflow name to execute (RFC 5)

Types

type Client

type Client struct {
	McpSession *mcp.ClientSession
	McpClient  *mcp.Client
	Cmd        *exec.Cmd
}

Client wraps an MCP client session for communicating with the internal Orla server

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new MCP client that connects to the internal Orla server via stdio The server is started as a subprocess running "orla serve --stdio" If orlaBin is empty, it will use the current executable

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)

CallTool calls a tool via the MCP server

func (*Client) Close

func (c *Client) Close() error

Close closes the MCP client session and cleans up the subprocess

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context) ([]*mcp.Tool, error)

ListTools lists all available tools from the MCP server

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor handles agent execution with proper setup and teardown

func NewExecutor

func NewExecutor(cfg *config.OrlaConfig) (*Executor, error)

NewExecutor creates a new agent executor

type Loop

type Loop struct {
	// contains filtered or unexported fields
}

Loop orchestrates the agent execution flow

func NewLoop

func NewLoop(client MCPClient, provider model.Provider, cfg *config.OrlaConfig) *Loop

NewLoop creates a new agent loop

func (*Loop) Execute

func (l *Loop) Execute(ctx context.Context, prompt string, messages []model.Message, stream bool, streamHandler StreamHandler) (*model.Response, error)

Execute runs a single agent execution cycle It implements the agent loop from RFC 4 Section 4.4: 1. Receive user prompt 2. Send prompt and available tools to the model 3. Receive model response (may include tool calls) 4. Execute tool calls via MCP 5. Return tool results to the model 6. Receive final response from the model 7. Stream response to user (if streaming and handler provided)

If streamHandler is provided and streaming is enabled, it will be called for each chunk. The stream will be consumed before checking for tool calls, ensuring the response is complete.

type MCPClient

type MCPClient interface {
	ListTools(ctx context.Context) ([]*mcp.Tool, error)
	CallTool(ctx context.Context, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
}

MCPClient is an interface for MCP client operations used by the agent loop

type StreamHandler

type StreamHandler func(event model.StreamEvent) error

StreamHandler is a function that handles streaming events

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL