Class: Insika::AgentProfile

Inherits:
Data
  • Object
show all
Defined in:
lib/insika/agent_profile.rb,
lib/insika/agent_profile.rb

Overview

Reopened class (not a Data.define block): a constant assigned inside the block would leak into the lexical scope (Insika::DEFAULT_LIMITS).

Constant Summary collapse

DEFAULT_LIMITS =
{
  turn_timeout: 300, tool_timeout: 60, provider_timeout: 5,
  context_budget: 8_000, max_tool_calls: 50,
  # consecutive identical (tool, args) calls that trigger the ONE
  # loop warning; a repeat after it aborts like max_tool_calls. < 2 = off.
  max_tool_repeat: 3,
  approval_timeout: 3_600, # cap on the wait for human approval (~1h)
  # parallel tool calls. ONE number is both the switch and the cap
  # (nil/0/1 = serial, the default; N > 1 = at most N tool calls in flight).
  # It sits next to tool_timeout/max_tool_calls because it is the third bound
  # on tool execution. Read through TurnState#tool_concurrency, which also
  # applies the approval gate.
  tool_concurrency: 1
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alertsObject (readonly)

Returns the value of attribute alerts

Returns:

  • (Object)

    the current value of alerts



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def alerts
  @alerts
end

#approvals_requiredObject (readonly)

Returns the value of attribute approvals_required

Returns:

  • (Object)

    the current value of approvals_required



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def approvals_required
  @approvals_required
end

#base_promptObject (readonly)

Returns the value of attribute base_prompt

Returns:

  • (Object)

    the current value of base_prompt



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def base_prompt
  @base_prompt
end

#budgetObject (readonly)

Returns the value of attribute budget

Returns:

  • (Object)

    the current value of budget



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def budget
  @budget
end

#capabilitiesObject (readonly)

Returns the value of attribute capabilities

Returns:

  • (Object)

    the current value of capabilities



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def capabilities
  @capabilities
end

#capabilities_declaredObject (readonly)

Returns the value of attribute capabilities_declared

Returns:

  • (Object)

    the current value of capabilities_declared



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def capabilities_declared
  @capabilities_declared
end

#context_providersObject (readonly)

Returns the value of attribute context_providers

Returns:

  • (Object)

    the current value of context_providers



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def context_providers
  @context_providers
end

#edge_streamObject (readonly)

Returns the value of attribute edge_stream

Returns:

  • (Object)

    the current value of edge_stream



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def edge_stream
  @edge_stream
end

#guardrailsObject (readonly)

Returns the value of attribute guardrails

Returns:

  • (Object)

    the current value of guardrails



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def guardrails
  @guardrails
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def id
  @id
end

#limitsObject (readonly)

Returns the value of attribute limits

Returns:

  • (Object)

    the current value of limits



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def limits
  @limits
end

#memoryObject (readonly)

Returns the value of attribute memory

Returns:

  • (Object)

    the current value of memory



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def memory
  @memory
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def 
  @metadata
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def model
  @model
end

#model_policyObject (readonly)

Returns the value of attribute model_policy

Returns:

  • (Object)

    the current value of model_policy



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def model_policy
  @model_policy
end

#paramsObject (readonly)

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def params
  @params
end

#policiesObject (readonly)

Returns the value of attribute policies

Returns:

  • (Object)

    the current value of policies



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def policies
  @policies
end

#prompt_cachingObject (readonly)

Returns the value of attribute prompt_caching

Returns:

  • (Object)

    the current value of prompt_caching



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def prompt_caching
  @prompt_caching
end

#prompt_filesObject (readonly)

Returns the value of attribute prompt_files

Returns:

  • (Object)

    the current value of prompt_files



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def prompt_files
  @prompt_files
end

#prompt_refsObject (readonly)

Returns the value of attribute prompt_refs

Returns:

  • (Object)

    the current value of prompt_refs



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def prompt_refs
  @prompt_refs
end

#providerObject (readonly)

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def provider
  @provider
end

#refinementObject (readonly)

Returns the value of attribute refinement

Returns:

  • (Object)

    the current value of refinement



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def refinement
  @refinement
end

#reliabilityObject (readonly)

Returns the value of attribute reliability

Returns:

  • (Object)

    the current value of reliability



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def reliability
  @reliability
end

#sandboxObject (readonly)

Returns the value of attribute sandbox

Returns:

  • (Object)

    the current value of sandbox



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def sandbox
  @sandbox
end

#skillsObject (readonly)

Returns the value of attribute skills

Returns:

  • (Object)

    the current value of skills



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def skills
  @skills
end

#skills_eagerObject (readonly)

Returns the value of attribute skills_eager

Returns:

  • (Object)

    the current value of skills_eager



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def skills_eager
  @skills_eager
end

#stuck_signalObject (readonly)

Returns the value of attribute stuck_signal

Returns:

  • (Object)

    the current value of stuck_signal



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def stuck_signal
  @stuck_signal
end

#subagentsObject (readonly)

Returns the value of attribute subagents

Returns:

  • (Object)

    the current value of subagents



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def subagents
  @subagents
end

#tool_output_compressionObject (readonly)

Returns the value of attribute tool_output_compression

Returns:

  • (Object)

    the current value of tool_output_compression



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def tool_output_compression
  @tool_output_compression
end

#tools_allowObject (readonly)

Returns the value of attribute tools_allow

Returns:

  • (Object)

    the current value of tools_allow



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def tools_allow
  @tools_allow
end

#tools_allow_groupsObject (readonly)

Returns the value of attribute tools_allow_groups

Returns:

  • (Object)

    the current value of tools_allow_groups



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def tools_allow_groups
  @tools_allow_groups
end

#tools_deferredObject (readonly)

Returns the value of attribute tools_deferred

Returns:

  • (Object)

    the current value of tools_deferred



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def tools_deferred
  @tools_deferred
end

#tools_denyObject (readonly)

Returns the value of attribute tools_deny

Returns:

  • (Object)

    the current value of tools_deny



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def tools_deny
  @tools_deny
end

#workflows_allowObject (readonly)

Returns the value of attribute workflows_allow

Returns:

  • (Object)

    the current value of workflows_allow



15
16
17
# File 'lib/insika/agent_profile.rb', line 15

def workflows_allow
  @workflows_allow
end

Class Method Details

.build(id:, model: nil, provider: nil, base_prompt: "", prompt_files: [], tools_allow: nil, tools_deny: [], tools_allow_groups: nil, skills: nil, skills_eager: nil, context_providers: nil, workflows_allow: nil, policies: [], prompt_refs: [], limits: {}, approvals_required: nil, capabilities: nil, subagents: nil, tools_deferred: nil, memory: nil, prompt_caching: nil, tool_output_compression: nil, params: {}, model_policy: nil, guardrails: nil, sandbox: nil, refinement: nil, capabilities_declared: nil, edge_stream: nil, metadata: {}, budget: nil, reliability: nil, alerts: nil, stuck_signal: nil) ⇒ Object

model is OPTIONAL as of v2: an agent without one resolves the platform default_model (Settings) at turn start via the ModelResolver.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/insika/agent_profile.rb', line 191

def self.build(id:, model: nil, provider: nil, base_prompt: "", prompt_files: [],
               tools_allow: nil, tools_deny: [], tools_allow_groups: nil, skills: nil,
               skills_eager: nil, context_providers: nil, workflows_allow: nil,
               policies: [], prompt_refs: [], limits: {}, approvals_required: nil,
               capabilities: nil, subagents: nil, tools_deferred: nil, memory: nil,
               prompt_caching: nil, tool_output_compression: nil,
               params: {}, model_policy: nil, guardrails: nil, sandbox: nil,
               refinement: nil, capabilities_declared: nil, edge_stream: nil, metadata: {},
               budget: nil, reliability: nil, alerts: nil, stuck_signal: nil)
  new(
    id: id, model: model, provider: provider, base_prompt: base_prompt,
    prompt_files: Array(prompt_files), tools_allow: tools_allow,
    tools_deny: Array(tools_deny), tools_allow_groups: tools_allow_groups, skills: skills,
    skills_eager: skills_eager,
    context_providers: context_providers, workflows_allow: workflows_allow,
    policies: Array(policies), prompt_refs: Array(prompt_refs),
    limits: DEFAULT_LIMITS.merge(limits), approvals_required: approvals_required,
    capabilities: capabilities,
    # opt-in like capabilities: nil => NONE. Array-normalize a present value so
    # readers get a clean [] and the ChatBuilder gate (present? => wire) is stable.
    subagents: subagents.nil? ? nil : Array(subagents).map(&:to_s),
    tools_deferred: tools_deferred, memory: memory,
    prompt_caching: prompt_caching, tool_output_compression: tool_output_compression,
    # The free-form hashes arrive with symbol keys (internal build) OR string
    # keys (StoredProfileSource JSON round-trip). Normalize to string keys ONCE
    # here — the single front door every profile passes through — so no reader
    # downstream has to defend against both (store_id, model_policy, Studio forms).
    params: Coercion.deep_stringify(params || {}),
    model_policy: Coercion.deep_stringify(model_policy),
    guardrails: Coercion.deep_stringify(guardrails),
    sandbox: Coercion.deep_stringify(sandbox),
    refinement: Coercion.deep_stringify(refinement),
    # Flat [String] — the evals compare it against a case's `requires`, and a
    # symbol/string mix there would be a silent miss.
    capabilities_declared: Array(capabilities_declared).map(&:to_s),
    edge_stream: Coercion.deep_stringify(edge_stream || {}),
    metadata: Coercion.deep_stringify( || {}),
    budget: Coercion.deep_stringify(budget),
    reliability: Coercion.deep_stringify(reliability),
    alerts: Coercion.deep_stringify(alerts),
    stuck_signal: stuck_signal
  )
end

Instance Method Details

#store_idObject

store_id of the turn context (ctx.store_id): lives in metadata (stable per store, comes from the pack). build string-keys metadata, so a plain string lookup is enough. nil = absent (the data-tool emits an empty header). It is NOT consumer-specific: store_id is a field of the turn-context contract generic per project.



245
# File 'lib/insika/agent_profile.rb', line 245

def store_id = ( || {})["store_id"]

#stream_public?(channel) ⇒ Boolean

May this channel (:thinking / :intermediate) cross to the customer? Tolerant of the string values a form or a pack round-trip produces ("1"/"true"), and of anything else being absent: the safe reading is the default one.

Returns:

  • (Boolean)


250
251
252
253
# File 'lib/insika/agent_profile.rb', line 250

def stream_public?(channel)
  v = (edge_stream || {})[channel.to_s]
  Coercion.truthy?(v)
end

#tool_opted_in?(name) ⇒ Boolean

opt-in for an optional tool = being in the agent's allow list.

Returns:

  • (Boolean)


236
237
238
# File 'lib/insika/agent_profile.rb', line 236

def tool_opted_in?(name)
  Array(tools_allow).include?(name)
end