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,
  approval_timeout: 3_600, # cap on the wait for human approval (~1h)
  # Item 30: 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 (D3).
  tool_concurrency: 1
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#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

#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

#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

#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

#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, 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, params: {}, model_policy: nil, guardrails: nil, sandbox: nil, refinement: nil, capabilities_declared: nil, edge_stream: nil, metadata: {}) ⇒ Object

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



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/insika/agent_profile.rb', line 130

def self.build(id:, model: nil, provider: nil, base_prompt: "", prompt_files: [],
               tools_allow: nil, tools_deny: [], tools_allow_groups: nil, skills: 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,
               params: {}, model_policy: nil, guardrails: nil, sandbox: nil,
               refinement: nil, capabilities_declared: nil, edge_stream: nil, metadata: {})
  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,
    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,
    # 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( || {})
  )
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 achei-specific: store_id is a field of the turn-context contract (§5), generic per project.



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

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)


183
184
185
186
# File 'lib/insika/agent_profile.rb', line 183

def stream_public?(channel)
  v = (edge_stream || {})[channel.to_s]
  [true, "true", "1", "yes", "on"].include?(v)
end

#tool_opted_in?(name) ⇒ Boolean

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

Returns:

  • (Boolean)


169
170
171
# File 'lib/insika/agent_profile.rb', line 169

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