Class: Prescient::Agent::PromptBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/prescient/agent/prompt_builder.rb

Overview

Builds deterministic instructions for the single-action agent protocol.

Class Method Summary collapse

Class Method Details

.build(system_instruction:, tools:) ⇒ String

Build the system instruction for one agent run.

Parameters:

  • system_instruction (String)

    Application-specific instruction

  • tools (Array<ToolRegistry::Tool>)

    Allowed tools

Returns:

  • (String)

    Deterministic orchestration prompt



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/prescient/agent/prompt_builder.rb', line 11

def self.build(system_instruction:, tools:)
  tool_text = tools.empty? ? "None" : tools.map { |tool| tool_instruction(tool) }.join("\n")
  <<~PROMPT
    #{system_instruction}

    You may either answer the task directly or request exactly one tool.
    For a tool request, return one JSON object in a fenced json block:
    {"action":"tool_name","args":{"key":"value"}}
    Available tools:
    #{tool_text}
    Never request an unavailable tool. Do not return more than one action.
  PROMPT
end