Module: RubynCode::Agent::ResponseModes
- Defined in:
- lib/rubyn_code/agent/response_modes.rb
Overview
Dynamically adjusts response verbosity based on the current task type. Injects mode-specific instructions into the system prompt to reduce unnecessary output tokens without losing useful information.
Constant Summary collapse
- MODES =
{ implementing: { label: 'implementing', instruction: 'Write the code. Brief comment on non-obvious decisions only. No preamble or recap.' }, explaining: { label: 'explaining', instruction: 'Explain clearly and concisely. Use examples from this codebase when possible.' }, reviewing: { label: 'reviewing', instruction: 'List findings with severity, file, line. No filler between findings.' }, exploring: { label: 'exploring', instruction: 'Summarize structure. Use tree format. Note patterns and anti-patterns briefly.' }, debugging: { label: 'debugging', instruction: 'State most likely cause first. Then evidence. Then fix. No preamble.' }, testing: { label: 'testing', instruction: 'Write specs directly. Minimal explanation. Only note non-obvious test setup.' }, chatting: { label: 'chatting', instruction: 'Respond naturally and concisely.' } }.freeze
- DEFAULT_MODE =
:chatting
Class Method Summary collapse
-
.detect(message, tool_calls: []) ⇒ Symbol
Detects the response mode from the user’s message content.
-
.instruction_for(mode) ⇒ String
Returns the instruction text for a given mode.
Class Method Details
.detect(message, tool_calls: []) ⇒ Symbol
Detects the response mode from the user’s message content.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rubyn_code/agent/response_modes.rb', line 48 def detect(, tool_calls: []) # rubocop:disable Metrics/CyclomaticComplexity -- mode detection dispatch return :implementing if implementation_signal?() return :debugging if debugging_signal?() return :reviewing if reviewing_signal?() return :testing if testing_signal?() return :exploring if exploring_signal?() return :explaining if explaining_signal?() recent_tool = tool_calls.last return detect_from_tool(recent_tool) if recent_tool DEFAULT_MODE end |
.instruction_for(mode) ⇒ String
Returns the instruction text for a given mode.
66 67 68 69 |
# File 'lib/rubyn_code/agent/response_modes.rb', line 66 def instruction_for(mode) config = MODES.fetch(mode, MODES[DEFAULT_MODE]) "\n## Response Mode: #{config[:label]}\n#{config[:instruction]}" end |