Class: TurnKit::Workflow
- Inherits:
-
Object
- Object
- TurnKit::Workflow
- Defined in:
- lib/turnkit/workflow.rb
Constant Summary collapse
- ORCHESTRATOR_PREAMBLE =
<<~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. When multiple independent items need the same kind of fetch or read, and an available batch tool can handle them in one call, prefer the batch tool over repeated one-item tool calls. 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
- DEFAULT_INSTRUCTIONS =
ORCHESTRATOR_PREAMBLE
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #agent(**overrides) ⇒ Object
-
#initialize(name: "workflow", instructions: nil, preamble: true, **options) ⇒ Workflow
constructor
A new instance of Workflow.
- #run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, **overrides) ⇒ Object
Constructor Details
#initialize(name: "workflow", instructions: nil, preamble: true, **options) ⇒ Workflow
Returns a new instance of Workflow.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/turnkit/workflow.rb', line 30 def initialize(name: "workflow", instructions: nil, preamble: true, **) @name = name.to_s raise ArgumentError, "name is required" if @name.empty? @options = .merge( name: @name, prompt_mode: .fetch(:prompt_mode, :task), instructions: compose_instructions(instructions, preamble: preamble) ).freeze @agent = Agent.new(**@options) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/turnkit/workflow.rb', line 28 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
28 29 30 |
# File 'lib/turnkit/workflow.rb', line 28 def @options end |
Instance Method Details
#agent(**overrides) ⇒ Object
46 47 48 |
# File 'lib/turnkit/workflow.rb', line 46 def agent(**overrides) overrides.empty? ? @agent : Agent.new(**@options.merge(overrides.compact)) end |
#run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, **overrides) ⇒ Object
42 43 44 |
# File 'lib/turnkit/workflow.rb', line 42 def run(prompt = nil, task: nil, input: nil, async: false, subject: nil, metadata: {}, **overrides) agent(**overrides).run(task || prompt, input: input, async: async, subject: subject, metadata: ) end |