Class: Cadenya::Resources::Objectives

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/objectives.rb,
lib/cadenya/resources/objectives/tasks.rb,
lib/cadenya/resources/objectives/tools.rb,
lib/cadenya/resources/objectives/feedback.rb,
lib/cadenya/resources/objectives/tool_calls.rb,
sig/cadenya/resources/objectives.rbs,
sig/cadenya/resources/objectives/tasks.rbs,
sig/cadenya/resources/objectives/tools.rbs,
sig/cadenya/resources/objectives/feedback.rbs,
sig/cadenya/resources/objectives/tool_calls.rbs

Defined Under Namespace

Classes: Feedback, Tasks, ToolCalls, Tools

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Objectives

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Objectives.

Parameters:



423
424
425
426
427
428
429
# File 'lib/cadenya/resources/objectives.rb', line 423

def initialize(client:)
  @client = client
  @tools = Cadenya::Resources::Objectives::Tools.new(client: client)
  @tool_calls = Cadenya::Resources::Objectives::ToolCalls.new(client: client)
  @tasks = Cadenya::Resources::Objectives::Tasks.new(client: client)
  @feedback = Cadenya::Resources::Objectives::Feedback.new(client: client)
end

Instance Attribute Details

#feedbackCadenya::Resources::Objectives::Feedback (readonly)



16
17
18
# File 'lib/cadenya/resources/objectives.rb', line 16

def feedback
  @feedback
end

#tasksCadenya::Resources::Objectives::Tasks (readonly)



13
14
15
# File 'lib/cadenya/resources/objectives.rb', line 13

def tasks
  @tasks
end

#tool_callsCadenya::Resources::Objectives::ToolCalls (readonly)



10
11
12
# File 'lib/cadenya/resources/objectives.rb', line 10

def tool_calls
  @tool_calls
end

#toolsCadenya::Resources::Objectives::Tools (readonly)



7
8
9
# File 'lib/cadenya/resources/objectives.rb', line 7

def tools
  @tools
end

Instance Method Details

#cancel(objective_id, workspace_id: nil, reason: nil, request_options: {}) ⇒ Cadenya::Models::Objective

Some parameter documentations has been truncated, see Models::ObjectiveCancelParams for more details.

Cancels a running or pending objective. The objective's state will be set to STATE_CANCELLED.

Parameters:

  • objective_id (String)

    Path param: The ID of the objective. Supports "external_id:" prefix for external

  • workspace_id (String)

    Path param

  • reason (String)

    Body param: Optional reason for cancellation

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/cadenya/resources/objectives.rb', line 185

def cancel(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveCancelParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/objectives/%2$s:cancel", workspace_id, objective_id],
    body: parsed,
    model: Cadenya::Objective,
    options: options
  )
end

#compact(objective_id, workspace_id: nil, compaction_config: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveCompactResponse

Some parameter documentations has been truncated, see Models::ObjectiveCompactParams for more details.

Triggers compaction on a running objective. Optionally override the variation's compaction config.

Parameters:

Returns:

See Also:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/cadenya/resources/objectives.rb', line 219

def compact(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveCompactParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/objectives/%2$s:compact", workspace_id, objective_id],
    body: parsed,
    model: Cadenya::Models::ObjectiveCompactResponse,
    options: options
  )
end

#continue(objective_id, message:, workspace_id: nil, enqueue: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveEvent

Some parameter documentations has been truncated, see Models::ObjectiveContinueParams for more details.

Continues an objective that has completed

Parameters:

  • objective_id (String)

    Path param: The ID of the objective. If you have assigned an external ID to the

  • message (String)

    Body param: The message to continue an objective that has completed (or you are

  • workspace_id (String)

    Path param

  • enqueue (Boolean)

    Body param: When set to true, the message will be enqueued for when the agent lo

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/cadenya/resources/objectives.rb', line 254

def continue(objective_id, params)
  parsed, options = Cadenya::ObjectiveContinueParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/objectives/%2$s:continue", workspace_id, objective_id],
    body: parsed,
    model: Cadenya::ObjectiveEvent,
    options: options
  )
end

#create(agent_id:, system_prompt_data:, workspace_id: nil, episodic_memory: nil, first_user_message: nil, first_user_message_data: nil, memory_cascade: nil, metadata: nil, pinned_parameters: nil, secrets: nil, subject: nil, tenant: nil, variation_id: nil, request_options: {}) ⇒ Cadenya::Models::Objective

Some parameter documentations has been truncated, see Models::ObjectiveCreateParams for more details.

Creates a new objective in the workspace

Parameters:

  • agent_id (String)

    Body param

  • system_prompt_data (Hash{Symbol=>Object})

    Body param: Arbitrary data rendered into the selected variation's systemprompt

  • workspace_id (String)

    Path param

  • episodic_memory (Cadenya::Models::ObjectiveCreateParams::EpisodicMemory)

    Body param: Episodic is used to configure the episodic memory for the objective

  • first_user_message (String)

    Body param: Optional explicit first user message for the LLM chat history. When

  • first_user_message_data (Hash{Symbol=>Object})

    Body param: Arbitrary data rendered into the selected variation's first_user_mes

  • memory_cascade (Array<Cadenya::Models::MemoryReference>)

    Body param: Memory layers/entries layered over the baseline cascade inherited

  • metadata (Cadenya::Models::CreateOperationMetadata)

    Body param: CreateOperationMetadata contains the user-provided fields for creati

  • pinned_parameters (Hash{Symbol=>String})

    Body param: Parameters forced onto this objective's tool calls. A pinned paramet

  • secrets (Array<Cadenya::Models::ObjectiveCreateParams::Secret>)

    Body param: Secrets that can be used in the headers for tool calls using the sec

  • subject (Cadenya::Models::SubjectAssertion)

    Body param: SubjectAssertion identifies a person within a tenant in the customer

  • tenant (Cadenya::Models::TenantAssertion)

    Body param: TenantAssertion identifies a tenant in the customer's own namespace

  • variation_id (String)

    Body param: Optional explicit variation selection. Overrides the agent's variati

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cadenya/resources/objectives.rb', line 56

def create(params)
  parsed, options = Cadenya::ObjectiveCreateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/objectives", workspace_id],
    body: parsed,
    model: Cadenya::Objective,
    options: options
  )
end

#list(workspace_id: nil, agent_id: nil, agent_schedule_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, parent_objective_id: nil, profile_id: nil, sort_order: nil, state: nil, subject_id: nil, tenant_id: nil, widget_id: nil, widget_session_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Objective>

Some parameter documentations has been truncated, see Models::ObjectiveListParams for more details.

Lists all objectives in the workspace

Parameters:

  • workspace_id (String)

    Path param

  • agent_id (String)

    Query param: Agent ID for filtering

  • agent_schedule_id (String)

    Query param: Filter to objectives produced by a specific AgentSchedule. Accepts

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When set to true you may use more of your alloted API rate-limit

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return

  • parent_objective_id (String)

    Query param: Optional filters

  • profile_id (String)

    Query param

  • sort_order (String)

    Query param: Sort order for results (asc or desc by creation time)

  • state (Symbol, Cadenya::Models::ObjectiveListParams::State)

    Query param: Filter by state

  • subject_id (String)

    Query param: Filter to objectives associated with a subject. Accepts the canonic

  • tenant_id (String)

    Query param: Filter to objectives associated with a tenant. Accepts the canonica

  • widget_id (String)

    Query param: Filter to objectives whose conversation ran through a widget. Accep

  • widget_session_id (String)

    Query param: Filter to objectives created by a specific widget session.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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
# File 'lib/cadenya/resources/objectives.rb', line 138

def list(params = {})
  parsed, options = Cadenya::ObjectiveListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives", workspace_id],
    query: query.transform_keys(
      agent_id: "agentId",
      agent_schedule_id: "agentScheduleId",
      include_info: "includeInfo",
      parent_objective_id: "parentObjectiveId",
      profile_id: "profileId",
      sort_order: "sortOrder",
      subject_id: "subjectId",
      tenant_id: "tenantId",
      widget_id: "widgetId",
      widget_session_id: "widgetSessionId"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Objective,
    options: options
  )
end

#list_context_windows(objective_id, workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveContextWindow>

Some parameter documentations has been truncated, see Models::ObjectiveListContextWindowsParams for more details.

Read-only list of the last five windows of execution for this objective, ordered by most recent first

Parameters:

  • objective_id (String)

    Path param: The objective ID to return windows for

  • workspace_id (String)

    Path param

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When set to true you may use more of your alloted API rate-limit

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/cadenya/resources/objectives.rb', line 294

def list_context_windows(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveListContextWindowsParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s/context_windows", workspace_id, objective_id],
    query: query.transform_keys(include_info: "includeInfo"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::ObjectiveContextWindow,
    options: options
  )
end

#list_events(objective_id, workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, since_event_id: nil, sort_order: nil, window_id: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::ObjectiveEvent>

Some parameter documentations has been truncated, see Models::ObjectiveListEventsParams for more details.

Lists all events for an objective

Parameters:

  • objective_id (String)

    Path param: Objective ID for filtering

  • workspace_id (String)

    Path param

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When set to true you may use more of your alloted API rate-limit

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return

  • since_event_id (String)

    Query param: Optional string to fetch events since an ID

  • sort_order (String)

    Query param: Sort order for results (asc or desc by creation time)

  • window_id (String)

    Query param: Optional context window ID to filter events by

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/cadenya/resources/objectives.rb', line 341

def list_events(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveListEventsParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s/events", workspace_id, objective_id],
    query: query.transform_keys(
      include_info: "includeInfo",
      since_event_id: "sinceEventId",
      sort_order: "sortOrder",
      window_id: "windowId"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::ObjectiveEvent,
    options: options
  )
end

#retrieve(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::Objective

Retrieves an objective by ID from the workspace

Parameters:

Returns:

See Also:



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cadenya/resources/objectives.rb', line 82

def retrieve(id, params = {})
  parsed, options = Cadenya::ObjectiveRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s", workspace_id, id],
    model: Cadenya::Objective,
    options: options
  )
end

#retrieve_diagnostics(objective_id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::ObjectiveRetrieveDiagnosticsResponse

Returns the context-usage breakdown measured for the objective's most recent iteration: character lengths per context component (system prompt, memory appendices, tool definitions, messages by role) alongside the iteration's input token counts.

Parameters:

  • objective_id (String)

    The ID of the objective. Supports "external_id:" prefix for external IDs.

  • workspace_id (String)
  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/cadenya/resources/objectives.rb', line 379

def retrieve_diagnostics(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveRetrieveDiagnosticsParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s/diagnostics", workspace_id, objective_id],
    model: Cadenya::Models::ObjectiveRetrieveDiagnosticsResponse,
    options: options
  )
end

#stream_events_streaming(objective_id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Internal::Stream<Cadenya::Models::ObjectiveEvent>

Streams events for an objective in real-time using server-sent events (SSE)

Parameters:

Returns:

See Also:



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/cadenya/resources/objectives.rb', line 404

def stream_events_streaming(objective_id, params = {})
  parsed, options = Cadenya::ObjectiveStreamEventsParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s/events:stream", workspace_id, objective_id],
    headers: {"accept" => "text/event-stream", "accept-encoding" => "identity"},
    stream: Cadenya::Internal::Stream,
    model: Cadenya::ObjectiveEvent,
    options: options
  )
end