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
data/doc/user/Delegation.md
CHANGED
|
@@ -34,15 +34,32 @@ receives:
|
|
|
34
34
|
| Mode | What the specialist gets | Use case |
|
|
35
35
|
|------|------------------------|----------|
|
|
36
36
|
| **`none`** | Only its own system prompt | Fully isolated sub-agent |
|
|
37
|
-
| **`tools`** *(default)* | Its own prompt + the caller's
|
|
37
|
+
| **`tools`** *(default)* | Its own prompt + the tooling of the caller's whole current chat — including tooling added mid-conversation — but not its history | Same capabilities, private history |
|
|
38
38
|
| **`conversation`** | Its own prompt + the caller's entire current conversation | Deep collaboration with shared context |
|
|
39
|
+
| **`clear_tools`** | Like `conversation` when the conversation is created; when **continuing** an existing conversation, it additionally drops the earlier tool-call traces (`function_call`/`function_call_output`) from the context sent to the model | Long delegated conversations whose accumulated tool output is bloating context |
|
|
39
40
|
|
|
40
41
|
The specialist always gets **its own** system prompt first. Inherited context
|
|
41
42
|
is appended after.
|
|
42
43
|
|
|
43
|
-
> **Important:** The inheritance mode
|
|
44
|
-
> created
|
|
45
|
-
> history regardless of the mode
|
|
44
|
+
> **Important:** The inheritance mode decides what the specialist receives
|
|
45
|
+
> only when a conversation is first created; subsequent turns in the same
|
|
46
|
+
> conversation reuse the accumulated history regardless of the mode — with
|
|
47
|
+
> one exception: `clear_tools` is a *continuation-time* policy. When you
|
|
48
|
+
> continue an existing conversation with `inherit: 'clear_tools'`, a
|
|
49
|
+
> `clear_tools` marker is appended immediately before your new prompt, and
|
|
50
|
+
> the model context for that round is compiled without the conversation's
|
|
51
|
+
> earlier tool-call traces. Repeated continuations append one marker each;
|
|
52
|
+
> they are equivalent to a single one.
|
|
53
|
+
|
|
54
|
+
The `clear_tools` fallback and its guarantee:
|
|
55
|
+
|
|
56
|
+
- **First creation (and `restart: true`) falls back to plain `conversation`
|
|
57
|
+
seeding** — there are no earlier bouts of that conversation to clear yet,
|
|
58
|
+
so no marker is appended; one low-severity log line records the fallback.
|
|
59
|
+
- **Clearing is context-only.** Nothing is removed from the stored chat, the
|
|
60
|
+
logs, or provenance records: the specialist's saved conversation keeps
|
|
61
|
+
every tool call and output, and only the context sent to the model drops
|
|
62
|
+
them. The marker itself stays in the stored chat too.
|
|
46
63
|
|
|
47
64
|
---
|
|
48
65
|
|
|
@@ -70,7 +87,7 @@ The model sees a tool with these parameters:
|
|
|
70
87
|
| `agent` | Yes | Name of the specialist agent |
|
|
71
88
|
| `prompt` | Yes | Plain-text prompt for the specialist |
|
|
72
89
|
| `conversation` | No | Named conversation. Omit for one-shot; reuse to continue |
|
|
73
|
-
| `inherit` | No (default `tools`) | Context policy
|
|
90
|
+
| `inherit` | No (default `tools`) | Context policy: `none`, `tools`, `conversation`, or `clear_tools` (like `conversation` at creation; on continuation drops earlier tool-call traces from the model context only) |
|
|
74
91
|
|
|
75
92
|
### Conversation persistence
|
|
76
93
|
|
|
@@ -83,27 +100,148 @@ Call 2: ask(agent="Worker", prompt="Now do Y", conversation="task_1")
|
|
|
83
100
|
# Worker remembers the full conversation from task_1
|
|
84
101
|
```
|
|
85
102
|
|
|
86
|
-
Without a `conversation` name,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
Without a `conversation` name, the call is routed to the specialist's
|
|
104
|
+
`default` conversation slot: successive anonymous calls to the same agent
|
|
105
|
+
therefore land in one shared, accumulating conversation, not in fresh
|
|
106
|
+
per-call chats. Use distinct `conversation` names whenever you want
|
|
107
|
+
isolation between calls.
|
|
108
|
+
|
|
109
|
+
Each delegated call leaves provenance evidence in the parent chat: a receipt
|
|
110
|
+
of the specialist's run (including its token usage) is attached to the tool
|
|
111
|
+
answer, so token costs can be traced afterwards with
|
|
112
|
+
`scout-ai llm prov --evidence`. Receipts are embedded provenance, not extra
|
|
113
|
+
messages in your conversation. See the
|
|
92
114
|
[developer provenance guide](../developer/Provenance.md) for details.
|
|
93
115
|
|
|
94
116
|
---
|
|
95
117
|
|
|
118
|
+
## One delegation per conversation per batch
|
|
119
|
+
|
|
120
|
+
The model may issue several tool calls in one round; the delegations among
|
|
121
|
+
them are dispatched **in parallel**. A specialist conversation is one
|
|
122
|
+
persisted save file, so two delegations of the same round that target the
|
|
123
|
+
same conversation would both drive (and auto-save) it at the same time.
|
|
124
|
+
Scout-AI used to block forever in that situation.
|
|
125
|
+
|
|
126
|
+
Now the delegation batch is rejected **before any specialist is asked**: the
|
|
127
|
+
parallel execution layer checks the pending delegations and every delegation of
|
|
128
|
+
that round returns an **error result** — a `function_call_output` with the
|
|
129
|
+
`error` flag and a `ScoutException` message naming the conflicting save file.
|
|
130
|
+
The batch is invalid as a whole, so **all** delegations of the round are
|
|
131
|
+
rejected together, not only the two that collide. The model receives the errors
|
|
132
|
+
as ordinary tool outputs and can rethink the plan; a corrected round (for
|
|
133
|
+
instance one delegation per conversation) then runs normally, and the rejected
|
|
134
|
+
prompts leave no residue in the conversations.
|
|
135
|
+
|
|
136
|
+
Other tool calls of the same round keep their real results — a file written by
|
|
137
|
+
an earlier call stays written, and its successful output is returned. The
|
|
138
|
+
failure belongs to the delegation batch, not to the round.
|
|
139
|
+
|
|
140
|
+
Two ways to hit it:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
# Same round, same agent, no conversation name: both land on 'default'
|
|
144
|
+
ask(agent="Worker", prompt="Do X")
|
|
145
|
+
ask(agent="Worker", prompt="Do Y")
|
|
146
|
+
|
|
147
|
+
# Same round, same agent, same explicit name
|
|
148
|
+
ask(agent="Worker", prompt="Do X", conversation="task_1")
|
|
149
|
+
ask(agent="Worker", prompt="Do Y", conversation="task_1")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
To fix the plan, give each delegation of a round its own conversation name
|
|
153
|
+
— two delegations that omit the name share the `default` conversation and
|
|
154
|
+
conflict as well — or spread the turns over several rounds so each
|
|
155
|
+
conversation is advanced by one delegation at a time. Sequential turns on
|
|
156
|
+
the same conversation across different rounds remain perfectly legal.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Two views: the official conversation and the agent view
|
|
161
|
+
|
|
162
|
+
When you run inference there are two distinct records, and provenance tools
|
|
163
|
+
navigate both:
|
|
164
|
+
|
|
165
|
+
- **The official conversation** — the main chat plus the answers of delegated
|
|
166
|
+
`chat_task` jobs projected into it. This is *the* conversation: what the
|
|
167
|
+
answer is, who said what, in what order.
|
|
168
|
+
- **The agent view** — each agent's own save_file plus the state Scout-AI
|
|
169
|
+
keeps next to it: society logs of delegated conversations, the inbox, restart
|
|
170
|
+
snapshots, and the transient in-flight workload file. This is the working
|
|
171
|
+
record of *how* each agent produced its part.
|
|
172
|
+
|
|
173
|
+
## The five ways of asking, and what you can see
|
|
174
|
+
|
|
175
|
+
| # | Way of asking | While it runs (live) | After it ends (forensic) |
|
|
176
|
+
|---|---|---|---|
|
|
177
|
+
| 1 | Plain `LLM.ask` / endpoint call (no agent) | the save_file is written **inside** the ask stacks, so persisted state appears mid-run | persisted chat with token metas |
|
|
178
|
+
| 2 | A normal agent ask | `<base>.chat` grows after each completed round; `<base>.inbox` is honoured; `<base>.jobs` appears while its own workflow tools produce | save_file transcript plus `step:`/`job=` receipts |
|
|
179
|
+
| 3 | An `ask` **chat_task** (workflow answering for the agent) | the `job=` meta line lands in the agent's current chat and is saved **before** the task completes | the `job=` meta in the agent save_file; the answer projected into the conversation |
|
|
180
|
+
| 4 | Delegation through `ask`/`hand_off_to_*` | the delegated conversation `<owner>.files/<name>.society/<Agent>/<conversation>/agent.chat` grows round by round; its sibling inbox is honoured | receipts under the `meta` key of the parent's `function_call_output` |
|
|
181
|
+
| 5 | A tool call that runs a workflow job | `<base>.jobs` lists the in-flight job while `Workflow.produce` blocks | `function_call_output` JSON with exactly `{meta, content}` plus the `step:` short path |
|
|
182
|
+
|
|
183
|
+
`scout-ai llm prov --live <chat>` renders the live half. Everything else
|
|
184
|
+
the command shows is forensic (concluded work).
|
|
185
|
+
|
|
186
|
+
### Watching live work with `--live`
|
|
187
|
+
|
|
188
|
+
While a run is in flight, `scout-ai llm prov --live <chat>` appends a
|
|
189
|
+
`Live work` section after the normal report. Each line names one piece of
|
|
190
|
+
actually-running work, in plain language:
|
|
191
|
+
|
|
192
|
+
- **`chat_task`** — an inference job that is running right now (the running
|
|
193
|
+
chat task of the delegation, including the dependency behind a wrapper
|
|
194
|
+
tool call such as a workspace `continue`); its agent log path is shown.
|
|
195
|
+
- **`agent_active`** — an agent mid-turn (prompt dispatched, tool round in
|
|
196
|
+
flight, or next round pending), named by its save file.
|
|
197
|
+
- **`dangling_job`** — a specialist agent whose `job=` reference is on disk
|
|
198
|
+
while the job behind it still runs.
|
|
199
|
+
- **`workflow`** — other in-flight workflow jobs: non-chat work, or a
|
|
200
|
+
waiting wrapper whose dependency is the running `chat_task` line above.
|
|
201
|
+
|
|
202
|
+
Work the normal report already shows is not repeated, and when nothing is in
|
|
203
|
+
flight the section disappears entirely: a quiet `--live` run prints exactly
|
|
204
|
+
what plain `prov` prints. Two things to keep in mind:
|
|
205
|
+
|
|
206
|
+
- a just-finished round may not yet show as active — the save file is
|
|
207
|
+
rewritten at round boundaries, so there is a brief instant where a running
|
|
208
|
+
agent looks idle (never the reverse); and
|
|
209
|
+
- run the command from the same working directory as the run you are
|
|
210
|
+
watching, because the in-flight job references resolve against the
|
|
211
|
+
`var/jobs` tree of the current directory.
|
|
212
|
+
|
|
213
|
+
## `chat_task` power, and why it is never exposed directly
|
|
214
|
+
|
|
215
|
+
A `chat_task` input is text that gets parsed into a Chat — and a Chat can
|
|
216
|
+
declare arbitrary tooling or execute arbitrary code. That makes chat_tasks
|
|
217
|
+
extremely powerful and completely unsafe to hand to an untrusted model as a
|
|
218
|
+
raw input. For that reason Scout-AI never exposes chat_tasks directly:
|
|
219
|
+
higher layers (for example the Cortex workspace) expose them through
|
|
220
|
+
prompt-only interfaces that append to conversations the agent has limited or
|
|
221
|
+
indirect control over.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
96
225
|
## Named hand-off tools (delegate)
|
|
97
226
|
|
|
98
227
|
`delegate` creates a specific tool for a pre-loaded agent:
|
|
99
228
|
|
|
100
229
|
```ruby
|
|
101
230
|
worker = LLM.load_agent('Worker')
|
|
102
|
-
agent.delegate(worker,
|
|
231
|
+
agent.delegate(worker, 'Worker', "Delegate work to the Worker agent")
|
|
103
232
|
```
|
|
104
233
|
|
|
105
|
-
This creates a tool called `
|
|
106
|
-
`message` parameter.
|
|
234
|
+
This creates a tool called `hand_off_to_Worker`. The model calls it with a
|
|
235
|
+
`message` parameter. The tool asks the conversation named after the slot
|
|
236
|
+
(`Worker/Worker` — the registration case is kept, nothing lower-cases it).
|
|
237
|
+
|
|
238
|
+
Without a custom block, the hand-off runs on the shared conversation
|
|
239
|
+
pipeline: the registered conversation is a clone of the passed agent,
|
|
240
|
+
persisting under `<save>.society/<agent>/<conversation>/agent.chat`, and the
|
|
241
|
+
passed agent object itself does not accumulate the conversation. Reuse the
|
|
242
|
+
tool to continue that conversation (`new_conversation: true` re-branches it);
|
|
243
|
+
reach the live conversation agent from Ruby with
|
|
244
|
+
`conversation_agent("Worker/Worker")`.
|
|
107
245
|
|
|
108
246
|
### Custom delegation blocks
|
|
109
247
|
|
|
@@ -178,7 +316,17 @@ The model can now delegate sub-tasks to any specialist by name.
|
|
|
178
316
|
model has no tool to delegate with.
|
|
179
317
|
- **Expecting specialists to share the orchestrator's tools by default**: Only
|
|
180
318
|
if `inherit` is `tools` or `conversation`. With `none`, specialists are
|
|
181
|
-
isolated.
|
|
319
|
+
isolated. (`clear_tools` seeds like `conversation`, so it shares context the
|
|
320
|
+
same way at creation.)
|
|
321
|
+
- **Expecting `clear_tools` to trim the stored conversation**: it never does.
|
|
322
|
+
Clearing is context-only — the saved chat, logs, and provenance keep every
|
|
323
|
+
tool call.
|
|
324
|
+
- **Two delegations of one round onto one conversation**: the whole delegation
|
|
325
|
+
batch is rejected, and every delegation of that round returns an error result
|
|
326
|
+
naming the shared save file; no specialist is asked. Other tool calls of the
|
|
327
|
+
round keep their results. Give each delegation its own conversation name, or
|
|
328
|
+
spread the turns over several rounds (see
|
|
329
|
+
[One delegation per conversation per batch](#one-delegation-per-conversation-per-batch)).
|
|
182
330
|
- **Using `conversation: 'current'`**: This is a legacy value. Use explicit
|
|
183
331
|
conversation names or omit the parameter.
|
|
184
332
|
|
|
@@ -189,3 +337,6 @@ The model can now delegate sub-tasks to any specialist by name.
|
|
|
189
337
|
- [MultiAgentWorkflows.md](MultiAgentWorkflows.md) — orchestration patterns.
|
|
190
338
|
- [BuildingAgents.md](BuildingAgents.md) — creating agents.
|
|
191
339
|
- [ManagingContext.md](ManagingContext.md) — how delegation affects context.
|
|
340
|
+
- [../developer/DelegationInternals.md](../developer/DelegationInternals.md) —
|
|
341
|
+
the implementation, including the known drift in what `inherit: 'tools'`
|
|
342
|
+
copies.
|
data/doc/user/GettingStarted.md
CHANGED
|
@@ -48,28 +48,30 @@ bundle install
|
|
|
48
48
|
### Set your API key
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
#
|
|
52
|
-
export OPENAI_API_KEY="sk-..."
|
|
53
|
-
|
|
54
|
-
# For Anthropic
|
|
55
|
-
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
51
|
+
export ANTHROPIC_KEY="sk-ant-..." # or OPENAI_KEY, GLM_KEY, ...
|
|
56
52
|
```
|
|
57
53
|
|
|
54
|
+
(Or put `key:` in the endpoint YAML below.)
|
|
55
|
+
|
|
58
56
|
---
|
|
59
57
|
|
|
60
58
|
## Configure your first endpoint
|
|
61
59
|
|
|
62
|
-
An **endpoint** is a named configuration for a provider + model.
|
|
63
|
-
|
|
60
|
+
An **endpoint** is a named configuration for a provider + model. There is no
|
|
61
|
+
CLI command for this: endpoints are YAML files under `~/.scout/etc/AI/`, one
|
|
62
|
+
per endpoint, that you write by hand.
|
|
64
63
|
|
|
65
|
-
```
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#
|
|
70
|
-
scout-ai config set anthropic provider=anthropic model=claude-sonnet-4-20250514
|
|
64
|
+
```yaml
|
|
65
|
+
# ~/.scout/etc/AI/anthropic.yaml
|
|
66
|
+
backend: anthropic
|
|
67
|
+
model: claude-sonnet-4-20250514
|
|
68
|
+
key: sk-ant-... # optional; ANTHROPIC_KEY is read when absent
|
|
71
69
|
```
|
|
72
70
|
|
|
71
|
+
[RunningInference.md](RunningInference.md) is the canonical endpoint
|
|
72
|
+
reference: full key set (`backend`, `url`, `key`, `model`), the `-ck` option,
|
|
73
|
+
and the provider table.
|
|
74
|
+
|
|
73
75
|
---
|
|
74
76
|
|
|
75
77
|
## Your first conversation
|
|
@@ -114,13 +116,15 @@ scout-ai llm ask -c hello.chat
|
|
|
114
116
|
|
|
115
117
|
## Your first agent
|
|
116
118
|
|
|
117
|
-
Agents are **named directories**. Create one
|
|
119
|
+
Agents are **named directories**. Create one under `~/.scout/chats/Agent/`
|
|
120
|
+
(the location `LLM.load_agent` and `scout-ai agent` look up regardless of
|
|
121
|
+
your current directory):
|
|
118
122
|
|
|
119
123
|
```bash
|
|
120
|
-
mkdir -p
|
|
124
|
+
mkdir -p ~/.scout/chats/Agent/Greeter
|
|
121
125
|
```
|
|
122
126
|
|
|
123
|
-
Create
|
|
127
|
+
Create `~/.scout/chats/Agent/Greeter/start_chat`:
|
|
124
128
|
|
|
125
129
|
```text
|
|
126
130
|
system:
|
data/doc/user/ManagingContext.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Managing Context
|
|
2
2
|
|
|
3
3
|
This page explains how Scout-AI handles conversations that grow too long for
|
|
4
|
-
the model's context window, and what you can do to control this behavior. It
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
the model's context window, and what you can do to control this behavior. It is
|
|
5
|
+
intended for workflow authors building long-running agents or workflows with
|
|
6
|
+
many tool calls.
|
|
7
7
|
|
|
8
8
|
**You should read this if:** your agents make many tool calls, use large files,
|
|
9
9
|
or run for many turns.
|
|
@@ -30,22 +30,130 @@ Scout-AI applies **prompt strategies** — transformations to the conversation
|
|
|
30
30
|
just before sending it to the model. These are **ephemeral**: they modify only
|
|
31
31
|
what the model sees, never the saved chat file.
|
|
32
32
|
|
|
33
|
-
The
|
|
34
|
-
|
|
33
|
+
The default strategy list is `['epoch_tool_compactation', 'inbox']`: a
|
|
34
|
+
tool-call compaction strategy with stable epoch boundaries (so provider
|
|
35
|
+
prompt caches stay useful), plus the one-off inbox described below. When tool
|
|
36
|
+
calls accumulate, oversized older ones are removed entirely and replaced by
|
|
37
|
+
short metadata records, while the recent ones stay whole:
|
|
35
38
|
|
|
36
39
|
| Threshold | Default | What happens |
|
|
37
40
|
|-----------|---------|-------------|
|
|
38
|
-
|
|
|
39
|
-
| Recent tool
|
|
40
|
-
|
|
|
41
|
+
| Tool-call threshold | 50 | At or below this total, nothing is compacted |
|
|
42
|
+
| Recent tool calls kept full | 20 | The newest calls stay at full fidelity |
|
|
43
|
+
| Compacted tool calls | 80 | Oversized calls before the full-recent window are replaced by metadata records |
|
|
41
44
|
|
|
42
45
|
This means:
|
|
43
46
|
- The most recent tool calls are always visible in full.
|
|
44
|
-
-
|
|
45
|
-
|
|
47
|
+
- An older tool interaction is oversized when its output is longer than 400
|
|
48
|
+
characters or one of its arguments is longer than 200; then **both its
|
|
49
|
+
messages are removed** and one **metadata record** takes their place: the
|
|
50
|
+
tool name, the call id, the original sizes, the identifying arguments, and a
|
|
51
|
+
pointer to the job that holds the full output when there is one. The record
|
|
52
|
+
is explicitly *not* a tool result and never contains a preview or a
|
|
53
|
+
truncated command — argument values appear either in full or as
|
|
54
|
+
`<omitted, N chars>`.
|
|
55
|
+
- Interactions older than the compacted window disappear without a record;
|
|
56
|
+
sub-threshold ones are kept byte-for-byte.
|
|
57
|
+
- A fixed notice at the top of the prompt warns the model that historical tool
|
|
58
|
+
interactions may be omitted and that compaction records are metadata, not
|
|
59
|
+
tool results. If a value from a removed interaction is needed, the model
|
|
60
|
+
must run the tool again.
|
|
61
|
+
- The boundary only advances in **epochs**, so the same prefix is sent again
|
|
62
|
+
and provider prompt caches stay valid.
|
|
46
63
|
|
|
47
64
|
The model never sees a truncated prompt — it simply gets a shorter conversation
|
|
48
|
-
that fits within its context window.
|
|
65
|
+
that fits within its context window. The exact configuration keys and the
|
|
66
|
+
(non-default) `shorten_tools` limits are tabulated in
|
|
67
|
+
[../developer/PromptProcessing.md](../developer/PromptProcessing.md).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## The `inbox` strategy: injecting one-off notices
|
|
72
|
+
|
|
73
|
+
Sometimes an external process (a workflow step, a cron job, a human dropping
|
|
74
|
+
a file) needs to hand the agent a message without going through the chat file.
|
|
75
|
+
The **inbox strategy** does that: on each inference it consumes the files in the
|
|
76
|
+
chat's inbox directory and injects them as one-off user messages.
|
|
77
|
+
|
|
78
|
+
The strategy is **on by default**: `inbox` is part of
|
|
79
|
+
`DEFAULT_CONTEXT_STRATEGY`, so every chat that passes a `save_file` gets it.
|
|
80
|
+
You only need to set `prompt_strategies` to *extend* the default list (a
|
|
81
|
+
user-supplied list **replaces** the default rather than appending to it) or to
|
|
82
|
+
reorder it:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
option prompt_strategies inbox,epoch_tool_compactation
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
or programmatically:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
options[:prompt_strategies] = 'inbox,epoch_tool_compactation'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
To turn it off, set `prompt_strategies` to a list without `inbox` (the string
|
|
95
|
+
`none` is the recognized no-op that disables every strategy). To go back to the
|
|
96
|
+
previous shortening behavior, select the old strategy explicitly —
|
|
97
|
+
`option prompt_strategies shorten_tools_epoch_increment,inbox` (a user-supplied
|
|
98
|
+
list replaces the default).
|
|
99
|
+
|
|
100
|
+
### Where the inbox lives
|
|
101
|
+
|
|
102
|
+
The inbox is a **sibling of the chat's `save_file`**, in the save_file's own
|
|
103
|
+
directory: take the save_file basename, strip its **last** extension if it has
|
|
104
|
+
one (an extension-less basename keeps the whole name), and append `.inbox`.
|
|
105
|
+
The log of delivered files is the same derivation with `.inbox_removed`:
|
|
106
|
+
|
|
107
|
+
| Context | save_file | Inbox | Removed log |
|
|
108
|
+
|---|---|---|---|
|
|
109
|
+
| `scout agent ask -c <chat>` | `<chat>.files/<agent>.chat` | `<chat>.files/<agent>.inbox` | `<chat>.files/<agent>.inbox_removed` |
|
|
110
|
+
| Agent workflow (`chat_task`) job | `<job>.files/<name>.chat` | `<job>.files/<name>.inbox` | `<job>.files/<name>.inbox_removed` |
|
|
111
|
+
|
|
112
|
+
A multi-dot save_file strips only the last extension (`a.b.chat` ->
|
|
113
|
+
`a.b.inbox`); an extension-less save_file keeps its whole name (`agent` ->
|
|
114
|
+
`agent.inbox`).
|
|
115
|
+
|
|
116
|
+
- Drop a regular file (any name, any extension) into the inbox directory.
|
|
117
|
+
Files are delivered in **sorted filename order**, so name them
|
|
118
|
+
(`001-first.md`, `002-second.md`) if order matters.
|
|
119
|
+
- On each inference the file is **moved** to the `.inbox_removed` sibling
|
|
120
|
+
(original modification time preserved; a name collision gets a numeric
|
|
121
|
+
suffix), and its content is appended to the prompt as a `user`-role
|
|
122
|
+
message.
|
|
123
|
+
- Write files elsewhere and rename them into the inbox if you want to be sure
|
|
124
|
+
the agent never reads a half-written file.
|
|
125
|
+
|
|
126
|
+
### Reserved filename: `abort`
|
|
127
|
+
|
|
128
|
+
One filename is special: a file named exactly `abort` (no extension,
|
|
129
|
+
case-sensitive). When the pickup reaches it, the file is consumed like any
|
|
130
|
+
other (moved to `.inbox_removed`, never delivered again) but its content is
|
|
131
|
+
**not** sent to the model: the inference is aborted instead, with the file
|
|
132
|
+
content as the abort reason. The job ends up marked as interrupted/aborted
|
|
133
|
+
rather than failing with an ordinary error.
|
|
134
|
+
|
|
135
|
+
Use it to stop a running agent from outside: `touch <inbox>/abort` for a
|
|
136
|
+
plain abort, or write a short reason into the file (`stop, budget exhausted`)
|
|
137
|
+
to have it recorded in the job's abort message.
|
|
138
|
+
|
|
139
|
+
Files that sort before `abort` are consumed in that same run (and not
|
|
140
|
+
delivered again); files sorting after it stay in the inbox for the next
|
|
141
|
+
inference. No other filename is special: `abort.txt` or `Abort` are ordinary
|
|
142
|
+
messages.
|
|
143
|
+
|
|
144
|
+
### What it does NOT do
|
|
145
|
+
|
|
146
|
+
- **Injected messages are not persisted.** The model sees them, but the saved
|
|
147
|
+
chat file does not record them; the `.inbox_removed` sibling is the log of
|
|
148
|
+
what was delivered.
|
|
149
|
+
- **Delivery is at-most-once.** The file is moved before the message is built,
|
|
150
|
+
so an interrupted inference may drop a notice but never delivers the same
|
|
151
|
+
notice twice.
|
|
152
|
+
- **A cached answer skips the inbox.** When a cached answer is replayed, no
|
|
153
|
+
inference runs, so inbox files are left untouched for the next real
|
|
154
|
+
inference (see [RunningInference.md](RunningInference.md) on the ask cache).
|
|
155
|
+
- **No inbox, no effect.** If the inbox directory does not exist, the strategy
|
|
156
|
+
is a no-op and creates nothing.
|
|
49
157
|
|
|
50
158
|
---
|
|
51
159
|
|
|
@@ -69,6 +177,27 @@ This is useful when:
|
|
|
69
177
|
`clear:` is also ephemeral — it affects what the model sees but does not delete
|
|
70
178
|
the messages from the saved chat file.
|
|
71
179
|
|
|
180
|
+
Two related directives are honoured inside the `clear:` scan, which walks the
|
|
181
|
+
chat backwards and stops at the last `clear:`:
|
|
182
|
+
|
|
183
|
+
- `clear_tools:` — drops `function_call` / `function_call_output` pairs from
|
|
184
|
+
that point forward as well (`clear_tools: false` keeps them; dropping tool
|
|
185
|
+
calls is the default behaviour of the scan).
|
|
186
|
+
- `clear_role: <role>` (alias `clean_role:`) — after the cut, removes every
|
|
187
|
+
message of the named role from what survives.
|
|
188
|
+
|
|
189
|
+
The `clear_tools:` directive is what backs the `clear_tools` delegation
|
|
190
|
+
inheritance mode: continuing an existing delegated conversation with
|
|
191
|
+
`inherit: 'clear_tools'` appends this same marker before your new prompt, so
|
|
192
|
+
the model context drops the conversation's earlier tool-call traces while the
|
|
193
|
+
stored chat keeps them. See
|
|
194
|
+
[Delegation.md](Delegation.md) (inheritance modes) for the mode's creation
|
|
195
|
+
fallback and its context-only guarantee.
|
|
196
|
+
|
|
197
|
+
`import:` has two narrower siblings worth knowing: `continue:` imports only
|
|
198
|
+
the last non-empty message of the referenced chat, and `last:` imports its
|
|
199
|
+
last message after purging `previous_response_id` messages.
|
|
200
|
+
|
|
72
201
|
---
|
|
73
202
|
|
|
74
203
|
## Tips for keeping context manageable
|
|
@@ -93,7 +222,7 @@ If you're not sure whether data will be needed, declare it as a tool instead of
|
|
|
93
222
|
importing it. The model will fetch it only if needed:
|
|
94
223
|
|
|
95
224
|
```text
|
|
96
|
-
|
|
225
|
+
tool: DataLookup
|
|
97
226
|
```
|
|
98
227
|
|
|
99
228
|
Rather than:
|
|
@@ -135,9 +264,10 @@ model actually saw:
|
|
|
135
264
|
|
|
136
265
|
| Aspect | Saved chat file | What the model sees |
|
|
137
266
|
|--------|----------------|-------------------|
|
|
138
|
-
| Tool calls | All of them, in full |
|
|
267
|
+
| Tool calls | All of them, in full | Older oversized ones replaced by metadata records or omitted |
|
|
139
268
|
| File contents | Full file text | Same (unless cleared) |
|
|
140
269
|
| `clear:` directives | Present as markers | Everything before is removed |
|
|
270
|
+
| Inbox notices | **Absent** (see the `.inbox_removed` sibling) | Injected once, then gone |
|
|
141
271
|
| Conversation history | Complete | Recent turns only (after pruning) |
|
|
142
272
|
|
|
143
273
|
This is by design: the saved chat is the **ground truth** of what happened;
|
|
@@ -149,15 +279,23 @@ the model's prompt is an **optimized view** for the current inference call.
|
|
|
149
279
|
|
|
150
280
|
- **Expecting the saved chat to match the model's input**: They can differ.
|
|
151
281
|
The saved chat is the record; the model's prompt is ephemeral.
|
|
282
|
+
- **Expecting inbox notices in the chat transcript**: Inbox messages are
|
|
283
|
+
delivered to the model only; check the `<files dir>/<name>.inbox_removed`
|
|
284
|
+
sibling of the save_file for the
|
|
285
|
+
delivery record.
|
|
152
286
|
- **Importing too much data**: Large files eat context. Use tools for
|
|
153
|
-
on-demand data
|
|
287
|
+
on-demand data.
|
|
154
288
|
- **Not using `clear:` between phases**: If your workflow has distinct phases,
|
|
155
289
|
clearing between them keeps each phase focused.
|
|
290
|
+
- **Expecting `shorten_tools` limits**: those belong to the non-default
|
|
291
|
+
strategy; the default `epoch_tool_compactation` numbers are 50 / 20 / 80
|
|
292
|
+
with a 400-character output and 200-character argument trigger (see the
|
|
293
|
+
table above).
|
|
156
294
|
|
|
157
295
|
---
|
|
158
296
|
|
|
159
297
|
## Next steps
|
|
160
298
|
|
|
161
|
-
- [WritingChats.md](WritingChats.md) —
|
|
162
|
-
- [ToolCalling.md](ToolCalling.md) —
|
|
163
|
-
- [Delegation.md](Delegation.md) —
|
|
299
|
+
- [WritingChats.md](WritingChats.md) — The `clear:` directive in context.
|
|
300
|
+
- [ToolCalling.md](ToolCalling.md) — Tools as an alternative to pre-loading.
|
|
301
|
+
- [Delegation.md](Delegation.md) — Splitting work across agents.
|