@lmmslab/harness 0.0.0-stage → 0.81.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.
- package/LICENSE +21 -0
- package/README.md +124 -2
- package/bin/harness.js +71 -0
- package/package.json +34 -4
- package/python/harness/README.md +72 -0
- package/python/harness/__init__.py +8 -0
- package/python/harness/__main__.py +3 -0
- package/python/harness/bench.py +124 -0
- package/python/harness/builtin/benches/README.md +5 -0
- package/python/harness/builtin/benches/none/bench.toml +6 -0
- package/python/harness/builtin/configs/README.md +26 -0
- package/python/harness/builtin/configs/assistant.toml +11 -0
- package/python/harness/builtin/configs/default.toml +33 -0
- package/python/harness/builtin/configs/deploy/example-api.toml +10 -0
- package/python/harness/builtin/configs/models/deepseek-api.toml +21 -0
- package/python/harness/builtin/configs/models/deepseek-flash.toml +12 -0
- package/python/harness/builtin/configs/models/grok-low.toml +8 -0
- package/python/harness/builtin/configs/models/grok-medium.toml +43 -0
- package/python/harness/builtin/configs/models/opus-5.5.toml +11 -0
- package/python/harness/builtin/environment/README.md +53 -0
- package/python/harness/builtin/environment/constraints.txt +31 -0
- package/python/harness/builtin/model-settings.js +143 -0
- package/python/harness/builtin/prompts/conversation/core.md +5 -0
- package/python/harness/builtin/prompts/conversation/pack.toml +12 -0
- package/python/harness/builtin/prompts/core/core.md +88 -0
- package/python/harness/builtin/prompts/core/pack.toml +9 -0
- package/python/harness/builtin/prompts/reflect/core.md +45 -0
- package/python/harness/builtin/prompts/reflect/pack.toml +7 -0
- package/python/harness/builtin/prompts/shared/agent-skills.md +5 -0
- package/python/harness/builtin/prompts/shared/agents.md +14 -0
- package/python/harness/builtin/prompts/shared/checklist.md +21 -0
- package/python/harness/builtin/prompts/shared/entries.md +86 -0
- package/python/harness/builtin/prompts/shared/environments.md +21 -0
- package/python/harness/builtin/prompts/shared/learning-goal.md +31 -0
- package/python/harness/builtin/prompts/shared/learning.md +27 -0
- package/python/harness/builtin/prompts/shared/mcp.md +9 -0
- package/python/harness/builtin/prompts/shared/world.md +1 -0
- package/python/harness/builtin/skills/README.md +10 -0
- package/python/harness/builtin/skills/agents/__init__.py +88 -0
- package/python/harness/builtin/skills/agents/skill.toml +11 -0
- package/python/harness/builtin/skills/checklist/__init__.py +32 -0
- package/python/harness/builtin/skills/checklist/skill.toml +9 -0
- package/python/harness/builtin/skills/conversation/__init__.py +23 -0
- package/python/harness/builtin/skills/conversation/skill.toml +8 -0
- package/python/harness/builtin/skills/entries/__init__.py +62 -0
- package/python/harness/builtin/skills/entries/skill.toml +8 -0
- package/python/harness/builtin/skills/environments/__init__.py +69 -0
- package/python/harness/builtin/skills/environments/skill.toml +9 -0
- package/python/harness/builtin/skills/experience/__init__.py +27 -0
- package/python/harness/builtin/skills/experience/skill.toml +9 -0
- package/python/harness/builtin/skills/instructions/__init__.py +29 -0
- package/python/harness/builtin/skills/instructions/skill.toml +9 -0
- package/python/harness/builtin/skills/learning/__init__.py +189 -0
- package/python/harness/builtin/skills/learning/skill.toml +7 -0
- package/python/harness/builtin/skills/mcp/__init__.py +54 -0
- package/python/harness/builtin/skills/mcp/skill.toml +10 -0
- package/python/harness/builtin/skills/memory/__init__.py +130 -0
- package/python/harness/builtin/skills/memory/skill.toml +13 -0
- package/python/harness/builtin/skills/verify/__init__.py +31 -0
- package/python/harness/builtin/skills/verify/skill.toml +7 -0
- package/python/harness/builtin/third_party/sources.toml +40 -0
- package/python/harness/cli.py +1182 -0
- package/python/harness/config/__init__.py +224 -0
- package/python/harness/config/agent.py +777 -0
- package/python/harness/core/__init__.py +52 -0
- package/python/harness/core/artifacts.py +46 -0
- package/python/harness/core/codec.py +160 -0
- package/python/harness/core/contracts.py +75 -0
- package/python/harness/core/episodes.py +150 -0
- package/python/harness/core/format.py +51 -0
- package/python/harness/core/http.py +124 -0
- package/python/harness/core/lanes.py +324 -0
- package/python/harness/core/linux_sandbox.py +55 -0
- package/python/harness/core/media.py +96 -0
- package/python/harness/core/memory.py +147 -0
- package/python/harness/core/ports.py +63 -0
- package/python/harness/core/procs.py +227 -0
- package/python/harness/core/remote.py +102 -0
- package/python/harness/core/spans.py +166 -0
- package/python/harness/core/trace.py +139 -0
- package/python/harness/core/wait.py +12 -0
- package/python/harness/core/worker.py +388 -0
- package/python/harness/core/worker_pipe.py +119 -0
- package/python/harness/embodiments.py +217 -0
- package/python/harness/extensions.py +112 -0
- package/python/harness/host/__init__.py +397 -0
- package/python/harness/host/client.py +201 -0
- package/python/harness/host/http.py +720 -0
- package/python/harness/host/listing.py +68 -0
- package/python/harness/host/server.py +189 -0
- package/python/harness/host/sessions.py +406 -0
- package/python/harness/host/tasks.py +1308 -0
- package/python/harness/host/workers.py +257 -0
- package/python/harness/host/workspaces.py +256 -0
- package/python/harness/model_list.py +117 -0
- package/python/harness/packages/__init__.py +73 -0
- package/python/harness/packages/addons.py +121 -0
- package/python/harness/packages/archive.py +122 -0
- package/python/harness/packages/describe.py +46 -0
- package/python/harness/packages/environments.py +448 -0
- package/python/harness/packages/fetch.py +57 -0
- package/python/harness/packages/manager.py +587 -0
- package/python/harness/packages/manifest.py +221 -0
- package/python/harness/packages/migrate.py +68 -0
- package/python/harness/packages/provision.py +38 -0
- package/python/harness/packages/registry.py +275 -0
- package/python/harness/packages/resolve.py +89 -0
- package/python/harness/packages/sources.py +141 -0
- package/python/harness/packages/state.py +213 -0
- package/python/harness/packages/versions.py +112 -0
- package/python/harness/paths.py +218 -0
- package/python/harness/providers.py +303 -0
- package/python/harness/runtime/__init__.py +8 -0
- package/python/harness/runtime/decision/__init__.py +1 -0
- package/python/harness/runtime/decision/loop.py +198 -0
- package/python/harness/runtime/decision/messages.py +271 -0
- package/python/harness/runtime/decision/model.py +424 -0
- package/python/harness/runtime/decision/prompts.py +248 -0
- package/python/harness/runtime/decision/protocol.py +169 -0
- package/python/harness/runtime/decision/thoughts.py +199 -0
- package/python/harness/runtime/events.py +213 -0
- package/python/harness/runtime/execution/__init__.py +1 -0
- package/python/harness/runtime/execution/attached.py +96 -0
- package/python/harness/runtime/execution/control.py +211 -0
- package/python/harness/runtime/execution/entries.py +665 -0
- package/python/harness/runtime/execution/kernel.py +811 -0
- package/python/harness/runtime/execution/noenv.py +84 -0
- package/python/harness/runtime/execution/results.py +40 -0
- package/python/harness/runtime/execution/session.py +871 -0
- package/python/harness/runtime/execution/skills.py +436 -0
- package/python/harness/runtime/learning/__init__.py +1 -0
- package/python/harness/runtime/learning/active.py +314 -0
- package/python/harness/runtime/learning/experience.py +48 -0
- package/python/harness/runtime/learning/fixtures.py +167 -0
- package/python/harness/runtime/learning/learner.py +651 -0
- package/python/harness/runtime/learning/library.py +504 -0
- package/python/harness/runtime/learning/reflect.py +151 -0
- package/python/harness/runtime/learning/usage.py +30 -0
- package/python/harness/runtime/learning/views.py +89 -0
- package/python/harness/runtime/reactive/__init__.py +1 -0
- package/python/harness/runtime/reactive/rules.py +549 -0
- package/python/harness/runtime/safety/__init__.py +1 -0
- package/python/harness/runtime/safety/approval.py +131 -0
- package/python/harness/runtime/safety/input.py +62 -0
- package/python/harness/runtime/safety/isolation.py +419 -0
- package/python/harness/runtime/safety/shield.py +129 -0
- package/python/harness/runtime/status.py +23 -0
- package/python/harness/runtime/task/__init__.py +7 -0
- package/python/harness/runtime/task/context.py +431 -0
- package/python/harness/runtime/task/delegation.py +468 -0
- package/python/harness/runtime/task/environments.py +268 -0
- package/python/harness/runtime/task/run.py +2878 -0
- package/python/harness/runtime/tick.py +909 -0
- package/python/harness/sdk/__init__.py +281 -0
- package/python/harness/services/__init__.py +6 -0
- package/python/harness/services/broker.py +35 -0
- package/python/harness/services/connectors.py +88 -0
- package/python/harness/services/mcp.py +298 -0
- package/python/harness/services/mcp_stdio.py +131 -0
- package/python/harness/services/placement.py +82 -0
- package/python/harness/services/registry.py +156 -0
- package/python/harness/settings.py +536 -0
- package/python/harness/terminal.py +79 -0
- package/python/harness/transcript.py +297 -0
- package/python/harness/tui/__init__.py +68 -0
- package/python/harness/tui/chat.py +1181 -0
- package/python/harness/tui/pty.py +81 -0
- package/python/harness/tui/renderer.py +45 -0
- package/python/harness/tui/timeline_rows.py +58 -0
- package/python/harness/tui/views.py +434 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"""System prompts assembled from a prompt pack for the skills a run enables.
|
|
2
|
+
|
|
3
|
+
A pack is a directory of Markdown sections (prompts/robodojo, prompts/robotwin). Its
|
|
4
|
+
pack.toml lists the sections in order; a section with `skills` is included only when
|
|
5
|
+
one of them is enabled:
|
|
6
|
+
|
|
7
|
+
sections = [
|
|
8
|
+
{ file = "core.md" },
|
|
9
|
+
{ file = "learned.md", skills = ["vla", "wam"] },
|
|
10
|
+
{ file = "rules_learned.md", skills = ["vla"], optional = true },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
A section { installed = true } is the skills a user installed (the app) that are on: each
|
|
14
|
+
Harness skill's summary, calls and prompt.md, and each Agent Skill's name and description
|
|
15
|
+
(runtime.installed_skills, runtime.agent_skills).
|
|
16
|
+
|
|
17
|
+
Inside a section, lines can be kept for some skills only:
|
|
18
|
+
|
|
19
|
+
<!-- if: pointing, segmentation --> kept when all named skills are enabled
|
|
20
|
+
...
|
|
21
|
+
<!-- else --> kept otherwise (optional)
|
|
22
|
+
...
|
|
23
|
+
<!-- end -->
|
|
24
|
+
|
|
25
|
+
Markers may also name features of the connection (FEATURES): measured_gripper holds
|
|
26
|
+
when gripper readings are measured openings, not under a contract that reports only the
|
|
27
|
+
last command, step_limit when the episode's step limit is reported (core/contract.py),
|
|
28
|
+
channels when the bench's embodiment declares channels (a game's keys, mouse and
|
|
29
|
+
wheel in groups that entries claim: runtime/tick.py), and think_while_acting when the
|
|
30
|
+
model is asked for its next program while one runs (runtime.think_while_acting enabled,
|
|
31
|
+
runtime/conversation.py), and look when the environment has views and the model looks at
|
|
32
|
+
them on its own demand (no runtime.cameras: runtime/task/run.py). The marker lines themselves never reach the
|
|
33
|
+
model, so a prompt with every skill and feature enabled is the pack's text without them. The API documentation stays in the pack
|
|
34
|
+
because it describes one embodiment (its frames, reach and numbers); the skills'
|
|
35
|
+
code is the same for every embodiment.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
import re
|
|
40
|
+
import tomllib
|
|
41
|
+
|
|
42
|
+
from harness.paths import locate
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Sections of a pack without pack.toml (the RoboDojo layout before packs had one).
|
|
46
|
+
DEFAULT_SECTIONS = (
|
|
47
|
+
{"file": "core.md"},
|
|
48
|
+
{"file": "learned.md", "skills": ["vla", "wam"]},
|
|
49
|
+
{"file": "reactive.md", "skills": ["reactive"]},
|
|
50
|
+
{"file": "events.md"},
|
|
51
|
+
{"file": "handlers.md", "skills": ["handlers"]},
|
|
52
|
+
{"file": "rules.md"},
|
|
53
|
+
{"file": "rules_learned.md", "skills": ["vla"], "optional": True},
|
|
54
|
+
{"file": "rules_reactive.md", "skills": ["reactive"], "optional": True},
|
|
55
|
+
{"file": "rules_handlers.md", "skills": ["handlers"], "optional": True},
|
|
56
|
+
)
|
|
57
|
+
# Features of the connection that prompt text may depend on (not skills).
|
|
58
|
+
# `look`: the environment has views and the model looks on demand (look, watch): the
|
|
59
|
+
# configuration declares no standing watch (runtime.cameras).
|
|
60
|
+
FEATURES = ("measured_gripper", "step_limit", "channels", "think_while_acting", "vision_service", "look")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def features_for(runtime: dict, channels: bool = False, *, embodiment=None) -> set[str]:
|
|
64
|
+
"""The prompt features of a runtime configuration (its observation contract and
|
|
65
|
+
whether the model thinks while acting), and `channels` when the embodiment declares
|
|
66
|
+
channels."""
|
|
67
|
+
from harness.embodiments import KINDS
|
|
68
|
+
|
|
69
|
+
kind = KINDS[embodiment] if embodiment is not None else None
|
|
70
|
+
features = set(kind.prompt_features if kind else ())
|
|
71
|
+
if runtime.get("contract", "native") == "native":
|
|
72
|
+
features.add("step_limit")
|
|
73
|
+
if kind:
|
|
74
|
+
features.update(kind.native_features)
|
|
75
|
+
if runtime.get("think_while_acting") != "off":
|
|
76
|
+
features.add("think_while_acting")
|
|
77
|
+
if runtime.get("vision"):
|
|
78
|
+
features.add("vision_service")
|
|
79
|
+
if "cameras" not in runtime and kind is not None and kind.cameras:
|
|
80
|
+
features.add("look")
|
|
81
|
+
return features | ({"channels"} if channels else set())
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
_MARK = re.compile(r"^\s*<!--\s*(if:\s*(?P<skills>[\w,\s]+?)|(?P<else>else)|(?P<end>end))\s*-->\s*$")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def pack(directory: Path) -> dict:
|
|
88
|
+
"""The pack's settings: sections and the exported names it leaves undocumented."""
|
|
89
|
+
path = Path(directory) / "pack.toml"
|
|
90
|
+
if not path.is_file():
|
|
91
|
+
return {"sections": [dict(section) for section in DEFAULT_SECTIONS], "undocumented": []}
|
|
92
|
+
with path.open("rb") as handle:
|
|
93
|
+
data = tomllib.load(handle)
|
|
94
|
+
unknown = set(data) - {"sections", "undocumented"}
|
|
95
|
+
if unknown or not data.get("sections"):
|
|
96
|
+
raise ValueError(f"{path}: needs `sections` (and may have `undocumented`); unknown keys {sorted(unknown)}")
|
|
97
|
+
return {"sections": [dict(section) for section in data["sections"]],
|
|
98
|
+
"undocumented": list(data.get("undocumented", []))}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def sections(directory: Path) -> list[dict]:
|
|
102
|
+
"""The pack's sections in order ({"file", and optionally "skills", "optional"}):
|
|
103
|
+
pack.toml's, or DEFAULT_SECTIONS without one. A section { pack = "../core" } stands
|
|
104
|
+
for that pack's sections (the core's page first, then the package's own), their files
|
|
105
|
+
named by absolute path."""
|
|
106
|
+
out = []
|
|
107
|
+
for section in pack(directory)["sections"]:
|
|
108
|
+
if "pack" not in section:
|
|
109
|
+
out.append(section)
|
|
110
|
+
continue
|
|
111
|
+
other = locate(Path(directory) / section["pack"]).resolve()
|
|
112
|
+
out += [{**inner, "file": str(locate(other / inner["file"]).resolve()), "included": True}
|
|
113
|
+
for inner in sections(other)]
|
|
114
|
+
return out
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def select(text: str, skills) -> str:
|
|
118
|
+
"""Keep the lines of `text` whose if/else markers hold for the enabled `skills`."""
|
|
119
|
+
enabled = set(skills)
|
|
120
|
+
stack = [] # (condition holds, in the else branch)
|
|
121
|
+
out = []
|
|
122
|
+
for number, line in enumerate(text.split("\n"), 1):
|
|
123
|
+
match = _MARK.match(line)
|
|
124
|
+
if match is None:
|
|
125
|
+
if all(holds != in_else for holds, in_else in stack):
|
|
126
|
+
out.append(line)
|
|
127
|
+
continue
|
|
128
|
+
if match.group("skills") is not None:
|
|
129
|
+
names = [name.strip() for name in match.group("skills").split(",") if name.strip()]
|
|
130
|
+
stack.append((all(name in enabled for name in names), False))
|
|
131
|
+
elif match.group("else"):
|
|
132
|
+
if not stack or stack[-1][1]:
|
|
133
|
+
raise ValueError(f"line {number}: <!-- else --> without an open <!-- if: ... -->")
|
|
134
|
+
stack[-1] = (stack[-1][0], True)
|
|
135
|
+
else:
|
|
136
|
+
if not stack:
|
|
137
|
+
raise ValueError(f"line {number}: <!-- end --> without an open <!-- if: ... -->")
|
|
138
|
+
stack.pop()
|
|
139
|
+
if stack:
|
|
140
|
+
raise ValueError("an <!-- if: ... --> block is not closed with <!-- end -->")
|
|
141
|
+
return "\n".join(out)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def marked_skills(text: str) -> set[str]:
|
|
145
|
+
"""Skills named in the markers of `text`."""
|
|
146
|
+
names = set()
|
|
147
|
+
for line in text.split("\n"):
|
|
148
|
+
match = _MARK.match(line)
|
|
149
|
+
if match and match.group("skills"):
|
|
150
|
+
names |= {name.strip() for name in match.group("skills").split(",") if name.strip()}
|
|
151
|
+
return names
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def installed_section(skills, installed=(), agent_skills=None, *, embodiment=None) -> str:
|
|
155
|
+
"""The installed section: of the Harness skills a user installed (`installed`, names)
|
|
156
|
+
those enabled, each with its summary, calls and prompt.md; then the Agent Skills
|
|
157
|
+
({name: {"description", "path"}}), each by name and description."""
|
|
158
|
+
from harness.runtime.execution.skills import load_skills
|
|
159
|
+
|
|
160
|
+
known = load_skills()
|
|
161
|
+
parts = []
|
|
162
|
+
for name in installed:
|
|
163
|
+
skill = known.get(name)
|
|
164
|
+
if skill is None or name not in set(skills):
|
|
165
|
+
continue
|
|
166
|
+
skill = skill.for_embodiment(embodiment)
|
|
167
|
+
text = f"Skill {name} (installed by the user): {skill.summary}\n calls: "
|
|
168
|
+
text += ", ".join(f"{call}()" for call in skill.public) + "\n"
|
|
169
|
+
extra = skill.path / "prompt.md"
|
|
170
|
+
if extra.is_file():
|
|
171
|
+
text += extra.read_text(encoding="utf-8").strip() + "\n"
|
|
172
|
+
parts.append(text)
|
|
173
|
+
if agent_skills:
|
|
174
|
+
parts.append("Skills the user installed (read one with read_skill(name) before a task it covers):\n"
|
|
175
|
+
+ "".join(f" {name}: {row['description']}\n" for name, row in agent_skills.items()))
|
|
176
|
+
return "".join(f"\n{part}" for part in parts)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def assemble_prompt(directory: Path, skills, overrides: dict | None = None,
|
|
180
|
+
features=("measured_gripper",), installed=(), agent_skills=None, *, embodiment=None,
|
|
181
|
+
own: bool = False, only=None) -> str:
|
|
182
|
+
"""The pack's sections for the enabled `skills` and connection `features`, joined.
|
|
183
|
+
`overrides` maps a section name (file stem) to another file, e.g. another
|
|
184
|
+
embodiment's core section; `installed` and `agent_skills` fill the installed section
|
|
185
|
+
(installed_section). `own`: only what the pack itself says of its environment, without
|
|
186
|
+
the page it starts from, the core's shared sections and the installed section (an
|
|
187
|
+
environment attached to a conversation that has those already). `only`: just the
|
|
188
|
+
sections that one of these skills switches on (a skill switched on while a
|
|
189
|
+
conversation runs)."""
|
|
190
|
+
from harness.paths import ROOT
|
|
191
|
+
|
|
192
|
+
directory = Path(directory)
|
|
193
|
+
enabled = set(skills) | set(features)
|
|
194
|
+
parts = []
|
|
195
|
+
for section in sections(directory):
|
|
196
|
+
if own and (section.get("included") or section.get("installed")
|
|
197
|
+
or ROOT.resolve() in locate(directory / section["file"]).resolve().parents):
|
|
198
|
+
continue
|
|
199
|
+
if only is not None and not set(section.get("skills") or ()) & set(only):
|
|
200
|
+
continue
|
|
201
|
+
if section.get("installed"):
|
|
202
|
+
text = installed_section(skills, installed, agent_skills, embodiment=embodiment)
|
|
203
|
+
if text:
|
|
204
|
+
parts.append(text.rstrip("\n"))
|
|
205
|
+
continue
|
|
206
|
+
name = Path(section["file"]).stem
|
|
207
|
+
wanted = section.get("skills")
|
|
208
|
+
if wanted and not set(skills) & set(wanted):
|
|
209
|
+
continue
|
|
210
|
+
# A section of another pack may be another package's (paths.locate).
|
|
211
|
+
path = locate(Path((overrides or {}).get(name) or directory / section["file"]))
|
|
212
|
+
if not path.is_file():
|
|
213
|
+
if section.get("optional"):
|
|
214
|
+
continue
|
|
215
|
+
raise ValueError(f"Prompt section {path} is missing")
|
|
216
|
+
parts.append(select(path.read_text(encoding="utf-8"), enabled).rstrip("\n"))
|
|
217
|
+
return "\n".join(parts) + "\n"
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def mentions(text: str, name: str) -> bool:
|
|
221
|
+
"""Whether the prompt refers to an API name: a call or an attribute for functions and
|
|
222
|
+
objects (`recall(`, `library.propose(`), the bare word for constants (upper case) and
|
|
223
|
+
classes (ClosedLoop)."""
|
|
224
|
+
bare = name.isupper() or name[:1].isupper()
|
|
225
|
+
pattern = rf"(?<![\w.]){re.escape(name)}\b" if bare else rf"(?<![\w.]){re.escape(name)}(\(|\.[A-Za-z_])"
|
|
226
|
+
return re.search(pattern, text) is not None
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# These calls are present in EpisodeCore even with no reactive skills enabled.
|
|
230
|
+
CORE_RULE_CALLS = {"rule", "when", "watch", "on", "clear_rules", "run_controller"}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def documentation_gaps(directory: Path, skills, exported: dict, features=("measured_gripper",)) -> dict:
|
|
234
|
+
"""What the assembled prompt gets wrong about the API: `missing` are functions of
|
|
235
|
+
enabled skills it never shows being called (except those the pack lists as
|
|
236
|
+
undocumented), `stray` are names of disabled skills it still mentions.
|
|
237
|
+
`exported` maps each exported name to its skill, or to the skills that export it."""
|
|
238
|
+
text = assemble_prompt(directory, skills, features=features)
|
|
239
|
+
enabled = set(skills)
|
|
240
|
+
skip = set(pack(directory)["undocumented"])
|
|
241
|
+
public = {name: {owner} if isinstance(owner, str) else set(owner)
|
|
242
|
+
for name, owner in exported.items() if not name.startswith("_")}
|
|
243
|
+
enabled.add("core")
|
|
244
|
+
public.update({name: {"core"} for name in CORE_RULE_CALLS})
|
|
245
|
+
missing = sorted(name for name, owners in public.items()
|
|
246
|
+
if owners & enabled and not name.isupper() and name not in skip and not mentions(text, name))
|
|
247
|
+
stray = sorted(name for name, owners in public.items() if not owners & enabled and mentions(text, name))
|
|
248
|
+
return {"missing": missing, "stray": stray}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""The high-level reply format: a short thought and exactly one action block."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
import json
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
KINDS = ("python", "verify", "finish")
|
|
9
|
+
DIRECT_KINDS = ("action", "finish")
|
|
10
|
+
# A reply to a call made while a program runs (runtime/conversation.py, think while
|
|
11
|
+
# acting) may also be <wait>: what comes next depends on that program's result.
|
|
12
|
+
AHEAD_KINDS = ("wait",)
|
|
13
|
+
_FENCE = re.compile(r"^\s*```[a-zA-Z0-9_-]*\s*\n(.*?)\n\s*```\s*$", re.DOTALL)
|
|
14
|
+
# DeepSeek models sometimes end a block with their own tool-call markup instead of its
|
|
15
|
+
# closing tag ("</\uff5cDSML\uff5c parameter>", "</\uff5cDSML\uff5c invoke>", ...): 50 of
|
|
16
|
+
# agent 1.4.0's 677 development replies, each a call that ran nothing. Lines of it are
|
|
17
|
+
# dropped, and a block it left open is closed at the end of the reply.
|
|
18
|
+
_MARK = r"\uff5c{1,2}DSML\uff5c{1,2}"
|
|
19
|
+
_LEAKED = re.compile(rf"^\s*</?\s*{_MARK}[^>\n]*>\s*$", re.MULTILINE)
|
|
20
|
+
# Or the whole block is their tool call: <\uff5cDSML\uff5c invoke name="python"> with the
|
|
21
|
+
# program as its one parameter (an app conversation on DeepSeek V4.1 Flash wrote every
|
|
22
|
+
# program so). It is read as the block it names.
|
|
23
|
+
_INVOKE = re.compile(rf"<\s*{_MARK}\s*invoke\s+name=\"(\w+)\"\s*>(.*?)(?:<\s*/\s*{_MARK}\s*invoke\s*>|$)",
|
|
24
|
+
re.DOTALL)
|
|
25
|
+
_PARAMETER = re.compile(rf"<\s*{_MARK}\s*parameter\b[^>]*>(.*?)(?:<\s*/\s*{_MARK}\s*parameter\s*>|$)",
|
|
26
|
+
re.DOTALL)
|
|
27
|
+
_CALLS = re.compile(rf"<\s*/?\s*{_MARK}\s*(?:function_)?calls\s*>")
|
|
28
|
+
_TOOL_MARKUP = re.compile(r"<\s*/?\s*(?:python|verify|finish|action|wait|plan|step_done|search_web|navigate|read_page|tools)\b",
|
|
29
|
+
re.IGNORECASE)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def looks_like_action(text: str) -> bool:
|
|
33
|
+
"""Action-shaped replies must be corrected, not treated as ordinary chat."""
|
|
34
|
+
return bool(_TOOL_MARKUP.search(text or "") or re.search(_MARK, text or ""))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# A sentence that says what the model is about to do: "I'll open the page ...", "Let me
|
|
38
|
+
# check ...", "好的,我来 ...". grok-4.7 ends most interactive turns with one such sentence
|
|
39
|
+
# and no block (no tool call or code in its reasoning either), so nothing runs. Waiting,
|
|
40
|
+
# being, letting the user know and stopping are things one tells the user.
|
|
41
|
+
_ANNOUNCE = re.compile(
|
|
42
|
+
r"(?:^|[.!\n。!]\s*)(?:(?:ok(?:ay)?|sure|alright|all right|got it|understood|great|right)[,.!,]?\s+)?"
|
|
43
|
+
r"(?:(?:now|next|first|then)[,,]?\s+)?"
|
|
44
|
+
r"(?:i['’]ll|i will|i['’]m going to|i am going to|let me|let['’]s)\s+"
|
|
45
|
+
r"(?!(?:be|wait|need|know|keep|remember|stop|leave|let you)\b)",
|
|
46
|
+
re.IGNORECASE)
|
|
47
|
+
_ANNOUNCE_ZH = re.compile(r"(?:^|[.!\n。!]\s*)(?:好的[,,]?\s*)?(?:我(?:将|会|来|先|这就|现在|马上|立即)|让我)"
|
|
48
|
+
r"(?!(?:等|等待|记住|停))")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Or the program itself in a Markdown fence and no block: deepseek-v4.1-flash once
|
|
52
|
+
# answered harness chat with "I'll start by finding the window ...\n\n```python\n...```".
|
|
53
|
+
_FENCED = re.compile(r"^\s*```(?:python|py)\s*$", re.MULTILINE | re.IGNORECASE)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def announces(text: str) -> bool:
|
|
57
|
+
"""A reply without a block that only says what the model will do next: short, and
|
|
58
|
+
not a question to the user, nor a long answer; or a program in a Markdown fence."""
|
|
59
|
+
text = (text or "").strip()
|
|
60
|
+
if not text or looks_like_action(text):
|
|
61
|
+
return False
|
|
62
|
+
if _FENCED.search(text):
|
|
63
|
+
return True
|
|
64
|
+
if len(text) > 600 or "?" in text or "?" in text:
|
|
65
|
+
return False
|
|
66
|
+
return bool(_ANNOUNCE.search(text) or _ANNOUNCE_ZH.search(text))
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ProtocolError(ValueError):
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass
|
|
74
|
+
class Reply:
|
|
75
|
+
thought: str
|
|
76
|
+
kind: str
|
|
77
|
+
body: str
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _invoked(text: str, kinds) -> str | None:
|
|
81
|
+
"""A reply whose block is a DeepSeek tool call (one invoke of a kind, one parameter)
|
|
82
|
+
as that block, the text before it as the thought; else None."""
|
|
83
|
+
if any(f"<{kind}>" in text for kind in kinds):
|
|
84
|
+
return None
|
|
85
|
+
invokes = list(_INVOKE.finditer(text))
|
|
86
|
+
# Count *all* invokes, including unknown tools. Never silently execute a subset.
|
|
87
|
+
openings = re.findall(rf"<\s*{_MARK}\s*invoke\b", text)
|
|
88
|
+
if len(invokes) != 1 or len(openings) != 1 or invokes[0].group(1) not in kinds:
|
|
89
|
+
raise ProtocolError("Expected one supported DSML invoke; use a single <python>, <verify>, or <finish> block")
|
|
90
|
+
invoke = invokes[0]
|
|
91
|
+
kind, inner = invoke.group(1), invoke.group(2)
|
|
92
|
+
parameters = _PARAMETER.findall(inner)
|
|
93
|
+
if len(parameters) == 1:
|
|
94
|
+
body = parameters[0]
|
|
95
|
+
remaining = _PARAMETER.sub("", inner)
|
|
96
|
+
elif not parameters and not re.search(rf"<\s*{_MARK}\s*parameter\b", inner):
|
|
97
|
+
# Observed Flash variant: a named invoke contains the program directly,
|
|
98
|
+
# sometimes followed by a stray closing parameter tag. Require the invoke's
|
|
99
|
+
# closing tag before accepting this form.
|
|
100
|
+
if not re.search(rf"</\s*{_MARK}\s*invoke\s*>$", invoke.group(0)):
|
|
101
|
+
raise ProtocolError("Unclosed DSML invoke; resend the complete <python> block")
|
|
102
|
+
body = re.sub(rf"</\s*{_MARK}\s*parameter\s*>\s*$", "", inner)
|
|
103
|
+
remaining = ""
|
|
104
|
+
else:
|
|
105
|
+
raise ProtocolError("A DSML invoke needs exactly one program, not multiple parameters")
|
|
106
|
+
tail = _CALLS.sub("", text[invoke.end():]).strip()
|
|
107
|
+
thought = _CALLS.sub("", text[:invoke.start()]).strip()
|
|
108
|
+
if remaining.strip() or tail or re.search(_MARK, body + thought):
|
|
109
|
+
raise ProtocolError("Ambiguous DSML content; resend one complete action block")
|
|
110
|
+
return f"{thought}\n<{kind}>\n{body.strip(chr(10))}\n</{kind}>"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _without_leaked_markup(text: str, kinds) -> str:
|
|
114
|
+
if not re.search(_MARK, text):
|
|
115
|
+
return text
|
|
116
|
+
if re.search(rf"<\s*{_MARK}\s*invoke\b", text):
|
|
117
|
+
if any(f"<{kind}>" in text for kind in kinds):
|
|
118
|
+
raise ProtocolError("Mixed action blocks and DSML invokes; resend just one block")
|
|
119
|
+
return _invoked(text, kinds)
|
|
120
|
+
text = _LEAKED.sub("", text).rstrip()
|
|
121
|
+
for kind in kinds:
|
|
122
|
+
if text.count(f"<{kind}>") == 1 and f"</{kind}>" not in text:
|
|
123
|
+
return text + f"\n</{kind}>"
|
|
124
|
+
return text
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def parse_reply(text: str, kinds=KINDS) -> Reply:
|
|
128
|
+
text = _without_leaked_markup(text or "", kinds)
|
|
129
|
+
pattern = re.compile(r"<(%s)>(.*?)</\1>" % "|".join(kinds), re.DOTALL)
|
|
130
|
+
blocks = pattern.findall(text)
|
|
131
|
+
if len(blocks) > 1 and all(kind == "python" for kind, _ in blocks):
|
|
132
|
+
# Several <python> blocks and nothing else (plan() in one, the program in the
|
|
133
|
+
# next: A6's demo runs showed it as a format error) are one program, in order.
|
|
134
|
+
bodies = []
|
|
135
|
+
for _, body in blocks:
|
|
136
|
+
body = body.strip("\n")
|
|
137
|
+
fenced = _FENCE.match(body)
|
|
138
|
+
bodies.append(fenced.group(1) if fenced else body)
|
|
139
|
+
blocks = [("python", "\n".join(body for body in bodies if body.strip()))]
|
|
140
|
+
if len(blocks) != 1:
|
|
141
|
+
names = ", ".join(f"<{kind}>" for kind in kinds)
|
|
142
|
+
raise ProtocolError(f"Reply must contain exactly one of {names}; found {len(blocks)}")
|
|
143
|
+
kind, body = blocks[0]
|
|
144
|
+
thought = text[:text.index(f"<{kind}>")].strip()
|
|
145
|
+
# Stray plan/tool tags before a valid block are not user-facing prose or extra
|
|
146
|
+
# actions. The caller retains the original reply verbatim in the trace.
|
|
147
|
+
if looks_like_action(thought):
|
|
148
|
+
thought = ""
|
|
149
|
+
body = body.strip("\n")
|
|
150
|
+
if kind in ("python", "action"):
|
|
151
|
+
fenced = _FENCE.match(body)
|
|
152
|
+
if fenced:
|
|
153
|
+
body = fenced.group(1)
|
|
154
|
+
if not body.strip():
|
|
155
|
+
raise ProtocolError(f"<{kind}> block is empty")
|
|
156
|
+
return Reply(thought=thought, kind=kind, body=body if kind == "python" else body.strip())
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def json_list(text) -> list:
|
|
160
|
+
"""The JSON list in a model's reply (the first "[" to the last "]"), or [] when there is
|
|
161
|
+
none or it does not parse."""
|
|
162
|
+
match = re.search(r"\[.*\]", text or "", re.DOTALL)
|
|
163
|
+
if not match:
|
|
164
|
+
return []
|
|
165
|
+
try:
|
|
166
|
+
value = json.loads(match.group(0))
|
|
167
|
+
except json.JSONDecodeError:
|
|
168
|
+
return []
|
|
169
|
+
return value if isinstance(value, list) else []
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""The host's decision tick. A session owns one transport until its worker returns."""
|
|
2
|
+
|
|
3
|
+
from copy import deepcopy
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
import threading
|
|
6
|
+
import time
|
|
7
|
+
import uuid
|
|
8
|
+
|
|
9
|
+
from harness.core.http import Preempted, RequestCancellation
|
|
10
|
+
from harness.runtime.decision.model import ChatModel, ChatReply
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ThoughtCancelled(Exception):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Thought:
|
|
18
|
+
def __init__(self, role, trigger, chat, system, messages, *, timeout, program=None,
|
|
19
|
+
revision=0, origin=None, owner=None, call=None, turns=None, invoke=None):
|
|
20
|
+
self.id = uuid.uuid4().hex
|
|
21
|
+
self.role, self.trigger, self.program = role, trigger, program
|
|
22
|
+
self.origin, self.owner, self.revision, self.call = origin, owner, revision, call
|
|
23
|
+
self.chat, self.system, self.messages = chat, system, deepcopy(messages)
|
|
24
|
+
self.turns, self.invoke = turns, invoke
|
|
25
|
+
self.deadline = time.monotonic() + max(0, timeout)
|
|
26
|
+
self.cancellation = RequestCancellation()
|
|
27
|
+
self.ready = threading.Event()
|
|
28
|
+
self.reply, self.error, self.outcome = None, None, None
|
|
29
|
+
self.cancelled, self.exited, self.started = False, False, False
|
|
30
|
+
self.stopped, self.said, self.side = False, False, None
|
|
31
|
+
self.seconds = 0.0
|
|
32
|
+
|
|
33
|
+
def back(self, timeout=None):
|
|
34
|
+
return self.ready.wait(timeout)
|
|
35
|
+
|
|
36
|
+
def wait(self):
|
|
37
|
+
self.ready.wait()
|
|
38
|
+
if self.cancelled:
|
|
39
|
+
raise ThoughtCancelled(self.error or "The thought was superseded")
|
|
40
|
+
if self.error is not None:
|
|
41
|
+
raise self.error
|
|
42
|
+
return self.reply
|
|
43
|
+
|
|
44
|
+
def cancel(self, reason="The thought was superseded"):
|
|
45
|
+
if not self.cancelled:
|
|
46
|
+
self.cancelled = True
|
|
47
|
+
self.error = ThoughtCancelled(reason)
|
|
48
|
+
self.cancellation.cancel()
|
|
49
|
+
self.ready.set()
|
|
50
|
+
|
|
51
|
+
def complete(self):
|
|
52
|
+
self.cancellation.check()
|
|
53
|
+
if self.invoke is not None:
|
|
54
|
+
return self.invoke(self)
|
|
55
|
+
options = {"cancellation": self.cancellation} if isinstance(self.chat, ChatModel) else {}
|
|
56
|
+
reply = self.chat.complete(self.system, self.messages, **options)
|
|
57
|
+
if isinstance(reply, ChatReply):
|
|
58
|
+
return reply
|
|
59
|
+
return ChatReply(reply.text, usage=getattr(reply, "usage", None) or {},
|
|
60
|
+
response_id=getattr(reply, "response_id", None), seconds=getattr(reply, "seconds", 0.0),
|
|
61
|
+
reasoning=getattr(reply, "reasoning", ""))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ThoughtQueue:
|
|
65
|
+
"""A condition-driven tick for decisions. Network workers only post exit receipts."""
|
|
66
|
+
|
|
67
|
+
def __init__(self, condition, *, advance=None, on_exit=None, trace=None):
|
|
68
|
+
self.changed, self.advance, self.on_exit, self.trace = condition, advance, on_exit, trace
|
|
69
|
+
self.pending = []
|
|
70
|
+
self.active = self.receipt = self.thread = None
|
|
71
|
+
self.closed = False
|
|
72
|
+
|
|
73
|
+
def wake(self):
|
|
74
|
+
with self.changed:
|
|
75
|
+
if self.thread is None and not self.closed:
|
|
76
|
+
self.thread = threading.Thread(target=self._tick, name="decision-tick", daemon=True)
|
|
77
|
+
self.thread.start()
|
|
78
|
+
self.changed.notify_all()
|
|
79
|
+
|
|
80
|
+
def submit(self, thought):
|
|
81
|
+
with self.changed:
|
|
82
|
+
if self.closed:
|
|
83
|
+
thought.cancel("The session has ended")
|
|
84
|
+
return
|
|
85
|
+
self.pending.append(thought)
|
|
86
|
+
self._emit("thought_queued", thought)
|
|
87
|
+
self.wake()
|
|
88
|
+
|
|
89
|
+
def cancel_where(self, predicate, reason):
|
|
90
|
+
with self.changed:
|
|
91
|
+
for thought in [self.active, *self.pending]:
|
|
92
|
+
if thought is not None and predicate(thought) and not thought.cancelled:
|
|
93
|
+
thought.cancel(reason)
|
|
94
|
+
self._emit("thought_cancelled", thought, reason=reason)
|
|
95
|
+
self.changed.notify_all()
|
|
96
|
+
|
|
97
|
+
def close(self):
|
|
98
|
+
with self.changed:
|
|
99
|
+
self.closed = True
|
|
100
|
+
self.cancel_where(lambda thought: True, "The session has ended")
|
|
101
|
+
|
|
102
|
+
def _emit(self, event, thought, **detail):
|
|
103
|
+
if self.trace is not None:
|
|
104
|
+
self.trace.emit(event, thought=thought.id, role=thought.role, trigger=thought.trigger,
|
|
105
|
+
program=thought.program, owner=thought.owner, origin=thought.origin,
|
|
106
|
+
revision=thought.revision, **detail)
|
|
107
|
+
|
|
108
|
+
def _tick(self):
|
|
109
|
+
with self.changed:
|
|
110
|
+
while True:
|
|
111
|
+
if self.receipt is not None:
|
|
112
|
+
thought, self.receipt = self.active, None
|
|
113
|
+
self.active = None
|
|
114
|
+
thought.exited = True
|
|
115
|
+
self._emit("thought_exited", thought, seconds=thought.seconds, cancelled=thought.cancelled,
|
|
116
|
+
usage=thought.reply.usage if thought.reply is not None else None,
|
|
117
|
+
**({"result": thought.reply.text} if thought.reply is not None and thought.role != "main" else {}),
|
|
118
|
+
**({"error": str(thought.error)} if thought.error is not None else {}))
|
|
119
|
+
try:
|
|
120
|
+
if self.on_exit is not None:
|
|
121
|
+
self.on_exit(thought)
|
|
122
|
+
except Exception as error:
|
|
123
|
+
thought.error = error
|
|
124
|
+
self._emit("thought_failed", thought, error=f"{type(error).__name__}: {error}")
|
|
125
|
+
finally:
|
|
126
|
+
thought.ready.set()
|
|
127
|
+
self.changed.notify_all()
|
|
128
|
+
if self.closed and self.active is None:
|
|
129
|
+
return
|
|
130
|
+
now = time.monotonic()
|
|
131
|
+
self.cancel_where(lambda thought: thought.deadline <= now, "Model transport deadline expired")
|
|
132
|
+
self.pending[:] = [thought for thought in self.pending if not thought.cancelled]
|
|
133
|
+
due = self.advance() if self.advance is not None and not self.closed else None
|
|
134
|
+
if self.active is None and self.pending:
|
|
135
|
+
# Real decisions and synchronous role requests precede speculative work.
|
|
136
|
+
thought = min(self.pending, key=lambda item: (item.trigger == "ahead" or item.role == "observer",
|
|
137
|
+
item.role != "main"))
|
|
138
|
+
self.pending.remove(thought)
|
|
139
|
+
self.active = thought
|
|
140
|
+
thought.started = True
|
|
141
|
+
self._emit("thought_started", thought, deadline_in=max(0, thought.deadline - now))
|
|
142
|
+
threading.Thread(target=self._transport, args=(thought,), name="model-transport",
|
|
143
|
+
daemon=True).start()
|
|
144
|
+
deadlines = [item.deadline for item in [self.active, *self.pending]
|
|
145
|
+
if item is not None and not item.cancelled]
|
|
146
|
+
if due is not None:
|
|
147
|
+
deadlines.append(due)
|
|
148
|
+
self.changed.wait(max(0, min(deadlines) - time.monotonic()) if deadlines else None)
|
|
149
|
+
|
|
150
|
+
@contextmanager
|
|
151
|
+
def _span(self, thought):
|
|
152
|
+
if self.trace is None or thought.role == "main":
|
|
153
|
+
yield
|
|
154
|
+
return
|
|
155
|
+
identifier = uuid.uuid4().hex
|
|
156
|
+
lane = {"reflection": "model", "verifier": "verifier", "observer": "observer"}.get(thought.role, "service")
|
|
157
|
+
self.trace.emit("span_start", id=identifier, lane=lane, name=getattr(thought.chat, "model", thought.role),
|
|
158
|
+
thought=thought.id, role=thought.role, reason=thought.trigger,
|
|
159
|
+
program=thought.program, parent=None)
|
|
160
|
+
try:
|
|
161
|
+
yield
|
|
162
|
+
finally:
|
|
163
|
+
self.trace.emit("span_end", id=identifier)
|
|
164
|
+
|
|
165
|
+
def _transport(self, thought):
|
|
166
|
+
began = time.monotonic()
|
|
167
|
+
reply, error = None, None
|
|
168
|
+
try:
|
|
169
|
+
with self._span(thought):
|
|
170
|
+
reply = thought.complete()
|
|
171
|
+
except Preempted:
|
|
172
|
+
error = ThoughtCancelled("The model transport was interrupted")
|
|
173
|
+
except Exception as failure:
|
|
174
|
+
error = failure
|
|
175
|
+
finally:
|
|
176
|
+
with self.changed:
|
|
177
|
+
thought.seconds = time.monotonic() - began
|
|
178
|
+
thought.reply = reply
|
|
179
|
+
if not thought.cancelled:
|
|
180
|
+
if time.monotonic() >= thought.deadline:
|
|
181
|
+
thought.cancel("Model transport deadline expired")
|
|
182
|
+
self._emit("thought_cancelled", thought, reason="Model transport deadline expired")
|
|
183
|
+
else:
|
|
184
|
+
thought.error = error
|
|
185
|
+
self.receipt = thought.id
|
|
186
|
+
self.changed.notify_all()
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def think(chat, system: str, messages: list, *, role="reflection", trigger="reflect", trace=None):
|
|
190
|
+
"""Use the same dispatcher for offline proposals and session-bound reflection."""
|
|
191
|
+
if getattr(chat, "thinks", False):
|
|
192
|
+
return chat.complete(system, messages)
|
|
193
|
+
queue = ThoughtQueue(threading.Condition(), trace=trace)
|
|
194
|
+
try:
|
|
195
|
+
thought = Thought(role, trigger, chat, system, messages, timeout=300)
|
|
196
|
+
queue.submit(thought)
|
|
197
|
+
return thought.wait()
|
|
198
|
+
finally:
|
|
199
|
+
queue.close()
|