Class: Pikuri::Mcp::Thinker
- Inherits:
-
Object
- Object
- Pikuri::Mcp::Thinker
- Defined in:
- lib/pikuri/mcp/thinker.rb
Overview
One-shot LLM pass for the MCP boot-time checks (Synthesizer, Verifier): #call takes a self-contained prompt and returns the model's reply as a String. Each call builds a fresh tools-free Agent, runs the prompt as its single turn, and closes it — fresh per call so per-server prompts don't accumulate in one chat and cross-contaminate (construction cost is noise next to the round-trip, and Cache short-circuits before #call fires anyway). No listeners, no step limit.
cancellable is checked once before each call (the gentle-cancel
semantic: a flag flipped between calls raises promptly; the in-flight HTTP
is not interrupted). Deliberately NOT passed into the one-shot agent —
Agent#run_loop resets its cancellable at the turn boundary, which would
erase a pending Ctrl+C. Provider errors propagate verbatim; how each
consumer then handles them is the cancel/degrade policy in
pikuri-mcp/DESIGN.md.
Constant Summary collapse
- SYSTEM_PROMPT =
System prompt for the one-shot agents. The real instructions (synthesis framing, verification rubric) live in the prompt Synthesizer / Verifier build and send as the user turn, so this stays generic.
'You are a one-shot analysis pass inside an agent boot sequence. ' \ 'Follow the instructions in the user message exactly and reply ' \ 'with only what they ask for — no preamble.'
Instance Method Summary collapse
-
#call(prompt) ⇒ String
Run one prompt through a fresh tools-free agent.
-
#initialize(transport:, cancellable: nil) ⇒ Thinker
constructor
A new instance of Thinker.
Constructor Details
#initialize(transport:, cancellable: nil) ⇒ Thinker
Returns a new instance of Thinker.
38 39 40 41 42 43 |
# File 'lib/pikuri/mcp/thinker.rb', line 38 def initialize(transport:, cancellable: nil) raise ArgumentError, 'transport must not be nil' if transport.nil? @transport = transport @cancellable = cancellable end |
Instance Method Details
#call(prompt) ⇒ String
Run one prompt through a fresh tools-free agent.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pikuri/mcp/thinker.rb', line 54 def call(prompt) @cancellable&.check! agent = Pikuri::Agent.new(transport: @transport, system_prompt: SYSTEM_PROMPT) begin agent.run_loop(user_message: prompt) agent.last_assistant_content.to_s ensure agent.close end end |