Class: TurnKit::Workflow
- Inherits:
-
Object
- Object
- TurnKit::Workflow
- Defined in:
- lib/turnkit/workflow.rb
Constant Summary collapse
- DEFAULT_INSTRUCTIONS =
<<~TEXT.strip You are an autonomous task orchestrator. Navigate from the application request to a final output without asking the user follow-up questions. Use the available tools to gather context, inspect sources, take actions, persist outputs, and verify work. Use loaded skills as reusable workflow patterns. Iterate when work needs missing context, critique, revision, or verification. Stop when the task is complete, when the available context and tools are sufficient for the best possible answer, or when further iteration would not materially improve the result. Respect runtime, cost, and iteration limits. TEXT
Instance Attribute Summary collapse
-
#available_skills ⇒ Object
readonly
Returns the value of attribute available_skills.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#compaction ⇒ Object
readonly
Returns the value of attribute compaction.
-
#cost_limit ⇒ Object
readonly
Returns the value of attribute cost_limit.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
-
#max_iterations ⇒ Object
readonly
Returns the value of attribute max_iterations.
-
#max_tool_executions ⇒ Object
readonly
Returns the value of attribute max_tool_executions.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_schema ⇒ Object
readonly
Returns the value of attribute output_schema.
-
#prompt_mode ⇒ Object
readonly
Returns the value of attribute prompt_mode.
-
#skills ⇒ Object
readonly
Returns the value of attribute skills.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#thinking ⇒ Object
readonly
Returns the value of attribute thinking.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
- #agent(**options) ⇒ Object
-
#initialize(name: "workflow", description: "", instructions: nil, tools: [], skills: [], available_skills: [], model: nil, client: nil, store: nil, prompt_mode: :task, thinking: nil, compaction: nil, output_schema: nil, max_iterations: nil, timeout: nil, max_spend: nil, cost_limit: nil, max_depth: nil, max_tool_executions: nil) ⇒ Workflow
constructor
A new instance of Workflow.
- #max_spend ⇒ Object
- #run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, max_spend: nil, cost_limit: nil, **options) ⇒ Object
Constructor Details
#initialize(name: "workflow", description: "", instructions: nil, tools: [], skills: [], available_skills: [], model: nil, client: nil, store: nil, prompt_mode: :task, thinking: nil, compaction: nil, output_schema: nil, max_iterations: nil, timeout: nil, max_spend: nil, cost_limit: nil, max_depth: nil, max_tool_executions: nil) ⇒ Workflow
Returns a new instance of Workflow.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/turnkit/workflow.rb', line 26 def initialize(name: "workflow", description: "", instructions: nil, tools: [], skills: [], available_skills: [], model: nil, client: nil, store: nil, prompt_mode: :task, thinking: nil, compaction: nil, output_schema: nil, max_iterations: nil, timeout: nil, max_spend: nil, cost_limit: nil, max_depth: nil, max_tool_executions: nil) @name = name.to_s @description = description.to_s @instructions = instructions || DEFAULT_INSTRUCTIONS @tools = Array(tools) @skills = Array(skills) @available_skills = Array(available_skills) @model = model @client = client @store = store @prompt_mode = prompt_mode @thinking = thinking @compaction = compaction @output_schema = output_schema @max_iterations = max_iterations @timeout = timeout @cost_limit = cost_limit || max_spend @max_depth = max_depth @max_tool_executions = max_tool_executions raise ArgumentError, "name is required" if @name.empty? build_agent end |
Instance Attribute Details
#available_skills ⇒ Object (readonly)
Returns the value of attribute available_skills.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def available_skills @available_skills end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def client @client end |
#compaction ⇒ Object (readonly)
Returns the value of attribute compaction.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def compaction @compaction end |
#cost_limit ⇒ Object (readonly)
Returns the value of attribute cost_limit.
9 10 11 |
# File 'lib/turnkit/workflow.rb', line 9 def cost_limit @cost_limit end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def description @description end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def instructions @instructions end |
#max_depth ⇒ Object (readonly)
Returns the value of attribute max_depth.
9 10 11 |
# File 'lib/turnkit/workflow.rb', line 9 def max_depth @max_depth end |
#max_iterations ⇒ Object (readonly)
Returns the value of attribute max_iterations.
9 10 11 |
# File 'lib/turnkit/workflow.rb', line 9 def max_iterations @max_iterations end |
#max_tool_executions ⇒ Object (readonly)
Returns the value of attribute max_tool_executions.
9 10 11 |
# File 'lib/turnkit/workflow.rb', line 9 def max_tool_executions @max_tool_executions end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def name @name end |
#output_schema ⇒ Object (readonly)
Returns the value of attribute output_schema.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def output_schema @output_schema end |
#prompt_mode ⇒ Object (readonly)
Returns the value of attribute prompt_mode.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def prompt_mode @prompt_mode end |
#skills ⇒ Object (readonly)
Returns the value of attribute skills.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def skills @skills end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def store @store end |
#thinking ⇒ Object (readonly)
Returns the value of attribute thinking.
8 9 10 |
# File 'lib/turnkit/workflow.rb', line 8 def thinking @thinking end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
9 10 11 |
# File 'lib/turnkit/workflow.rb', line 9 def timeout @timeout end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
7 8 9 |
# File 'lib/turnkit/workflow.rb', line 7 def tools @tools end |
Instance Method Details
#agent(**options) ⇒ Object
69 70 71 |
# File 'lib/turnkit/workflow.rb', line 69 def agent(**) build_agent(**) end |
#max_spend ⇒ Object
73 74 75 |
# File 'lib/turnkit/workflow.rb', line 73 def max_spend cost_limit end |
#run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, max_spend: nil, cost_limit: nil, **options) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/turnkit/workflow.rb', line 54 def run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, max_spend: nil, cost_limit: nil, **) task = task || prompt raise ArgumentError, "task is required" if task.to_s.empty? build_agent(cost_limit: cost_limit || max_spend, **).run( task, input: input, async: async, subject: subject, metadata: ) end |