scout-ai 2.0.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 +135 -55
- 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 +320 -34
- 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 +402 -44
- 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 +64 -0
- 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 +79 -17
- data/lib/scout/llm/agent.rb +151 -27
- data/lib/scout/llm/ask.rb +37 -27
- 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 +131 -32
- 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 -52
- 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 +352 -626
- 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 +72 -26
- 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 +845 -80
- 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 +109 -22
- 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 +200 -28
- data/test/scout/llm/chat/test_agent_meta_tokens.rb +112 -7
- 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 +708 -13
- 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 +71 -25
- 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/synthesis-report.md +0 -487
- data/research/tools-system-analysis.md +0 -779
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require 'scout/llm/agent'
|
|
3
|
+
|
|
4
|
+
class TestLLMAgentDelegate < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
super
|
|
7
|
+
@dir = File.join(tmpdir, 'delegate_tests')
|
|
8
|
+
FileUtils.mkdir_p @dir
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def worker_agent(content = 'worker helper')
|
|
12
|
+
LLM::Agent.new(start_chat: Chat.setup([{role: :system, content: content}]))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parent_agent(content = 'parent')
|
|
16
|
+
agent = LLM::Agent.new(start_chat: Chat.setup([{role: :system, content: content}]))
|
|
17
|
+
agent
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Run the delegate tool block exactly like process_calls would: tools hash
|
|
21
|
+
# lookup then block.call(name, arguments).
|
|
22
|
+
def invoke_hand_off(agent, tool_name, arguments = {})
|
|
23
|
+
tools = agent.other_options[:tools]
|
|
24
|
+
assert tools.key?(tool_name), "tool #{tool_name} not registered"
|
|
25
|
+
block, _definition = tools[tool_name]
|
|
26
|
+
block.call(tool_name, IndiferentHash.setup(arguments.dup))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def message_contents(chat, role)
|
|
30
|
+
chat.select { |m| m[:role].to_s == role.to_s }.collect { |m| m[:content] }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_default_block_returns_an_agent
|
|
34
|
+
root = parent_agent
|
|
35
|
+
root.delegate worker_agent, 'Worker', 'Hand work to the worker'
|
|
36
|
+
|
|
37
|
+
result = invoke_hand_off(root, :hand_off_to_Worker, message: 'do something')
|
|
38
|
+
|
|
39
|
+
assert LLM::Agent === result
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_parent_save_sweeps_the_hand_off_child
|
|
43
|
+
TmpFile.with_dir do |dir|
|
|
44
|
+
LLM::Mock.script('worker answer')
|
|
45
|
+
|
|
46
|
+
root = parent_agent
|
|
47
|
+
root.save_file = File.join(dir, 'root.chat')
|
|
48
|
+
root.delegate worker_agent, 'Worker', 'Hand work to the worker'
|
|
49
|
+
|
|
50
|
+
result = invoke_hand_off(root, :hand_off_to_Worker, message: 'first task')
|
|
51
|
+
result.chat persist: false, endpoint: 'mock', backend: :mock
|
|
52
|
+
|
|
53
|
+
root.save
|
|
54
|
+
|
|
55
|
+
child_file = File.join(dir, 'root.society', 'Worker', 'Worker', 'agent.chat')
|
|
56
|
+
assert Open.exist?(child_file)
|
|
57
|
+
assert_include Open.read(child_file), 'first task'
|
|
58
|
+
assert_include Open.read(child_file), 'worker answer'
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_state_persists_across_calls_and_rebranches_on_new_conversation
|
|
63
|
+
root = parent_agent
|
|
64
|
+
root.delegate worker_agent, 'Worker', 'Hand work to the worker'
|
|
65
|
+
|
|
66
|
+
first = invoke_hand_off(root, :hand_off_to_Worker, message: 'first message')
|
|
67
|
+
second = invoke_hand_off(root, :hand_off_to_Worker, message: 'second message')
|
|
68
|
+
|
|
69
|
+
assert_same first, second
|
|
70
|
+
assert_equal ['first message', 'second message'],
|
|
71
|
+
message_contents(second.current_chat, :user)
|
|
72
|
+
|
|
73
|
+
# new_conversation re-branches: prior user messages dropped, start_chat kept
|
|
74
|
+
third = invoke_hand_off(root, :hand_off_to_Worker,
|
|
75
|
+
message: 'fresh start', new_conversation: true)
|
|
76
|
+
assert_same first, third
|
|
77
|
+
assert_equal ['fresh start'], message_contents(third.current_chat, :user)
|
|
78
|
+
assert_equal ['worker helper'], message_contents(third.current_chat, :system)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_conversation_agent_returns_the_live_registered_agent
|
|
82
|
+
root = parent_agent
|
|
83
|
+
worker = worker_agent
|
|
84
|
+
before = worker.current_chat.length
|
|
85
|
+
|
|
86
|
+
root.delegate worker, 'Worker', 'Hand work to the worker'
|
|
87
|
+
registered = invoke_hand_off(root, :hand_off_to_Worker, message: 'task')
|
|
88
|
+
|
|
89
|
+
# The registered holder is reachable by key and is the block's return
|
|
90
|
+
assert_same registered, root.conversation_agent('Worker/Worker')
|
|
91
|
+
assert_nil root.conversation_agent('Worker/missing')
|
|
92
|
+
|
|
93
|
+
# The passed-in agent object is NOT the conversation holder anymore: its
|
|
94
|
+
# chat does not advance (staleness is visible, not silent).
|
|
95
|
+
assert_equal before, worker.current_chat.length
|
|
96
|
+
assert message_contents(worker.current_chat, :user).empty?
|
|
97
|
+
assert_include message_contents(registered.current_chat, :user), 'task'
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_hyphenated_name_gives_a_sanitized_slot
|
|
101
|
+
TmpFile.with_dir do |dir|
|
|
102
|
+
LLM::Mock.script('worker answer')
|
|
103
|
+
|
|
104
|
+
root = parent_agent
|
|
105
|
+
root.save_file = File.join(dir, 'root.chat')
|
|
106
|
+
root.delegate worker_agent, 'data-miner', 'Hand work to the miner'
|
|
107
|
+
|
|
108
|
+
# The tool name keeps the raw hyphen; only the conversation slot is
|
|
109
|
+
# sanitized (hyphens are legal in both, so slot == name here)
|
|
110
|
+
result = invoke_hand_off(root, :'hand_off_to_data-miner', message: 'mine')
|
|
111
|
+
result.chat persist: false, endpoint: 'mock', backend: :mock
|
|
112
|
+
root.save
|
|
113
|
+
|
|
114
|
+
child_file = File.join(dir, 'root.society', 'data-miner', 'data-miner', 'agent.chat')
|
|
115
|
+
assert Open.exist?(child_file), "expected #{child_file}"
|
|
116
|
+
assert_include Open.read(child_file), 'mine'
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_pre_registered_agent_is_the_society_template
|
|
121
|
+
root = parent_agent
|
|
122
|
+
worker = worker_agent
|
|
123
|
+
|
|
124
|
+
root.delegate worker, 'Worker', 'Hand work to the worker'
|
|
125
|
+
|
|
126
|
+
# The passed agent became the template for that name in @society
|
|
127
|
+
assert_same worker, root.society['Worker']
|
|
128
|
+
# A socialize ask of the same name clones THAT template, not an installed one
|
|
129
|
+
root.socialize
|
|
130
|
+
ask_result = invoke_hand_off(root, :ask,
|
|
131
|
+
agent: 'Worker', prompt: 'via ask tool')
|
|
132
|
+
assert_not_same worker, ask_result
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_custom_block_receives_the_passed_agent_and_mutates_it
|
|
136
|
+
root = parent_agent
|
|
137
|
+
worker = worker_agent
|
|
138
|
+
|
|
139
|
+
root.delegate worker, 'Worker', 'Hand work to the worker' do |_name, parameters|
|
|
140
|
+
worker.user "custom: #{parameters[:message]}"
|
|
141
|
+
worker
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
result = invoke_hand_off(root, :hand_off_to_Worker, message: 'custom work')
|
|
145
|
+
|
|
146
|
+
assert_same worker, result
|
|
147
|
+
assert_equal ['custom: custom work'], message_contents(worker.current_chat, :user)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_non_agent_duck_object_keeps_legacy_path
|
|
151
|
+
duck = Object.new
|
|
152
|
+
seen = []
|
|
153
|
+
duck.define_singleton_method(:start) { seen << :start }
|
|
154
|
+
duck.define_singleton_method(:user) { |message| seen << [:user, message]; self }
|
|
155
|
+
|
|
156
|
+
root = parent_agent
|
|
157
|
+
root.delegate duck, 'Duck', 'Hand work to the duck'
|
|
158
|
+
|
|
159
|
+
result = invoke_hand_off(root, :hand_off_to_Duck,
|
|
160
|
+
message: 'quack', new_conversation: true)
|
|
161
|
+
|
|
162
|
+
assert_same duck, result
|
|
163
|
+
assert_equal [:start, [:user, 'quack']], seen
|
|
164
|
+
assert_nil root.chats
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def test_bad_hand_off_returns_the_exception_not_a_raise
|
|
168
|
+
root = parent_agent
|
|
169
|
+
|
|
170
|
+
root.delegate worker_agent, 'Worker', 'Hand work to the worker'
|
|
171
|
+
|
|
172
|
+
# A message that is not a String raises ParameterException (a
|
|
173
|
+
# ScoutException subclass) inside ask_conversation; the block must return
|
|
174
|
+
# the exception rather than aborting the tool round.
|
|
175
|
+
result = invoke_hand_off(root, :hand_off_to_Worker, message: nil)
|
|
176
|
+
|
|
177
|
+
assert ParameterException === result
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def test_adopt_current_folds_template_progress_into_the_seed
|
|
181
|
+
template = worker_agent
|
|
182
|
+
template.user 'template progress'
|
|
183
|
+
template.current_chat.push({role: :assistant, content: 'template answer'})
|
|
184
|
+
|
|
185
|
+
root = parent_agent
|
|
186
|
+
root.delegate template, 'Worker', 'Hand work to the worker'
|
|
187
|
+
registered = invoke_hand_off(root, :hand_off_to_Worker, message: 'new task')
|
|
188
|
+
|
|
189
|
+
# Seed order: start_chat copy, adopted delta, then the delegated message
|
|
190
|
+
assert_include message_contents(registered.current_chat, :user), 'template progress'
|
|
191
|
+
assert_include message_contents(registered.current_chat, :assistant), 'template answer'
|
|
192
|
+
assert_equal ['template progress', 'new task'],
|
|
193
|
+
message_contents(registered.current_chat, :user)
|
|
194
|
+
assert_equal ['worker helper'], message_contents(registered.current_chat, :system)
|
|
195
|
+
# The template itself is untouched
|
|
196
|
+
assert_equal ['template progress'], message_contents(template.current_chat, :user)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def test_adopt_with_empty_template_current_chat_is_a_no_op
|
|
200
|
+
template = worker_agent
|
|
201
|
+
|
|
202
|
+
root = parent_agent
|
|
203
|
+
root.delegate template, 'Worker', 'Hand work to the worker'
|
|
204
|
+
registered = invoke_hand_off(root, :hand_off_to_Worker, message: 'only message')
|
|
205
|
+
|
|
206
|
+
assert_equal ['worker helper'], message_contents(registered.current_chat, :system)
|
|
207
|
+
assert_equal ['only message'], message_contents(registered.current_chat, :user)
|
|
208
|
+
end
|
|
209
|
+
end
|