Class: Insika::Tools::UpdateBriefing
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Insika::Tools::UpdateBriefing
- Includes:
- BriefingWrite
- Defined in:
- lib/insika/tools/update_briefing.rb
Overview
Write edge of the session briefing: the agent records what it
learned in THIS conversation — the working state it is accountable for
(tool-written, never engine-inferred). System builtin (like remember):
require "ruby_llm" stays in THIS file, loaded lazily by the Executor in
create_chat. Wired only when the pack declared briefing_fields AND the
builder has a session_store (double gate, like remember). Never enveloped:
deterministic in-process writes.
Defined Under Namespace
Classes: SetNextStep
Constant Summary collapse
- BASE_DESCRIPTION =
The class-level text carries no field list, so it can never render the empty "field must be one of: ." placeholder; the instance adds the DECLARED names (D3) to the description AND as the
fieldenum (the model sees the valid set in the schema instead of inventing one — the set is instance-built. Per-instance, like the subagent tools' dynamic schemas. "Records a fact learned in this conversation into the session briefing. " \ "Call it as soon as the customer gives one of these, and when they correct one."
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#execute(field:, value:) ⇒ Object
E2: an undeclared name returns an ENVELOPE error to the model and never persists.
-
#initialize(session_store:, fields:, event_stream:, state:) ⇒ UpdateBriefing
constructor
A new instance of UpdateBriefing.
- #name ⇒ Object
-
#params_schema ⇒ Object
The declared names become the
fieldenum in the schema the provider sees — per-turn data, like the subagent allowlist (Tools::AgentEnum).
Constructor Details
#initialize(session_store:, fields:, event_stream:, state:) ⇒ UpdateBriefing
Returns a new instance of UpdateBriefing.
61 62 63 64 65 66 67 |
# File 'lib/insika/tools/update_briefing.rb', line 61 def initialize(session_store:, fields:, event_stream:, state:) @session_store = session_store @fields = Array(fields).map(&:to_s) @event_stream = event_stream @state = state super() end |
Class Method Details
.description_for(fields) ⇒ Object
51 52 53 54 |
# File 'lib/insika/tools/update_briefing.rb', line 51 def self.description_for(fields) names = Array(fields).map(&:to_s) names.empty? ? BASE_DESCRIPTION : "#{BASE_DESCRIPTION} field must be one of: #{names.join(', ')}." end |
Instance Method Details
#description ⇒ Object
69 70 71 |
# File 'lib/insika/tools/update_briefing.rb', line 69 def description self.class.description_for(@fields) end |
#execute(field:, value:) ⇒ Object
E2: an undeclared name returns an ENVELOPE error to the model and never persists. A missing session is the same shape (the model can retry later).
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/insika/tools/update_briefing.rb', line 81 def execute(field:, value:) sid = session_id return no_session_error if sid.to_s.empty? unless @fields.include?(field.to_s) return { error: "unknown field '#{field}'; declared: #{@fields.join(', ')}" } end session = @session_store.update_briefing(sid, field: field.to_s, value: value.to_s) emit("field", field.to_s, value.to_s) { updated: field.to_s, briefing: session.briefing } rescue Insika::NotFoundError { error: "session not found" } end |
#name ⇒ Object
59 |
# File 'lib/insika/tools/update_briefing.rb', line 59 def name = "update_briefing" |
#params_schema ⇒ Object
The declared names become the field enum in the schema the provider
sees — per-turn data, like the subagent allowlist (Tools::AgentEnum).
75 76 77 |
# File 'lib/insika/tools/update_briefing.rb', line 75 def params_schema @field_enum_schema ||= Insika::Tools::AgentEnum.inject(super, @fields, path: %i[field]) end |