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.
- checksums.yaml +4 -4
- data/.vimproject +133 -58
- data/README.md +2 -1
- data/VERSION +1 -1
- data/doc/Improvements.md +490 -148
- data/doc/Model.md +53 -10
- data/doc/StartHere.md +44 -19
- data/doc/developer/Architecture.md +25 -6
- data/doc/developer/Backends.md +207 -48
- data/doc/developer/ChatLifecycle.md +121 -20
- data/doc/developer/DelegationInternals.md +319 -33
- data/doc/developer/DesignPrinciples.md +205 -16
- data/doc/developer/PathEngine.md +628 -0
- data/doc/developer/PromptProcessing.md +332 -82
- data/doc/developer/Provenance.md +388 -40
- data/doc/developer/Sandbox.md +213 -0
- data/doc/user/BuildingAgents.md +130 -18
- data/doc/user/Cookbook.md +29 -8
- data/doc/user/CoreConcepts.md +7 -6
- data/doc/user/Delegation.md +166 -15
- data/doc/user/GettingStarted.md +20 -16
- data/doc/user/ManagingContext.md +155 -17
- data/doc/user/MultiAgentWorkflows.md +105 -15
- data/doc/user/Python.md +11 -1
- data/doc/user/RunningInference.md +90 -47
- data/doc/user/ToolCalling.md +134 -29
- data/doc/user/WritingChats.md +56 -27
- data/lib/scout/llm/agent/attach.rb +13 -17
- data/lib/scout/llm/agent/chat.rb +32 -0
- data/lib/scout/llm/agent/construction.rb +64 -0
- data/lib/scout/llm/agent/conversation.rb +304 -0
- data/lib/scout/llm/agent/delegate.rb +56 -238
- data/lib/scout/llm/agent/path/edit.rb +230 -0
- data/lib/scout/llm/agent/path/patch.rb +252 -0
- data/lib/scout/llm/agent/path/workflow_kinds.rb +175 -0
- data/lib/scout/llm/agent/path.rb +1777 -0
- data/lib/scout/llm/agent/save.rb +11 -9
- data/lib/scout/llm/agent/workflow.rb +77 -16
- data/lib/scout/llm/agent.rb +147 -31
- data/lib/scout/llm/ask.rb +28 -17
- data/lib/scout/llm/backends/anthropic.rb +1 -1
- data/lib/scout/llm/backends/bedrock.rb +3 -2
- data/lib/scout/llm/backends/default.rb +127 -34
- data/lib/scout/llm/backends/glm.rb +28 -1
- data/lib/scout/llm/backends/huggingface.rb +1 -1
- data/lib/scout/llm/backends/ollama.rb +1 -1
- data/lib/scout/llm/backends/openai.rb +7 -6
- data/lib/scout/llm/backends/openwebui.rb +14 -7
- data/lib/scout/llm/backends/relay.rb +8 -2
- data/lib/scout/llm/chat/agent_meta.rb +24 -60
- data/lib/scout/llm/chat/parse.rb +1 -1
- data/lib/scout/llm/chat/process/files.rb +10 -0
- data/lib/scout/llm/chat/process/meta.rb +5 -7
- data/lib/scout/llm/chat/process/tools.rb +104 -49
- data/lib/scout/llm/chat/prompt/epoch_tool_compactation.rb +355 -0
- data/lib/scout/llm/chat/prompt/inbox.rb +188 -0
- data/lib/scout/llm/chat/prompt/shorten_tools.rb +797 -13
- data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +1 -365
- data/lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb +1 -0
- data/lib/scout/llm/chat/prompt.rb +24 -10
- data/lib/scout/llm/chat/provenance/live.rb +1080 -0
- data/lib/scout/llm/chat/provenance/tokens.rb +386 -0
- data/lib/scout/llm/chat/provenance.rb +343 -676
- data/lib/scout/llm/chat.rb +8 -2
- data/lib/scout/llm/embed.rb +15 -3
- data/lib/scout/llm/image.rb +4 -1
- data/lib/scout/llm/mcp.rb +4 -2
- data/lib/scout/llm/request_context.rb +234 -0
- data/lib/scout/llm/sandbox.rb +263 -0
- data/lib/scout/llm/tools/call.rb +163 -42
- data/lib/scout/llm/tools/definition.rb +48 -0
- data/lib/scout/llm/tools/knowledge_base.rb +1 -0
- data/lib/scout/llm/tools/mcp.rb +50 -43
- data/lib/scout/llm/tools/workflow.rb +90 -20
- data/lib/scout/llm/tools.rb +14 -41
- data/lib/scout/model/decision/base.rb +43 -0
- data/lib/scout/model/decision/jev.rb +161 -0
- data/lib/scout/model/python/torch.rb +1 -1
- data/research/clear-tools-inherit.md +171 -0
- data/research/path-engine-dc1-dc2-dc3-fixes.md +279 -0
- data/research/path-kind-chat-role.md +96 -0
- data/research/path-kind-contract-fixes-engine.md +307 -0
- data/research/scout-ai-runtime-availability.md +65 -0
- data/research/subsys/README.md +127 -0
- data/research/subsys/agent-delegation.md +201 -0
- data/research/subsys/agent-society.md +275 -0
- data/research/subsys/agentworkflow.md +233 -0
- data/research/subsys/backends.md +221 -0
- data/research/subsys/chat.md +314 -0
- data/research/subsys/embed-image.md +244 -0
- data/research/subsys/entry-cli.md +253 -0
- data/research/subsys/model-ml.md +326 -0
- data/research/subsys/provenance.md +290 -0
- data/research/subsys/tools.md +334 -0
- data/scout-ai.gemspec +71 -27
- data/scout_commands/agent/ask +8 -7
- data/scout_commands/llm/abridged +40 -0
- data/scout_commands/llm/ask +9 -9
- data/scout_commands/llm/md +2 -0
- data/scout_commands/llm/prov +724 -59
- data/scout_commands/llm/word +4 -0
- data/share/word/reference.docx +0 -0
- data/test/integration/scout/model/decision/test_jev.rb +144 -0
- data/test/scout/llm/agent/test_attach.rb +117 -0
- data/test/scout/llm/agent/test_conversation.rb +407 -0
- data/test/scout/llm/agent/test_delegate.rb +209 -0
- data/test/scout/llm/agent/test_path.rb +1812 -0
- data/test/scout/llm/agent/test_path_edit.rb +908 -0
- data/test/scout/llm/agent/test_path_errors.rb +390 -0
- data/test/scout/llm/agent/test_path_filesystem.rb +532 -0
- data/test/scout/llm/agent/test_path_patch.rb +233 -0
- data/test/scout/llm/agent/test_path_promotion.rb +386 -0
- data/test/scout/llm/agent/test_path_workflow_integration.rb +665 -0
- data/test/scout/llm/agent/test_save.rb +70 -15
- data/test/scout/llm/agent/test_workflow.rb +130 -4
- data/test/scout/llm/backends/test_anthropic.rb +4 -4
- data/test/scout/llm/backends/test_bedrock.rb +4 -4
- data/test/scout/llm/backends/test_format_other.rb +43 -0
- data/test/scout/llm/backends/test_ollama.rb +2 -2
- data/test/scout/llm/backends/test_openwebui.rb +12 -8
- data/test/scout/llm/backends/test_reasoning.rb +114 -0
- data/test/scout/llm/chat/agent_meta_fixtures.rb +28 -27
- data/test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb +612 -0
- data/test/scout/llm/chat/prov_plot_fixtures.rb +131 -0
- data/test/scout/llm/chat/test_agent_meta.rb +40 -80
- data/test/scout/llm/chat/test_agent_meta_provenance.rb +67 -28
- data/test/scout/llm/chat/test_agent_meta_tokens.rb +59 -8
- data/test/scout/llm/chat/test_agent_view.rb +178 -0
- data/test/scout/llm/chat/test_live_report.rb +282 -0
- data/test/scout/llm/chat/test_live_workload.rb +193 -0
- data/test/scout/llm/chat/test_parse.rb +32 -2
- data/test/scout/llm/chat/test_prompt.rb +411 -0
- data/test/scout/llm/chat/test_prov_cli.rb +310 -15
- data/test/scout/llm/chat/test_prov_cli_live.rb +152 -0
- data/test/scout/llm/chat/test_prov_plot.rb +213 -0
- data/test/scout/llm/chat/test_prov_timeline.rb +355 -0
- data/test/scout/llm/chat/test_provenance.rb +67 -22
- data/test/scout/llm/chat/test_provenance_index.rb +479 -0
- data/test/scout/llm/chat/test_society_view.rb +159 -0
- data/test/scout/llm/test_agent.rb +1 -1
- data/test/scout/llm/test_embed.rb +103 -1
- data/test/scout/llm/test_request_context.rb +299 -0
- data/test/scout/llm/test_sandbox.rb +249 -0
- data/test/scout/llm/tools/test_agent_pairing.rb +150 -0
- data/test/scout/llm/tools/test_call_delegation_conflict.rb +316 -0
- data/test/scout/llm/tools/test_definition.rb +332 -0
- data/test/scout/llm/tools/test_jobs_file.rb +211 -0
- data/test/scout/llm/tools/test_mcp.rb +37 -8
- data/test/scout/llm/tools/test_workflow.rb +45 -1
- data/test/scout/model/decision/test_jev.rb +453 -0
- data/test/scout/model/python/huggingface/causal/test_next_token.rb +7 -10
- data/test/scout/model/python/huggingface/test_causal.rb +11 -2
- data/test/scout/model/python/huggingface/test_classification.rb +5 -3
- data/test/scout/model/python/test_availability.rb +116 -0
- data/test/scout/model/python/test_torch.rb +54 -2
- data/test/support/availability.rb +72 -174
- data/test/support/fake_clients.rb +18 -9
- data/test/support/fixtures.rb +75 -6
- data/test/support/mock_backend.rb +9 -1
- data/test/support/test_fixtures.rb +156 -0
- data/test/test_helper.rb +14 -4
- metadata +70 -26
- data/research/ChatAnalyst-required-changes.md +0 -167
- data/research/agent-delegation-analysis.md +0 -810
- data/research/agent-meta-provenance-integration-plan.md +0 -622
- data/research/agent-workflow-analysis.md +0 -1120
- data/research/backends-analysis.md +0 -836
- data/research/chat-core-analysis.md +0 -946
- data/research/chatanalyst-provenance/00-baseline.md +0 -30
- data/research/chatanalyst-provenance/01-repo-map.md +0 -60
- data/research/chatanalyst-provenance/02-event-reconstruction.md +0 -55
- data/research/chatanalyst-provenance/03-duplication-evidence.md +0 -45
- data/research/chatanalyst-provenance/04-tooling-root-cause.md +0 -57
- data/research/chatanalyst-provenance/05-fix-plan.md +0 -46
- data/research/chatanalyst-provenance/07-critic-review.md +0 -25
- data/research/chatanalyst-provenance/final-report.md +0 -45
- data/research/chatanalyst-provenance/resumption.md +0 -37
- data/research/coding-philosophy-analysis.md +0 -928
- data/research/commands-analysis.md +0 -947
- data/research/multi-agent-patterns-analysis.md +0 -853
- data/research/prompt-strategies-analysis.md +0 -630
- data/research/prov-verbosity-fix-notes.md +0 -77
- data/research/provenance-analysis.md +0 -469
- data/research/provenance-continuation-accounting.md +0 -255
- data/research/synthesis-report.md +0 -487
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|