scout-ai 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +133 -58
  3. data/README.md +2 -1
  4. data/VERSION +1 -1
  5. data/doc/Improvements.md +490 -148
  6. data/doc/Model.md +53 -10
  7. data/doc/StartHere.md +44 -19
  8. data/doc/developer/Architecture.md +25 -6
  9. data/doc/developer/Backends.md +207 -48
  10. data/doc/developer/ChatLifecycle.md +121 -20
  11. data/doc/developer/DelegationInternals.md +319 -33
  12. data/doc/developer/DesignPrinciples.md +205 -16
  13. data/doc/developer/PathEngine.md +628 -0
  14. data/doc/developer/PromptProcessing.md +332 -82
  15. data/doc/developer/Provenance.md +388 -40
  16. data/doc/developer/Sandbox.md +213 -0
  17. data/doc/user/BuildingAgents.md +130 -18
  18. data/doc/user/Cookbook.md +29 -8
  19. data/doc/user/CoreConcepts.md +7 -6
  20. data/doc/user/Delegation.md +166 -15
  21. data/doc/user/GettingStarted.md +20 -16
  22. data/doc/user/ManagingContext.md +155 -17
  23. data/doc/user/MultiAgentWorkflows.md +105 -15
  24. data/doc/user/Python.md +11 -1
  25. data/doc/user/RunningInference.md +90 -47
  26. data/doc/user/ToolCalling.md +134 -29
  27. data/doc/user/WritingChats.md +56 -27
  28. data/lib/scout/llm/agent/attach.rb +13 -17
  29. data/lib/scout/llm/agent/chat.rb +32 -0
  30. data/lib/scout/llm/agent/construction.rb +64 -0
  31. data/lib/scout/llm/agent/conversation.rb +304 -0
  32. data/lib/scout/llm/agent/delegate.rb +56 -238
  33. data/lib/scout/llm/agent/path/edit.rb +230 -0
  34. data/lib/scout/llm/agent/path/patch.rb +252 -0
  35. data/lib/scout/llm/agent/path/workflow_kinds.rb +175 -0
  36. data/lib/scout/llm/agent/path.rb +1777 -0
  37. data/lib/scout/llm/agent/save.rb +11 -9
  38. data/lib/scout/llm/agent/workflow.rb +77 -16
  39. data/lib/scout/llm/agent.rb +147 -31
  40. data/lib/scout/llm/ask.rb +28 -17
  41. data/lib/scout/llm/backends/anthropic.rb +1 -1
  42. data/lib/scout/llm/backends/bedrock.rb +3 -2
  43. data/lib/scout/llm/backends/default.rb +127 -34
  44. data/lib/scout/llm/backends/glm.rb +28 -1
  45. data/lib/scout/llm/backends/huggingface.rb +1 -1
  46. data/lib/scout/llm/backends/ollama.rb +1 -1
  47. data/lib/scout/llm/backends/openai.rb +7 -6
  48. data/lib/scout/llm/backends/openwebui.rb +14 -7
  49. data/lib/scout/llm/backends/relay.rb +8 -2
  50. data/lib/scout/llm/chat/agent_meta.rb +24 -60
  51. data/lib/scout/llm/chat/parse.rb +1 -1
  52. data/lib/scout/llm/chat/process/files.rb +10 -0
  53. data/lib/scout/llm/chat/process/meta.rb +5 -7
  54. data/lib/scout/llm/chat/process/tools.rb +104 -49
  55. data/lib/scout/llm/chat/prompt/epoch_tool_compactation.rb +355 -0
  56. data/lib/scout/llm/chat/prompt/inbox.rb +188 -0
  57. data/lib/scout/llm/chat/prompt/shorten_tools.rb +797 -13
  58. data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +1 -365
  59. data/lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb +1 -0
  60. data/lib/scout/llm/chat/prompt.rb +24 -10
  61. data/lib/scout/llm/chat/provenance/live.rb +1080 -0
  62. data/lib/scout/llm/chat/provenance/tokens.rb +386 -0
  63. data/lib/scout/llm/chat/provenance.rb +343 -676
  64. data/lib/scout/llm/chat.rb +8 -2
  65. data/lib/scout/llm/embed.rb +15 -3
  66. data/lib/scout/llm/image.rb +4 -1
  67. data/lib/scout/llm/mcp.rb +4 -2
  68. data/lib/scout/llm/request_context.rb +234 -0
  69. data/lib/scout/llm/sandbox.rb +263 -0
  70. data/lib/scout/llm/tools/call.rb +163 -42
  71. data/lib/scout/llm/tools/definition.rb +48 -0
  72. data/lib/scout/llm/tools/knowledge_base.rb +1 -0
  73. data/lib/scout/llm/tools/mcp.rb +50 -43
  74. data/lib/scout/llm/tools/workflow.rb +90 -20
  75. data/lib/scout/llm/tools.rb +14 -41
  76. data/lib/scout/model/decision/base.rb +43 -0
  77. data/lib/scout/model/decision/jev.rb +161 -0
  78. data/lib/scout/model/python/torch.rb +1 -1
  79. data/research/clear-tools-inherit.md +171 -0
  80. data/research/path-engine-dc1-dc2-dc3-fixes.md +279 -0
  81. data/research/path-kind-chat-role.md +96 -0
  82. data/research/path-kind-contract-fixes-engine.md +307 -0
  83. data/research/scout-ai-runtime-availability.md +65 -0
  84. data/research/subsys/README.md +127 -0
  85. data/research/subsys/agent-delegation.md +201 -0
  86. data/research/subsys/agent-society.md +275 -0
  87. data/research/subsys/agentworkflow.md +233 -0
  88. data/research/subsys/backends.md +221 -0
  89. data/research/subsys/chat.md +314 -0
  90. data/research/subsys/embed-image.md +244 -0
  91. data/research/subsys/entry-cli.md +253 -0
  92. data/research/subsys/model-ml.md +326 -0
  93. data/research/subsys/provenance.md +290 -0
  94. data/research/subsys/tools.md +334 -0
  95. data/scout-ai.gemspec +71 -27
  96. data/scout_commands/agent/ask +8 -7
  97. data/scout_commands/llm/abridged +40 -0
  98. data/scout_commands/llm/ask +9 -9
  99. data/scout_commands/llm/md +2 -0
  100. data/scout_commands/llm/prov +724 -59
  101. data/scout_commands/llm/word +4 -0
  102. data/share/word/reference.docx +0 -0
  103. data/test/integration/scout/model/decision/test_jev.rb +144 -0
  104. data/test/scout/llm/agent/test_attach.rb +117 -0
  105. data/test/scout/llm/agent/test_conversation.rb +407 -0
  106. data/test/scout/llm/agent/test_delegate.rb +209 -0
  107. data/test/scout/llm/agent/test_path.rb +1812 -0
  108. data/test/scout/llm/agent/test_path_edit.rb +908 -0
  109. data/test/scout/llm/agent/test_path_errors.rb +390 -0
  110. data/test/scout/llm/agent/test_path_filesystem.rb +532 -0
  111. data/test/scout/llm/agent/test_path_patch.rb +233 -0
  112. data/test/scout/llm/agent/test_path_promotion.rb +386 -0
  113. data/test/scout/llm/agent/test_path_workflow_integration.rb +665 -0
  114. data/test/scout/llm/agent/test_save.rb +70 -15
  115. data/test/scout/llm/agent/test_workflow.rb +130 -4
  116. data/test/scout/llm/backends/test_anthropic.rb +4 -4
  117. data/test/scout/llm/backends/test_bedrock.rb +4 -4
  118. data/test/scout/llm/backends/test_format_other.rb +43 -0
  119. data/test/scout/llm/backends/test_ollama.rb +2 -2
  120. data/test/scout/llm/backends/test_openwebui.rb +12 -8
  121. data/test/scout/llm/backends/test_reasoning.rb +114 -0
  122. data/test/scout/llm/chat/agent_meta_fixtures.rb +28 -27
  123. data/test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb +612 -0
  124. data/test/scout/llm/chat/prov_plot_fixtures.rb +131 -0
  125. data/test/scout/llm/chat/test_agent_meta.rb +40 -80
  126. data/test/scout/llm/chat/test_agent_meta_provenance.rb +67 -28
  127. data/test/scout/llm/chat/test_agent_meta_tokens.rb +59 -8
  128. data/test/scout/llm/chat/test_agent_view.rb +178 -0
  129. data/test/scout/llm/chat/test_live_report.rb +282 -0
  130. data/test/scout/llm/chat/test_live_workload.rb +193 -0
  131. data/test/scout/llm/chat/test_parse.rb +32 -2
  132. data/test/scout/llm/chat/test_prompt.rb +411 -0
  133. data/test/scout/llm/chat/test_prov_cli.rb +310 -15
  134. data/test/scout/llm/chat/test_prov_cli_live.rb +152 -0
  135. data/test/scout/llm/chat/test_prov_plot.rb +213 -0
  136. data/test/scout/llm/chat/test_prov_timeline.rb +355 -0
  137. data/test/scout/llm/chat/test_provenance.rb +67 -22
  138. data/test/scout/llm/chat/test_provenance_index.rb +479 -0
  139. data/test/scout/llm/chat/test_society_view.rb +159 -0
  140. data/test/scout/llm/test_agent.rb +1 -1
  141. data/test/scout/llm/test_embed.rb +103 -1
  142. data/test/scout/llm/test_request_context.rb +299 -0
  143. data/test/scout/llm/test_sandbox.rb +249 -0
  144. data/test/scout/llm/tools/test_agent_pairing.rb +150 -0
  145. data/test/scout/llm/tools/test_call_delegation_conflict.rb +316 -0
  146. data/test/scout/llm/tools/test_definition.rb +332 -0
  147. data/test/scout/llm/tools/test_jobs_file.rb +211 -0
  148. data/test/scout/llm/tools/test_mcp.rb +37 -8
  149. data/test/scout/llm/tools/test_workflow.rb +45 -1
  150. data/test/scout/model/decision/test_jev.rb +453 -0
  151. data/test/scout/model/python/huggingface/causal/test_next_token.rb +7 -10
  152. data/test/scout/model/python/huggingface/test_causal.rb +11 -2
  153. data/test/scout/model/python/huggingface/test_classification.rb +5 -3
  154. data/test/scout/model/python/test_availability.rb +116 -0
  155. data/test/scout/model/python/test_torch.rb +54 -2
  156. data/test/support/availability.rb +72 -174
  157. data/test/support/fake_clients.rb +18 -9
  158. data/test/support/fixtures.rb +75 -6
  159. data/test/support/mock_backend.rb +9 -1
  160. data/test/support/test_fixtures.rb +156 -0
  161. data/test/test_helper.rb +14 -4
  162. metadata +70 -26
  163. data/research/ChatAnalyst-required-changes.md +0 -167
  164. data/research/agent-delegation-analysis.md +0 -810
  165. data/research/agent-meta-provenance-integration-plan.md +0 -622
  166. data/research/agent-workflow-analysis.md +0 -1120
  167. data/research/backends-analysis.md +0 -836
  168. data/research/chat-core-analysis.md +0 -946
  169. data/research/chatanalyst-provenance/00-baseline.md +0 -30
  170. data/research/chatanalyst-provenance/01-repo-map.md +0 -60
  171. data/research/chatanalyst-provenance/02-event-reconstruction.md +0 -55
  172. data/research/chatanalyst-provenance/03-duplication-evidence.md +0 -45
  173. data/research/chatanalyst-provenance/04-tooling-root-cause.md +0 -57
  174. data/research/chatanalyst-provenance/05-fix-plan.md +0 -46
  175. data/research/chatanalyst-provenance/07-critic-review.md +0 -25
  176. data/research/chatanalyst-provenance/final-report.md +0 -45
  177. data/research/chatanalyst-provenance/resumption.md +0 -37
  178. data/research/coding-philosophy-analysis.md +0 -928
  179. data/research/commands-analysis.md +0 -947
  180. data/research/multi-agent-patterns-analysis.md +0 -853
  181. data/research/prompt-strategies-analysis.md +0 -630
  182. data/research/prov-verbosity-fix-notes.md +0 -77
  183. data/research/provenance-analysis.md +0 -469
  184. data/research/provenance-continuation-accounting.md +0 -255
  185. data/research/synthesis-report.md +0 -487
  186. data/research/tools-system-analysis.md +0 -779
@@ -0,0 +1,211 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require 'scout/llm/tools/call'
3
+
4
+ # Lifecycle guards for the live-workload sidecar `<base>.jobs` written by
5
+ # LLM.process_calls while workflow jobs are in flight under a chat save_file.
6
+ #
7
+ # Semantics under test (canonical, fixed):
8
+ # * the file is a SIBLING of the save_file, derived by Chat.jobs_file
9
+ # (trailing '.chat' strip only);
10
+ # * it is WRITTEN just before Workflow.produce with the short paths of the
11
+ # jobs not yet done (newline-joined), one write per round: a snapshot of
12
+ # the current in-flight set, not an append log;
13
+ # * it is REMOVED in an ensure once Workflow.produce returns -- whether the
14
+ # jobs finished or one of them failed;
15
+ # * no file is created at all when save_file is nil.
16
+ #
17
+ # The observation trick: the child task runs in a fork under
18
+ # Workflow::LocalExecutor, so in-process globals do NOT propagate from it.
19
+ # Instead the task block itself appends a line to an observations file that
20
+ # lives next to the save_file; the writer has necessarily run before the task
21
+ # block starts (it runs before Workflow.produce).
22
+ class TestLLMToolCallJobsFile < Test::Unit::TestCase
23
+ # SlowChildWF: a real (mock-free) workflow whose tasks sleep, then record
24
+ # what the sidecar looked like from inside produce. Path.join is used so the
25
+ # observations file does not depend on the workflow jobs directory.
26
+ # Observation directory for the child tasks: set as a PROCESS GLOBAL
27
+ # before run_round. The task block may run in a fork under
28
+ # Workflow::LocalExecutor, but a fork copies the parent's memory, so the
29
+ # child sees it; the reverse (child writing memory) does not propagate,
30
+ # which is why observations go to FILES. A workflow INPUT would not work
31
+ # here: Scout path-resolves plain string inputs and relocates absolute
32
+ # tmpdir values under the workflow's file lookup paths.
33
+ def self.obs_dir; @obs_dir; end
34
+ def self.obs_dir=(v); @obs_dir = v; end
35
+
36
+ SlowChildWF = Module.new do
37
+ extend Workflow
38
+ self.name = "SlowChildWF"
39
+
40
+ task :slow => :string do
41
+ sleep 0.2
42
+ SlowChildWF.record_sidecar_observation(TestLLMToolCallJobsFile.obs_dir, 'slow')
43
+ 'done'
44
+ end
45
+
46
+ task :fail => :string do
47
+ SlowChildWF.record_sidecar_observation(TestLLMToolCallJobsFile.obs_dir, 'fail')
48
+ raise 'child failed'
49
+ end
50
+
51
+ # Each child writes its own marker (no lost-update race) snapshotting the
52
+ # sidecar content it can see; it runs under Workflow.produce, i.e. after
53
+ # the writer fired.
54
+ def self.record_sidecar_observation(dir, name)
55
+ dir = dir.to_s
56
+ return if dir.empty?
57
+ save_file = File.join(dir, 'agent.chat')
58
+ jobs = Open.exists?(Chat.jobs_file(save_file)) ? Open.read(Chat.jobs_file(save_file)) : ''
59
+ Open.write(File.join(dir, name.to_s + '.obs'), jobs)
60
+ Open.write(File.join(dir, name.to_s + '.seen'), jobs)
61
+ end
62
+ end
63
+
64
+ # `job` tool shape used by LLM.process_calls: {name => [obj, definition]}.
65
+ # The Proc returns a Step (not-yet-done), exactly like LLM.call_workflow
66
+ # for a non-exec workflow task; process_calls then produces them.
67
+ def slow_child_tool(wf, task)
68
+ proc do |_name, args|
69
+ wf.job(task.to_sym, args[:jobname], {})
70
+ end
71
+ end
72
+
73
+ # Point the fork-inherited observation variable at dir and yield. A class
74
+ # ivar (not a const) so reassignment does not warn; forks still copy it.
75
+ def with_obs_dir(dir)
76
+ old = TestLLMToolCallJobsFile.obs_dir
77
+ TestLLMToolCallJobsFile.obs_dir = dir
78
+ yield
79
+ ensure
80
+ TestLLMToolCallJobsFile.obs_dir = old
81
+ end
82
+
83
+ def tool_call(id, name, arguments)
84
+ IndiferentHash.setup({
85
+ 'id' => id, 'type' => 'function',
86
+ 'function' => {'name' => name, 'arguments' => arguments.to_json}
87
+ })
88
+ end
89
+
90
+ def read_sidecar(save_file)
91
+ path = Chat.jobs_file(save_file)
92
+ Open.exists?(path) ? Open.read(path) : nil
93
+ end
94
+
95
+ # Drive one process_calls round directly (no LLM.ask, no mock backend): the
96
+ # sidecar writer is inside process_calls, which is exactly the unit here.
97
+ def run_round(save_file, tools, calls)
98
+ LLM.process_calls(tools, calls, save_file: save_file)
99
+ end
100
+
101
+ def test_jobs_file_exists_while_child_in_flight_and_lists_its_short_path
102
+ save_dir = File.join(tmpdir, 'jobs_single')
103
+ FileUtils.mkdir_p save_dir
104
+ save_file = File.join(save_dir, 'agent.chat')
105
+
106
+ with_obs_dir(save_dir) do
107
+ run_round(save_file,
108
+ {'slow' => [slow_child_tool(SlowChildWF, :slow), nil]},
109
+ [tool_call('c1', 'slow', {jobname: 'single'})])
110
+ end
111
+
112
+ # The child OBSERVED the sidecar from inside produce: a marker file was
113
+ # written by the forked task (named after its Step, hence the glob).
114
+ seen = Dir.glob(File.join(save_dir, '*.seen'))
115
+ assert !seen.empty?, 'child task never ran (no *.seen marker)'
116
+
117
+ # ... and it saw exactly the child's short path (newline-separated set,
118
+ # single entry here, no extra decoration).
119
+ assert_equal [SlowChildWF.job(:slow, 'single', {}).short_path],
120
+ Open.read(seen.first).split("\n")
121
+ end
122
+
123
+ def test_jobs_file_removed_after_children_complete
124
+ save_dir = File.join(tmpdir, 'jobs_after')
125
+ FileUtils.mkdir_p save_dir
126
+ save_file = File.join(save_dir, 'agent.chat')
127
+
128
+ with_obs_dir(save_dir) do
129
+ run_round(save_file,
130
+ {'slow' => [slow_child_tool(SlowChildWF, :slow), nil]},
131
+ [tool_call('c1', 'slow', {jobname: 'after'})])
132
+ end
133
+
134
+ assert !Open.exists?(Chat.jobs_file(save_file)),
135
+ "<base>.jobs must be removed once Workflow.produce returns"
136
+ end
137
+
138
+ def test_jobs_file_removed_when_produce_raises
139
+ save_dir = File.join(tmpdir, 'jobs_fail')
140
+ FileUtils.mkdir_p save_dir
141
+ save_file = File.join(save_dir, 'agent.chat')
142
+
143
+ # process_calls rescues around produce, so the round returns normally;
144
+ # the child raised inside the task block (the failure surfaces as the
145
+ # error envelope in the function_call_output).
146
+ result = with_obs_dir(save_dir) do
147
+ run_round(save_file,
148
+ {'fail' => [slow_child_tool(SlowChildWF, :fail), nil]},
149
+ [tool_call('c1', 'fail', {jobname: 'boom'})])
150
+ end
151
+
152
+ # The failing child still ran (and observed) before raising.
153
+ assert !Dir.glob(File.join(save_dir, '*.seen')).empty?,
154
+ 'failing child never ran'
155
+
156
+ # The ensure removed the sidecar even though produce ended in an error.
157
+ assert !Open.exists?(Chat.jobs_file(save_file)),
158
+ "<base>.jobs must be removed when Workflow.produce fails"
159
+
160
+ assert_equal 1, result.select{|m| m[:role].to_s == 'function_call_output' }.length
161
+ end
162
+
163
+ def test_jobs_file_lists_two_in_flight_children
164
+ save_dir = File.join(tmpdir, 'jobs_two')
165
+ FileUtils.mkdir_p save_dir
166
+ save_file = File.join(save_dir, 'agent.chat')
167
+
168
+ with_obs_dir(save_dir) do
169
+ run_round(save_file,
170
+ {'slow' => [slow_child_tool(SlowChildWF, :slow), nil]},
171
+ [tool_call('c1', 'slow', {jobname: 'pair_a'}),
172
+ tool_call('c2', 'slow', {jobname: 'pair_b'})])
173
+ end
174
+
175
+ expected = [SlowChildWF.job(:slow, 'pair_a', {}).short_path,
176
+ SlowChildWF.job(:slow, 'pair_b', {}).short_path].sort
177
+
178
+ # BOTH children ran under produce (both marker files exist) and the
179
+ # snapshot the LAST one to observe saw listed BOTH in-flight jobs (the
180
+ # two forks write the same file name 'slow.seen'; each sees the full
181
+ # pre-produce snapshot, which already contains both short paths).
182
+ seen_files = Dir.glob(File.join(save_dir, '*.seen'))
183
+ assert !seen_files.empty?, 'no child task ever ran (no *.seen marker)'
184
+ seen_files.each do |file|
185
+ assert_equal expected, Open.read(file).split("\n").sort,
186
+ "child snapshot #{File.basename(file)} did not list both in-flight jobs"
187
+ end
188
+ end
189
+
190
+ def test_no_jobs_file_created_when_save_file_is_nil
191
+ wf_dir = Workflow.directory['SlowChildWF']
192
+ before = Open.exists?(wf_dir) ? Dir.glob(File.join(wf_dir, '**', '*.jobs')) : []
193
+
194
+ obs = File.join(tmpdir, 'obs_nil')
195
+ FileUtils.mkdir_p obs
196
+ with_obs_dir(obs) do
197
+ run_round(nil,
198
+ {'slow' => [slow_child_tool(SlowChildWF, :slow), nil]},
199
+ [tool_call('c1', 'slow', {jobname: 'nil_save'})])
200
+ end
201
+
202
+ after = Dir.glob(File.join(wf_dir, '**', '*.jobs'))
203
+
204
+ # The child still ran (its marker file was written) but no .jobs file
205
+ # was ever created anywhere in the jobs tree, since the writer is a
206
+ # no-op without a save_file.
207
+ assert !Dir.glob(File.join(obs, '*.obs')).empty?, 'child never ran'
208
+ assert_equal before.sort, after.sort
209
+ assert(!after.any?{|p| p.end_with?('.jobs') })
210
+ end
211
+ end
@@ -1,13 +1,42 @@
1
1
  require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
2
  require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
3
 
4
- class TestClass < Test::Unit::TestCase
5
- # Real remote MCP server version moved to
6
- # test/integration/scout/llm/tools/test_mcp.rb: LLM.mcp_tools needs a live
7
- # MCP server (no seam to fake). Stdio coverage stays unit-side in
8
- # test/scout/llm/test_mcp.rb.
9
- def _test_client
10
- c = LLM.mcp_tools("https://api.githubcopilot.com/mcp/")
11
- assert_include c.keys, "get_me"
4
+ require 'scout/llm/mcp'
5
+ require 'json'
6
+
7
+ module TestMCPServingWorkflow
8
+ extend Workflow
9
+ self.name = "TestMCPServingWorkflow"
10
+
11
+ desc "Greet someone"
12
+ input :name, :string, "string", "Who to greet"
13
+ task :greet => :string do |name| "hello #{name}" end
14
+ export :greet
15
+ end
16
+
17
+ class TestLLMToolMCP < Test::Unit::TestCase
18
+ def setup
19
+ @server = TestMCPServingWorkflow.mcp(:greet)
20
+ end
21
+
22
+ def request(method, params)
23
+ JSON.parse @server.handle_json({'jsonrpc' => '2.0', 'id' => 1, 'method' => method, 'params' => params}.to_json)
24
+ end
25
+
26
+ def test_mcp_serves_task_as_string_named_tool
27
+ response = request('tools/list', {})
28
+ assert_equal ['greet'], response['result']['tools'].collect{|t| t['name']}
29
+ end
30
+
31
+ def test_mcp_tool_call_dispatches_to_workflow
32
+ response = request('tools/call', {'name' => 'greet', 'arguments' => {'name' => 'World'}})
33
+ assert_equal 'hello World', response['result']['content'].first['text']
34
+ assert ! response['result']['isError']
35
+ end
36
+
37
+ def test_mcp_default_task_set_registers_string_names
38
+ server = TestMCPServingWorkflow.mcp
39
+ tool = server.instance_variable_get(:@tools)['greet']
40
+ assert(tool, "default task set should register the greet tool by string name")
12
41
  end
13
42
  end
@@ -56,5 +56,49 @@ class TestLLMToolWorkflow < Test::Unit::TestCase
56
56
 
57
57
  assert_equal "30 minutes", LLM.call_workflow(m, :step_time, step: 'bake', exec_type: 'exec')
58
58
  end
59
- end
60
59
 
60
+ def test_refresh_applies_to_ordinary_tasks_before_return_semantics
61
+ calls = 0
62
+ workflow = Module.new do
63
+ extend Workflow
64
+ self.name = "RefreshWorkflow"
65
+ input :value, :string
66
+ task :count => :integer do |_value|
67
+ calls += 1
68
+ end
69
+ end
70
+
71
+ first = LLM.call_workflow(workflow, :count, value: 'same')
72
+ first.produce
73
+ assert_equal 1, first.load
74
+
75
+ refreshed = LLM.call_workflow(workflow, :count, value: 'same', refresh: 'refresh')
76
+ assert(Step === refreshed)
77
+ refreshed.produce
78
+ assert_equal 2, refreshed.load
79
+
80
+ refreshed_path = LLM.call_workflow(workflow, :count, value: 'same', return_path: true, refresh: 'refresh')
81
+ assert_equal 3, Open.read(refreshed_path).to_i
82
+
83
+ deeply_refreshed_path = LLM.call_workflow(workflow, :count, value: 'same', return_path: true, refresh: 'deep_refresh')
84
+ assert_equal 4, Open.read(deeply_refreshed_path).to_i
85
+ end
86
+
87
+ def test_exported_task_return_semantics
88
+ workflow = Module.new do
89
+ extend Workflow
90
+ self.name = "ExportedWorkflow"
91
+ input :value, :string
92
+ task :exported_value => :string do |value|
93
+ "exported-#{value}"
94
+ end
95
+ export_exec :exported_value
96
+ end
97
+
98
+ assert_equal "exported-result", LLM.call_workflow(workflow, :exported_value, value: 'result')
99
+
100
+ path = LLM.call_workflow(workflow, :exported_value, value: 'result', return_path: true)
101
+ assert_kind_of String, path
102
+ assert_equal "exported-result", Open.read(path)
103
+ end
104
+ end