Class: Roast::Cogs::Agent

Inherits:
Roast::Cog show all
Defined in:
lib/roast/cogs/agent.rb,
lib/roast/cogs/agent/input.rb,
lib/roast/cogs/agent/stats.rb,
lib/roast/cogs/agent/usage.rb,
lib/roast/cogs/agent/config.rb,
lib/roast/cogs/agent/output.rb,
lib/roast/cogs/agent/provider.rb,
lib/roast/cogs/agent/providers/pi.rb,
lib/roast/cogs/agent/providers/claude.rb,
lib/roast/cogs/agent/providers/claude/message.rb,
lib/roast/cogs/agent/providers/claude/tool_use.rb,
lib/roast/cogs/agent/providers/pi/pi_invocation.rb,
lib/roast/cogs/agent/providers/claude/tool_result.rb,
lib/roast/cogs/agent/providers/claude/claude_invocation.rb,
lib/roast/cogs/agent/providers/claude/messages/text_message.rb,
lib/roast/cogs/agent/providers/claude/messages/user_message.rb,
lib/roast/cogs/agent/providers/pi/messages/tool_call_message.rb,
lib/roast/cogs/agent/providers/claude/messages/result_message.rb,
lib/roast/cogs/agent/providers/claude/messages/system_message.rb,
lib/roast/cogs/agent/providers/claude/messages/unknown_message.rb,
lib/roast/cogs/agent/providers/pi/messages/tool_result_message.rb,
lib/roast/cogs/agent/providers/claude/messages/thinking_message.rb,
lib/roast/cogs/agent/providers/claude/messages/tool_use_message.rb,
lib/roast/cogs/agent/providers/claude/messages/assistant_message.rb,
lib/roast/cogs/agent/providers/claude/messages/tool_result_message.rb

Overview

Agent cog for running coding agents on the local machine

The agent cog runs a coding agent on the local machine with access to local files, tools, and MCP servers. It is designed for coding tasks and any work requiring local filesystem access.

Key capabilities:

  • Access to local filesystem (read and write files)

  • Can run local tools and commands

  • Access to locally-configured MCP servers

  • Maintain session state across multiple invocations

  • Resume previous conversations using session identifiers

  • Track detailed execution statistics including token usage and cost

For pure LLM interaction without local system access, use the ‘chat` cog instead.

Defined Under Namespace

Modules: Providers Classes: AgentCogError, Config, Input, MissingPromptError, MissingProviderError, Output, Provider, Stats, UnknownProviderError, Usage

Instance Attribute Summary collapse

Attributes inherited from Roast::Cog

#name, #output

Instance Method Summary collapse

Methods inherited from Roast::Cog

#anonymous?, config_class, #failed?, generate_fallback_name, #initialize, input_class, #run!, #skipped?, #started?, #stopped?, #succeeded?, #type, #wait

Constructor Details

This class inherits a constructor from Roast::Cog

Instance Attribute Details

#configObject (readonly)

The configuration object for this agent cog instance

: Agent::Config



37
38
39
# File 'lib/roast/cogs/agent.rb', line 37

def config
  @config
end

Instance Method Details

#execute(input) ⇒ Object

Execute the agent with the given input and return the output

Invokes the configured agent provider with the input prompt and any session context. Optionally displays the user prompt, agent response, and execution statistics to the console based on the cog’s configuration.

The agent may make multiple turns (back-and-forth exchanges) during execution, especially when using tools. Each turn is counted in the execution statistics.

: (Input) -> Output



49
50
51
52
53
54
55
# File 'lib/roast/cogs/agent.rb', line 49

def execute(input)
  output = provider.invoke(input)
  if config.show_stats?
    Event << { block: { header: "AGENT STATS", content: "#{output.stats}\nSession ID: #{output.session}" } }
  end
  output
end