Class: Cadenya::Resources::Objectives::ToolCalls

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/objectives/tool_calls.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ToolCalls

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 ToolCalls.

Parameters:



133
134
135
# File 'lib/cadenya/resources/objectives/tool_calls.rb', line 133

def initialize(client:)
  @client = client
end

Instance Method Details

#approve(tool_call_id, workspace_id:, objective_id:, request_options: {}) ⇒ Cadenya::Models::Objectives::ObjectiveToolCall

When an agent attempts to use a tool that requires approval, use this endpoint to mark it as approved.

Parameters:

  • tool_call_id (String)

    The ID of the tool call to approve

  • workspace_id (String)
  • objective_id (String)

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

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

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cadenya/resources/objectives/tool_calls.rb', line 61

def approve(tool_call_id, params)
  parsed, options = Cadenya::Objectives::ToolCallApproveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  objective_id =
    parsed.delete(:objective_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: [
      "v1/workspaces/%1$s/objectives/%2$s/tool_calls/%3$s/approve",
      workspace_id,
      objective_id,
      tool_call_id
    ],
    model: Cadenya::Objectives::ObjectiveToolCall,
    options: options
  )
end

#deny(tool_call_id, workspace_id:, objective_id:, memo: nil, request_options: {}) ⇒ Cadenya::Models::Objectives::ObjectiveToolCall

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

When an agent attempts to use a tool that requires approval, use this endpoint to mark it as denied. Use a memo to steer the LLM to a different decision or usage of the tool.

Parameters:

  • tool_call_id (String)

    Path param: The ID of the tool call to deny

  • workspace_id (String)

    Path param

  • objective_id (String)

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

  • memo (String)

    Body param: A memo to associate to the tool call denial. Use a memo to steer the

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

Returns:

See Also:



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cadenya/resources/objectives/tool_calls.rb', line 106

def deny(tool_call_id, params)
  parsed, options = Cadenya::Objectives::ToolCallDenyParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  objective_id =
    parsed.delete(:objective_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: [
      "v1/workspaces/%1$s/objectives/%2$s/tool_calls/%3$s/deny",
      workspace_id,
      objective_id,
      tool_call_id
    ],
    body: parsed,
    model: Cadenya::Objectives::ObjectiveToolCall,
    options: options
  )
end

#list(objective_id, workspace_id:, cursor: nil, include_info: nil, limit: nil, status: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Objectives::ObjectiveToolCall>

Lists all tool calls for an objective

Parameters:

  • objective_id (String)

    Path param: The objective ID to return tool calls 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

  • limit (Integer)

    Query param: Maximum number of results to return

  • status (Symbol, Cadenya::Models::Objectives::ToolCallListParams::Status)

    Query param: Filter by tool call status

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cadenya/resources/objectives/tool_calls.rb', line 28

def list(objective_id, params)
  parsed, options = Cadenya::Objectives::ToolCallListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/objectives/%2$s/tool_calls", workspace_id, objective_id],
    query: query.transform_keys(include_info: "includeInfo"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Objectives::ObjectiveToolCall,
    options: options
  )
end