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
|
@@ -30,8 +30,9 @@ The core building block is `chat_task` — a Scout workflow task that runs an
|
|
|
30
30
|
agent:
|
|
31
31
|
|
|
32
32
|
```ruby
|
|
33
|
-
module MyWorkflow
|
|
33
|
+
module MyWorkflow
|
|
34
34
|
extend Workflow
|
|
35
|
+
include_workflow AgentWorkflow
|
|
35
36
|
chat_task :analyze do
|
|
36
37
|
agent = self.agent('Analyst', chat: chat)
|
|
37
38
|
agent.start
|
|
@@ -43,11 +44,24 @@ end
|
|
|
43
44
|
```
|
|
44
45
|
|
|
45
46
|
The `chat_task` helper and the `agent` method are available in any workflow
|
|
46
|
-
that includes the `AgentWorkflow` mixin.
|
|
47
|
+
that includes the `AgentWorkflow` mixin. `chat_task` itself is defined on
|
|
48
|
+
`Workflow`, so a bare `extend Workflow` module *can* declare one — but the
|
|
49
|
+
block shown here calls `self.agent`, which needs the mixin: `extend Workflow`
|
|
50
|
+
alone raises `NoMethodError`.
|
|
51
|
+
|
|
52
|
+
Mix the mixin in with `include_workflow AgentWorkflow`, not plain `include`:
|
|
53
|
+
the helpers are class-level state that only `include_workflow` merges, so a
|
|
54
|
+
plain `include` leaves the task without `self.agent`/`self.chat`/`log_agent`
|
|
55
|
+
at run time (the helpers list would be empty; `test/scout/llm/agent/test_workflow.rb`
|
|
56
|
+
covers it).
|
|
47
57
|
|
|
48
58
|
### What `chat_task` gives you
|
|
49
59
|
|
|
50
60
|
- **Caching**: The same chat input produces the same output, cached on disk.
|
|
61
|
+
(`chat_task` declares its result type as `:chat`; `:chat` is a registered
|
|
62
|
+
workflow type extension — `Workflow::TYPE_EXTENSIONS[:chat] = :chat` — so
|
|
63
|
+
plain `task :x => :chat` in any workflow gets the same serialization for
|
|
64
|
+
free.)
|
|
51
65
|
- **Provenance**: Every agent run is recorded with full chat history.
|
|
52
66
|
- **Agent chat sidecar**: the agent's own conversation is always written to
|
|
53
67
|
`<job>.files/<name>.chat` next to the job (`agent.chat` by default,
|
|
@@ -56,12 +70,10 @@ that includes the `AgentWorkflow` mixin.
|
|
|
56
70
|
semantics — only the messages produced by this run.
|
|
57
71
|
- **Provenance includes the society tree**: `scout-ai llm prov` treats a job
|
|
58
72
|
and a saved chat the same way here — both are scanned for conversations
|
|
59
|
-
under `<path>.files/`, namely `<path>.files/*.chat
|
|
60
|
-
`<path>.files/*.society/<agent>/<conversation
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`<chat>.files/log/agent.chat`); society conversations keep the same
|
|
64
|
-
`agent.chat` name and are included.
|
|
73
|
+
under `<path>.files/`, namely `<path>.files/*.chat` and
|
|
74
|
+
`<path>.files/*.society/<agent>/<conversation>/`. A saved chat skips
|
|
75
|
+
only its own top-level copy at `<chat>.files/<name>.chat`;
|
|
76
|
+
society conversations keep the same `agent.chat` name and are included.
|
|
65
77
|
- **Lazy society tree**: delegated specialist conversations, if any, are
|
|
66
78
|
saved under `<job>.files/<name>.society/<agent_name>/<conversation>/…`, but
|
|
67
79
|
only when they exist. Nothing is created eagerly — no job starts with an
|
|
@@ -77,7 +89,7 @@ Here's a three-step pipeline: Plan → Execute → Review.
|
|
|
77
89
|
```ruby
|
|
78
90
|
module Pipeline
|
|
79
91
|
extend Workflow
|
|
80
|
-
|
|
92
|
+
include_workflow AgentWorkflow
|
|
81
93
|
|
|
82
94
|
chat_task :plan do |objective|
|
|
83
95
|
agent = self.agent('Planner', chat: chat)
|
|
@@ -154,10 +166,11 @@ chat_task :run do
|
|
|
154
166
|
end
|
|
155
167
|
```
|
|
156
168
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
Delegation semantics — the `ask`/`hand_off_to_<name>` tool pair, the
|
|
170
|
+
inheritance modes and their creation-time scope (the `clear_tools` exception
|
|
171
|
+
included), conversation persistence and the
|
|
172
|
+
safe-delegation rules — are documented once in
|
|
173
|
+
[Delegation.md](Delegation.md); nothing here repeats them.
|
|
161
174
|
|
|
162
175
|
---
|
|
163
176
|
|
|
@@ -200,12 +213,52 @@ Orchestrator → Agent B → Synthesizer
|
|
|
200
213
|
Multiple agents work in parallel on different aspects, then a synthesizer
|
|
201
214
|
combines results.
|
|
202
215
|
|
|
216
|
+
### What the `chat_task` block may return
|
|
217
|
+
|
|
218
|
+
| block returns | outcome |
|
|
219
|
+
|---|---|
|
|
220
|
+
| an agent (`LLM::Agent`) | if its chat does not already end in an assistant message, one more `agent.chat(return_messages: true)` round runs; then the agent is logged (`log_agent`) and this run's delta is projected |
|
|
221
|
+
| a `Chat` / Array of messages | used as-is, roles preserved |
|
|
222
|
+
| a single `Hash` | wrapped as `[hash]` |
|
|
223
|
+
| a `String` / `Integer` / `nil` | not a chat: the projection fails with a `TypeError` and the job ends in `error` |
|
|
224
|
+
| `raise ScoutException` | rescued: the result is an assistant message holding `{exception: ..., job: <short_path>}` as JSON, job status `done` |
|
|
225
|
+
| any other `raise` | propagates; job status `error` (and `log_agent` never runs) |
|
|
226
|
+
|
|
227
|
+
### Idioms inside a chain
|
|
228
|
+
|
|
229
|
+
| Idiom | Code | Purpose |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| Follow a dependency's whole chat | `chat.follow step(:dep).load` | Append the dependency's projected chat result |
|
|
232
|
+
| Follow only its last message | `chat.follow step(:dep).load.last` | Just the final answer, not the tool traffic |
|
|
233
|
+
| Drop tools for a focused step | `chat.message :clear_tools, true` | Remove tool definitions from the step's context |
|
|
234
|
+
| Configurable worker agent | `options[:worker_agent] || 'Worker'` | Pick the agent at run time |
|
|
235
|
+
| Conditional dependency | `dep :search do |jobname,options| ... end` | Skip a stage on demand |
|
|
236
|
+
| Iterative refinement | `raise` + `retry` on your own exception class | Loop control inside a `chat_task` block (plain Ruby; `ScoutException` is special-cased by `chat_task`, so use a distinct class for retry) |
|
|
237
|
+
|
|
203
238
|
---
|
|
204
239
|
|
|
205
240
|
## Logging agent activity
|
|
206
241
|
|
|
207
|
-
|
|
208
|
-
|
|
242
|
+
The `agent` helper seeds the spawned agent's `start_chat` with the current
|
|
243
|
+
job's tooling (`tool:`, `kb:`, `mcp:`, `introduce:` roles). That extraction
|
|
244
|
+
is **destructive**: `Chat#remove_role` strips those roles out of the job's
|
|
245
|
+
own chat permanently. The memoized helper can only run once per task — a
|
|
246
|
+
second `agent` call in the same task finds no tooling left to extract. Use
|
|
247
|
+
`tooling_intro` (the non-destructive half, the `introduce:` messages only,
|
|
248
|
+
intended for specialists) when the job's chat must keep its roles, or pass
|
|
249
|
+
`tooling:` explicitly to override what is inherited.
|
|
250
|
+
|
|
251
|
+
When agents run inside workflow tasks, the seeded `start_chat` also receives
|
|
252
|
+
system notes about the working directory, the job path, the job's
|
|
253
|
+
dependencies and any other jobs found in the incoming chat; the incoming
|
|
254
|
+
`You have been assigned …` and those note prefixes are stripped before the
|
|
255
|
+
rest of the chat is followed in. (One of those prefixes relies on a
|
|
256
|
+
misspelled "depencencies" literal that the recycle filter matches — do not
|
|
257
|
+
"fix" the spelling in `lib/scout/llm/agent/workflow.rb` without updating the
|
|
258
|
+
filter.)
|
|
259
|
+
|
|
260
|
+
The agent's own conversation is saved to `<job>.files/<name>.chat` (the full
|
|
261
|
+
chat; `agent.chat` by default,
|
|
209
262
|
`worker.chat` for a `worker` agent), the job result keeps only
|
|
210
263
|
this run's delta, and delegated specialist conversations — when they exist —
|
|
211
264
|
are saved under `<job>.files/<name>.society/<agent_name>/<conversation>/…`.
|
|
@@ -230,11 +283,45 @@ Restart snapshots (`.files/resets/<timestamp>.chat`, taken by `agent.start`
|
|
|
230
283
|
when a prior non-empty chat existed) sit outside `log/` and are recovery
|
|
231
284
|
artifacts, not provenance logs.
|
|
232
285
|
|
|
286
|
+
Sibling state next to that chat file follows one convention: `<base>.society/`,
|
|
287
|
+
`<base>.inbox/`, `<base>.inbox_removed/` and the transient `<base>.jobs`
|
|
288
|
+
(trailing `.chat` stripped). Add `--live` to see the in-flight workflow
|
|
289
|
+
workload of an agent while it runs:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
scout-ai llm prov --live /path/to/saved.chat
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`chat_task` inputs are plain text parsed into a Chat, so they can declare
|
|
296
|
+
arbitrary tooling or run arbitrary code; that is why Scout-AI never exposes
|
|
297
|
+
chat_tasks directly — the security rationale and the mitigation are stated in
|
|
298
|
+
[Delegation.md](Delegation.md#chat_task-power-and-why-it-is-never-exposed-directly).
|
|
299
|
+
The five ways of asking, and what is visible live vs after the fact, are
|
|
300
|
+
tabulated in
|
|
301
|
+
[Delegation.md](Delegation.md#the-five-ways-of-asking-and-what-you-can-see).
|
|
302
|
+
|
|
233
303
|
See [../developer/Provenance.md](../developer/Provenance.md) for provenance
|
|
234
304
|
internals and [BuildingAgents.md](BuildingAgents.md) for save semantics.
|
|
235
305
|
|
|
236
306
|
---
|
|
237
307
|
|
|
308
|
+
### Composition idioms
|
|
309
|
+
|
|
310
|
+
Larger multi-agent systems compose from the vocabulary on this page. The
|
|
311
|
+
recurring shapes are: a **linear pipeline** of chained `chat_task`s
|
|
312
|
+
(request → search → plan → work → ask, each task's result appended into
|
|
313
|
+
the next agent's context with `chat.follow`); a **manager control loop**
|
|
314
|
+
(budgeted Search → Edit → Score → Select driven by the delegation `ask`
|
|
315
|
+
tool with named branch conversations); a **critic verification stage**
|
|
316
|
+
(JSON verdicts parsed with `Chat.parse_json` and stored with `set_info`,
|
|
317
|
+
the critic built with `no_ask_override: true` so it cannot delegate); a
|
|
318
|
+
**branched fan-out** (a splitter partitions the plan, then
|
|
319
|
+
`iterate_dictionary ... cpus: N` runs one isolated worker per branch over
|
|
320
|
+
`plan.dup`, with an aggregate critic over the reports); a **worker/critic
|
|
321
|
+
retry loop** (shared chat across rounds, `clear_tools` between rounds);
|
|
322
|
+
and a **two-phase prep pipeline** (an analyst agent reduces data into
|
|
323
|
+
artifacts that a worker consumes).
|
|
324
|
+
|
|
238
325
|
## Common mistakes
|
|
239
326
|
|
|
240
327
|
- **Trying to do everything in one giant chat**: Break work into tasks. Each
|
|
@@ -246,6 +333,9 @@ internals and [BuildingAgents.md](BuildingAgents.md) for save semantics.
|
|
|
246
333
|
- **Forgetting that tasks are cached**: If you change an agent's `start_chat`
|
|
247
334
|
but not the task input, you may get a cached result. Clear the cache or
|
|
248
335
|
change the input.
|
|
336
|
+
- **Calling `agent` twice in one task**: the tooling extraction behind it is
|
|
337
|
+
destructive and memoized, so the second call finds nothing left to extract —
|
|
338
|
+
pass `tooling:` explicitly instead.
|
|
249
339
|
|
|
250
340
|
---
|
|
251
341
|
|
data/doc/user/Python.md
CHANGED
|
@@ -7,6 +7,11 @@ keeping agent orchestration in Scout-AI.
|
|
|
7
7
|
**You should read this if:** you have Python code or libraries you want to
|
|
8
8
|
expose as agent tools.
|
|
9
9
|
|
|
10
|
+
**Scope note:** this page is about *tasks written in Python* that a Ruby
|
|
11
|
+
Scout-AI agent loads as tools. It is not about *driving Scout from Python*:
|
|
12
|
+
for the separate Python client that builds and runs agents from Python code
|
|
13
|
+
(`python/scout_ai/` in this repository), see `python/README.md`.
|
|
14
|
+
|
|
10
15
|
---
|
|
11
16
|
|
|
12
17
|
## The idea
|
|
@@ -39,6 +44,11 @@ No `workflow.rb` file is needed if Python tasks are sufficient.
|
|
|
39
44
|
|
|
40
45
|
Create a Python function with type hints and register it with `scout.task()`:
|
|
41
46
|
|
|
47
|
+
> `scout` here is the Python package that ships with the Scout toolchain
|
|
48
|
+
> (via the `scout-rig` gem), **not** something you install from this
|
|
49
|
+
> repository. It is already on the Python path when Scout runs your
|
|
50
|
+
> agent's Python tasks.
|
|
51
|
+
|
|
42
52
|
```python
|
|
43
53
|
# python/greet.py
|
|
44
54
|
import scout
|
|
@@ -71,7 +81,7 @@ Once the directory is set up, load the agent normally:
|
|
|
71
81
|
```ruby
|
|
72
82
|
require 'scout-ai'
|
|
73
83
|
|
|
74
|
-
agent = LLM
|
|
84
|
+
agent = LLM.load_agent('MyAgent', endpoint: :openai)
|
|
75
85
|
agent.start
|
|
76
86
|
agent.user 'Greet Alice using your tool'
|
|
77
87
|
puts agent.chat
|
|
@@ -21,35 +21,31 @@ same regardless of whether you're using OpenAI, Anthropic, or a local model.
|
|
|
21
21
|
|
|
22
22
|
## Configuring endpoints
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
There is no CLI command that writes endpoint configuration. Endpoints are
|
|
25
|
+
YAML files under `Scout.etc.AI` (by default `~/.scout/etc/AI/`), one file per
|
|
26
|
+
endpoint, named `<endpoint>.yaml`. Hand-write them:
|
|
25
27
|
|
|
26
|
-
```
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Anthropic
|
|
31
|
-
scout-ai config set anthropic provider=anthropic model=claude-sonnet-4-20250514
|
|
28
|
+
```yaml
|
|
29
|
+
# ~/.scout/etc/AI/anthropic.yaml
|
|
30
|
+
backend: anthropic
|
|
31
|
+
model: claude-sonnet-4-20250514
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
|
|
33
|
+
# ~/.scout/etc/AI/local.yaml
|
|
34
|
+
backend: ollama
|
|
35
|
+
model: qwen2.5:14b
|
|
36
|
+
url: http://localhost:11434/v1
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
The keys merge in as option defaults: `backend`, `url`, `key`, `model` are
|
|
40
|
+
recognized, and an explicit option still wins over the file. For one-off
|
|
41
|
+
configuration you can also pass `-ck key=value` to the CLI instead of
|
|
42
|
+
writing a file. `-ck` is Scout's global option (`--config_keys`): values are
|
|
43
|
+
comma-separated, and each one is either a `key=value` pair, a config file
|
|
44
|
+
path, or a named profile under `etc/config_profile/`.
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[local]
|
|
49
|
-
provider = ollama
|
|
50
|
-
model = qwen2.5:14b
|
|
51
|
-
url = http://localhost:11434/v1
|
|
52
|
-
```
|
|
46
|
+
Endpoint names are case-sensitive and must resolve to a real
|
|
47
|
+
`AI/<name>.yaml`; asking for a non-empty endpoint that has no file raises
|
|
48
|
+
`Endpoint not found <name>`.
|
|
53
49
|
|
|
54
50
|
---
|
|
55
51
|
|
|
@@ -97,36 +93,81 @@ Scout-AI supports several providers out of the box:
|
|
|
97
93
|
|
|
98
94
|
| Provider | Key | Notes |
|
|
99
95
|
|----------|-----|-------|
|
|
100
|
-
| OpenAI | `
|
|
101
|
-
|
|
|
96
|
+
| OpenAI (default) | `responses` | OpenAI **Responses** API; `gpt-5-nano` by default |
|
|
97
|
+
| OpenAI (chat) | `openai` | GPT models via Chat Completions |
|
|
98
|
+
| Anthropic | `anthropic` | Claude models |
|
|
102
99
|
| Ollama | `ollama` | Local models via Ollama API |
|
|
103
|
-
|
|
|
100
|
+
| vLLM | `vllm` | Responses-shaped, with vLLM tool-name unmangling |
|
|
101
|
+
| OpenWebUI | `openwebui` | OpenAI-compatible HTTP with bearer key |
|
|
102
|
+
| HuggingFace | `huggingface` | Inference endpoints |
|
|
103
|
+
| GLM | `glm` | Nested `image_url` image formatting |
|
|
104
|
+
| Bedrock | `bedrock` | Standalone loop (`LLM::Bedrock.ask`) |
|
|
105
|
+
| Relay | `relay` | scp round-trip to a remote `scout-ai` |
|
|
106
|
+
|
|
107
|
+
The full dispatch table is documented in
|
|
108
|
+
[../developer/Backends.md](../developer/Backends.md).
|
|
104
109
|
|
|
105
110
|
### Setting API keys
|
|
106
111
|
|
|
112
|
+
Scout-AI looks up `<TAG>_KEY` — `OPENAI_KEY`, `ANTHROPIC_KEY`, and so on for
|
|
113
|
+
the backend's `TAG` (`ANTHROPIC_API_KEY` is *not* one of them):
|
|
114
|
+
|
|
107
115
|
```bash
|
|
108
|
-
export
|
|
109
|
-
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
116
|
+
export ANTHROPIC_KEY="sk-ant-..."
|
|
110
117
|
```
|
|
111
118
|
|
|
112
|
-
|
|
119
|
+
A `key:` entry in the endpoint YAML, or `-ck key=...`, works as well. Local
|
|
120
|
+
models (Ollama, vLLM) usually need no key.
|
|
113
121
|
|
|
114
122
|
---
|
|
115
123
|
|
|
124
|
+
## Bypassing processing for a daemon (`process:`)
|
|
125
|
+
|
|
126
|
+
`LLM.ask` accepts a `process:` option (a String). When set, the raw provider
|
|
127
|
+
response JSON is written to `Scout.var.query.response[<process>].json` and
|
|
128
|
+
returned **immediately, unprocessed** — no parsing, no tool loop, no meta.
|
|
129
|
+
This is the mechanism behind the `llm process_queries` daemon (it polls
|
|
130
|
+
`Scout.var.query` for request files and calls
|
|
131
|
+
`LLM.ask(messages, options.merge(process: id))`); the sibling
|
|
132
|
+
`llm process` daemon serves the same role for `Scout.var.ask` files by
|
|
133
|
+
calling plain `LLM.ask` and writing the reply file itself.
|
|
134
|
+
|
|
116
135
|
## Caching
|
|
117
136
|
|
|
118
|
-
By default,
|
|
137
|
+
By default, `LLM.ask` wraps every round in a `Persist` cache keyed on the
|
|
138
|
+
endpoint, the whole options hash, and the message list. Asking the same
|
|
139
|
+
question with the same options twice replays the cached answer; the flip side
|
|
140
|
+
is that any option change (`model`, `tools`, …) changes the key and forces a
|
|
141
|
+
re-query. To bypass the cache for a specific call, set `persist: false`
|
|
142
|
+
(`agent.option :persist, false`), which is the only way to force a re-run of
|
|
143
|
+
an identical question — the cache key includes the options hash, but not that
|
|
144
|
+
flag.
|
|
145
|
+
|
|
146
|
+
---
|
|
119
147
|
|
|
120
|
-
|
|
121
|
-
- Workflow jobs that produce the same chat are not re-run.
|
|
122
|
-
- You can reproduce results deterministically.
|
|
148
|
+
## Request context for workflow tasks
|
|
123
149
|
|
|
124
|
-
|
|
150
|
+
`LLM.ask` accepts an optional `request_context:` hash for non-provider metadata
|
|
151
|
+
that should follow a request into workflow tasks invoked as tools. Scout projects
|
|
152
|
+
the hash to JSON-safe fields, filters credential-like or otherwise unsafe
|
|
153
|
+
values, and records it in the task Step's `.info` metadata; it is not added to
|
|
154
|
+
the task's declared inputs and therefore does not change the workflow task's
|
|
155
|
+
input identity. Within a task body it is available as `request_context`:
|
|
125
156
|
|
|
126
157
|
```ruby
|
|
127
|
-
|
|
158
|
+
LLM.ask(question,
|
|
159
|
+
request_context: {request_id: 'req-123', source: 'my-app'},
|
|
160
|
+
tools: workflow_tools,
|
|
161
|
+
persist: false)
|
|
162
|
+
|
|
163
|
+
# In a workflow task body:
|
|
164
|
+
request_context # => {request_id: "req-123", source: "my-app", ...}
|
|
128
165
|
```
|
|
129
166
|
|
|
167
|
+
Use only non-sensitive descriptive metadata. Provider credentials, clients,
|
|
168
|
+
messages, and other unsafe fields are excluded. Context is persisted as Step
|
|
169
|
+
metadata for provenance and task access, not sent as a provider prompt field.
|
|
170
|
+
|
|
130
171
|
---
|
|
131
172
|
|
|
132
173
|
## Choosing the right model
|
|
@@ -144,6 +185,11 @@ The model is configured per-endpoint but can be overridden per-call:
|
|
|
144
185
|
scout-ai llm ask -e openai -m gpt-4o-mini "Quick question"
|
|
145
186
|
```
|
|
146
187
|
|
|
188
|
+
> **Model is not isolated per provider.** The `model` config key is read
|
|
189
|
+
> through a single shared token, so a `model` set at the config level leaks
|
|
190
|
+
> into the default model of every backend. Pin `model:` inside each endpoint
|
|
191
|
+
> YAML to isolate providers from each other.
|
|
192
|
+
|
|
147
193
|
---
|
|
148
194
|
|
|
149
195
|
## The inference flow
|
|
@@ -160,7 +206,7 @@ When you call `agent.chat` or `scout-ai llm ask`, Scout-AI:
|
|
|
160
206
|
This is all automatic. You configure the endpoint and model; Scout-AI handles
|
|
161
207
|
the rest.
|
|
162
208
|
|
|
163
|
-
Persistence, however, differs
|
|
209
|
+
Persistence, however, differs slightly between the two CLIs:
|
|
164
210
|
|
|
165
211
|
- `scout-ai agent ask ... -c <chat>` sets the agent's `save_file` to
|
|
166
212
|
`<chat>.files/<name>.chat` (`agent.chat` by default; a named agent writes
|
|
@@ -168,14 +214,11 @@ Persistence, however, differs slighly between the two CLIs:
|
|
|
168
214
|
auto-save hook fires), and also appends the new messages to `<chat>`
|
|
169
215
|
itself — a dual write. The `agent.chat` should contain also the agent
|
|
170
216
|
instructions. Delegated society conversations, when they exist, are written
|
|
171
|
-
under `<chat>.files/<name>.society/<agent>/<conversation>/agent.chat
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
internally, but `LLM.ask` currently extracts that option and drops it
|
|
177
|
-
without applying it, unless an agent is defined inside the chat, in which
|
|
178
|
-
case that agent will get configured with the `save_file`.
|
|
217
|
+
under `<chat>.files/<name>.society/<agent>/<conversation>/agent.chat`.
|
|
218
|
+
- `scout-ai llm ask ... -c <chat>` computes an `agent_save_file` for the chat
|
|
219
|
+
and passes it to `LLM.ask`, but it is only applied when the chat also
|
|
220
|
+
declares an `agent` (the `agent:` role); otherwise the option is extracted
|
|
221
|
+
and dropped, so nothing is saved.
|
|
179
222
|
|
|
180
223
|
---
|
|
181
224
|
|
|
@@ -185,8 +228,8 @@ Persistence, however, differs slighly between the two CLIs:
|
|
|
185
228
|
environment variable matches your provider.
|
|
186
229
|
- **Using the wrong endpoint name**: Endpoint names are case-sensitive and must
|
|
187
230
|
match your config.
|
|
188
|
-
- **Expecting streaming
|
|
189
|
-
|
|
231
|
+
- **Expecting streaming**: there is no streaming path at all — requests are
|
|
232
|
+
blocking and return once complete.
|
|
190
233
|
- **Not realizing caching is on**: If you're not seeing new responses to the
|
|
191
234
|
same question, it may be cached. Use `persist: false` to bypass.
|
|
192
235
|
|