@yahyahammad/venastine 0.2.0 → 0.3.9
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/.env.example +9 -4
- package/CONFIG_ARCHITECTURE.md +2030 -0
- package/LICENSE +201 -201
- package/NOTICE +1 -1
- package/README.md +1034 -895
- package/agents/builtin/build.md +73 -0
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/general.md +80 -0
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -88
- package/agents/builtin/review.md +74 -74
- package/agents/builtin/test.md +65 -0
- package/agents/builtin/writer.md +67 -0
- package/agents/manager.py +68 -2
- package/agents/subagent_tool.py +472 -238
- package/agents/tui_commands.py +238 -151
- package/bin/venastine.mjs +150 -4
- package/bin/venastine.py +71 -0
- package/cli_commands.py +838 -0
- package/config.py +95 -1198
- package/config.yaml +1103 -0
- package/config_edit.py +1301 -0
- package/config_schema.py +971 -0
- package/config_update.py +749 -0
- package/core/agent_activity.py +256 -118
- package/core/ansi.py +452 -0
- package/core/approval.py +137 -115
- package/core/call_view.py +364 -0
- package/core/cancel.py +121 -0
- package/core/chatgpt_auth.py +747 -0
- package/core/claims_view.py +107 -0
- package/core/client.py +2715 -1559
- package/core/commands.py +460 -0
- package/core/compaction.py +1735 -971
- package/core/config_loader.py +1982 -1563
- package/core/connect.py +686 -0
- package/core/events.py +123 -61
- package/core/file_mentions.py +280 -0
- package/core/interaction.py +411 -328
- package/core/line_pattern.py +128 -0
- package/core/loop.py +2566 -1490
- package/core/memory.py +482 -370
- package/core/pipeline_models.py +190 -176
- package/core/provider_errors.py +234 -0
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -468
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/json_retry.py +19 -1
- package/core/reasoning/orchestrator.py +1561 -1382
- package/core/reasoning/output_writer.py +345 -286
- package/core/reasoning/payload_validation.py +524 -398
- package/core/reasoning/pipeline_storage.py +88 -22
- package/core/reasoning/review.py +659 -615
- package/core/reasoning/scholar.py +458 -434
- package/core/reasoning/source_corpus.py +433 -327
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -183
- package/core/session.py +36 -12
- package/core/session_view.py +259 -0
- package/core/session_wake.py +259 -0
- package/core/shell_sessions.py +1553 -0
- package/core/workspace_trust.py +1 -1
- package/credentials.py +148 -20
- package/database.py +333 -252
- package/{PRIVACY.md → docs/PRIVACY.md} +78 -66
- package/docs/SECURITY.md +108 -0
- package/docs/THIRD_PARTY_NOTICES.md +148 -0
- package/env_secrets.py +50 -9
- package/json_store.py +343 -123
- package/logging_setup.py +295 -185
- package/main.py +3433 -1961
- package/mcp_client/client.py +733 -499
- package/mcp_client/config.py +126 -21
- package/mcp_client/registration.py +343 -182
- package/memories/manager.py +147 -132
- package/memories/tui_commands.py +319 -244
- package/package.json +303 -73
- package/project_init/config_files.py +282 -278
- package/project_init/generator.py +728 -564
- package/project_init/manifest.py +18 -6
- package/project_init/tui_commands.py +147 -144
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +2 -0
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -262
- package/providers.json.example +4 -2
- package/pyproject.toml +149 -100
- package/requirements.txt +295 -72
- package/safety/policy_enforcement.py +1082 -746
- package/security/askpass.py +419 -0
- package/security/capability.py +207 -177
- package/security/confine.py +484 -0
- package/security/hosted.py +182 -0
- package/security/permissions.py +237 -190
- package/security/posture.py +124 -12
- package/security/protected_paths.py +501 -309
- package/security/sandbox.py +4108 -985
- package/security/secrets.py +855 -0
- package/skills/builtin/math/formal-specification.md +67 -67
- package/skills/builtin/math/numerical-methods.md +66 -66
- package/skills/builtin/research/experiment-design.md +62 -62
- package/skills/builtin/research/reproducibility.md +55 -55
- package/skills/builtin/research/source-evaluation.md +70 -70
- package/skills/builtin/research/statistical-inference.md +63 -63
- package/skills/builtin/research/technical-writing.md +59 -59
- package/skills/builtin/software/code-review.md +61 -61
- package/skills/builtin/software/debugging.md +61 -61
- package/skills/builtin/software/test-design.md +67 -67
- package/skills/tui_commands.py +110 -111
- package/storage.py +1338 -1005
- package/tools/base.py +161 -1
- package/tools/builtin/_math_common.py +667 -377
- package/tools/builtin/_net_common.py +225 -19
- package/tools/builtin/arxiv.py +497 -39
- package/tools/builtin/ask_user.py +231 -213
- package/tools/builtin/discrete_math.py +35 -4
- package/tools/builtin/fetch_url.py +371 -153
- package/tools/builtin/file_ops.py +720 -412
- package/tools/builtin/geometry.py +48 -12
- package/tools/builtin/get_time.py +2 -2
- package/tools/builtin/linear_algebra.py +66 -23
- package/tools/builtin/load_skill.py +76 -66
- package/tools/builtin/logic.py +171 -12
- package/tools/builtin/pin.py +227 -193
- package/tools/builtin/probability_stats.py +12 -16
- package/tools/builtin/project_docs.py +464 -405
- package/tools/builtin/remember.py +175 -158
- package/tools/builtin/shell.py +980 -461
- package/tools/builtin/shell_sessions.py +613 -0
- package/tools/builtin/symbolic_math.py +80 -10
- package/tools/builtin/todo.py +149 -147
- package/tools/builtin/web_search.py +191 -13
- package/tools/context.py +159 -136
- package/tools/isolation.py +107 -34
- package/tools/registry.py +1242 -925
- package/tui/app.py +8318 -4100
- package/tui/app.tcss +747 -556
- package/tui/commands.py +26 -170
- package/tui/diffs.py +34 -13
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +1329 -1279
- package/tui/meters.py +364 -268
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -943
- package/tui/themes.py +599 -559
- package/tui/widgets.py +3813 -2332
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
package/core/reasoning/events.py
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
"""
|
|
2
|
-
core/reasoning/events.py
|
|
3
|
-
|
|
4
|
-
PipelineEvent is the single event type yielded by
|
|
5
|
-
core.reasoning.orchestrator.stream_deep_research_pipeline() as the
|
|
6
|
-
ten-pass research pipeline progresses. Consumers (the CLI's research
|
|
7
|
-
mode, the TUI's /research worker) iterate the generator and render what
|
|
8
|
-
they care about; run_pipeline_to_completion() drains it for callers that
|
|
9
|
-
only need the finished PipelineRun.
|
|
10
|
-
|
|
11
|
-
WHY THIS IS A SEPARATE TYPE FROM core.events.LoopEvent (ROADMAP_v2 §22
|
|
12
|
-
§22 AC4, decision P1). §22 required this decision be made and recorded
|
|
13
|
-
BEFORE any event was added, precisely so nobody discovered the problem at
|
|
14
|
-
§23. Three shapes were considered:
|
|
15
|
-
|
|
16
|
-
1. Add fields to LoopEvent. Rejected. LoopEvent is a flat dataclass
|
|
17
|
-
with an "exactly one field is populated" convention documented in a
|
|
18
|
-
docstring rather than in the type. That was right for six kinds;
|
|
19
|
-
§22 adds seven of a different family and §23 adds more, at which
|
|
20
|
-
point ~15 optional fields whose valid combinations live in prose
|
|
21
|
-
stops paying for itself.
|
|
22
|
-
2. A tagged union for both. Rejected as disproportionate: it rewrites
|
|
23
|
-
every `if event.token_delta:` read in tui/app.py, core/loop.py and
|
|
24
|
-
the streaming tests -- a §13-scale breakage inside a §22 change.
|
|
25
|
-
3. A separate, KIND-DISCRIMINATED type. Chosen. The two families have
|
|
26
|
-
different consumers and different lifetimes: a LoopEvent describes
|
|
27
|
-
one model call's progress and lives for a turn, a PipelineEvent
|
|
28
|
-
describes a ten-pass run and lives for the run. The `kind` field
|
|
29
|
-
puts the discriminator in the data rather than in a convention, so
|
|
30
|
-
adding a kind cannot silently widen what "exactly one field" means.
|
|
31
|
-
|
|
32
|
-
The two types deliberately do NOT compose, and ROADMAP_v2 §26 did not
|
|
33
|
-
change that. §22's P2 said a pass's LoopEvents are not forwarded up, on
|
|
34
|
-
the premise that a pass's internals are not worth seeing; a real ten-pass
|
|
35
|
-
run disproved the premise (a pass making fourteen tool calls over several
|
|
36
|
-
minutes was indistinguishable from one that had hung). So §26 amends P2:
|
|
37
|
-
core/reasoning/orchestrator.py now iterates
|
|
38
|
-
RunAgentLoop.stream_deep_research_mode() and TRANSLATES a chosen subset of
|
|
39
|
-
its LoopEvents into the pipeline kinds below.
|
|
40
|
-
|
|
41
|
-
Translated, not forwarded -- and the distinction is the whole amendment. A
|
|
42
|
-
consumer of this generator still receives exactly one event type, so no
|
|
43
|
-
`if event.token_delta:` read exists anywhere outside core/loop.py and the
|
|
44
|
-
streaming tests, which is what P1 and P2 were jointly protecting.
|
|
45
|
-
core/client.py, core/reasoning/json_retry.py and review.py's internals
|
|
46
|
-
remain untouched.
|
|
47
|
-
|
|
48
|
-
KNOWN LIMIT, stated rather than fixed: json_retry.py reaches the model via
|
|
49
|
-
continue_conversation(), which drains its own loop internally, so tool
|
|
50
|
-
calls made during a corrective JSON retry produce no tool_call event. The
|
|
51
|
-
retry itself is still visible -- that module appends a trace line per
|
|
52
|
-
failed parse, which _Progress's watermark carries as a trace_line.
|
|
53
|
-
|
|
54
|
-
ERROR HANDLING: there is deliberately no error variant, matching
|
|
55
|
-
core/events.py for the same reason. Exceptions raised mid-pipeline
|
|
56
|
-
propagate out of the generator unchanged, so the orchestrator's
|
|
57
|
-
`except Exception: update_pipeline_run(..., status="failed"); raise`
|
|
58
|
-
keeps working exactly as it did when the function was synchronous.
|
|
59
|
-
Turning failures into data-shaped events would require every consumer to
|
|
60
|
-
know to unpack and re-raise them.
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
from dataclasses import dataclass
|
|
64
|
-
from typing import Any, Optional
|
|
65
|
-
|
|
66
|
-
# Every kind stream_deep_research_pipeline() can yield. Named here rather
|
|
67
|
-
# than left implicit in the emission sites so a consumer can be written
|
|
68
|
-
# against the list, and so an unknown kind in a test is a typo rather
|
|
69
|
-
# than a silently-ignored event.
|
|
70
|
-
PIPELINE_EVENT_KINDS = (
|
|
71
|
-
"pass_start", # pass_id -- an LLM-backed pass is about to run
|
|
72
|
-
"pass_complete", # pass_id (+ ok/text) -- it returned. ok=False
|
|
73
|
-
# marks a pass that ENDED BADLY (#115/E14): text
|
|
74
|
-
# carries a short reason, mirroring tool_result,
|
|
75
|
-
# and no success line may be printed for it. A
|
|
76
|
-
# skipped ensemble candidate resolves this way
|
|
77
|
-
# while the run continues; a fatal pass emits it
|
|
78
|
-
# before its exception propagates.
|
|
79
|
-
"trace_line", # text -- one line appended to PipelineRun.trace
|
|
80
|
-
"claim_extracted", # claim_id + text -- Pass 2 produced a claim
|
|
81
|
-
"claim_tiered", # claim_id + tier -- Pass 5 (or a 6b round) scored it
|
|
82
|
-
"retry", # claim_id + attempt -- Pass 6a revised a claim
|
|
83
|
-
"run_complete", # run -- the terminal event, carrying the PipelineRun
|
|
84
|
-
# --- §26 ---------------------------------------------------------
|
|
85
|
-
"stage", # pass_id -- a ZERO-LLM stage completed. Pass 5 and
|
|
86
|
-
# 6c are passes by the pipeline's numbering and
|
|
87
|
-
# stages by their cost: they make no model call,
|
|
88
|
-
# so they complete instantly and can never be
|
|
89
|
-
# meaningfully "running". Consumers distinguish
|
|
90
|
-
# them by THIS kind (tui/widgets.py's is_stage,
|
|
91
|
-
# main.py's '..'), never by matching pass-id
|
|
92
|
-
# strings -- #84 deleted CODE_STAGES, an unused
|
|
93
|
-
# list of those strings whose only future was to
|
|
94
|
-
# drift away from the orchestrator's _stage()
|
|
95
|
-
# call sites while looking like a contract.
|
|
96
|
-
"tool_call", # pass_id + tool + text -- a pass invoked a tool
|
|
97
|
-
"tool_result", # pass_id + tool + ok (+ text when it failed)
|
|
98
|
-
"pass_activity", # pass_id + chars -- output streamed so far, throttled
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
# There is deliberately NO "step" kind. §26 set out to report which model
|
|
102
|
-
# call a pass was on, and _run() has no step marker to read: within one
|
|
103
|
-
# step it yields tool_call_start/tool_result in pairs, and BETWEEN steps it
|
|
104
|
-
# yields nothing at all unless the model happened to stream text. Inferring
|
|
105
|
-
# a boundary from that interleaving would be a guess presented as a fact,
|
|
106
|
-
# and growing LoopEvent to carry a real one is what P1's test forbids.
|
|
107
|
-
#
|
|
108
|
-
# So a consumer counts tool_call events itself -- derivation, not a second
|
|
109
|
-
# writer of related data -- and pass_activity covers the other half: a pass
|
|
110
|
-
# that calls no tools (Pass 1, final synthesis) still proves it is alive by
|
|
111
|
-
# how much it has written.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
@dataclass
|
|
115
|
-
class PipelineEvent:
|
|
116
|
-
"""One event yielded by stream_deep_research_pipeline().
|
|
117
|
-
|
|
118
|
-
`kind` says which of the fields below are meaningful; the rest stay
|
|
119
|
-
None. See PIPELINE_EVENT_KINDS for the mapping.
|
|
120
|
-
|
|
121
|
-
This type GROWS with its kinds, which is what P1 chose it for. The
|
|
122
|
-
contrast is LoopEvent, whose "exactly one field is populated" rule
|
|
123
|
-
lives in a docstring -- so an EIGHTH field there (it has seven: six
|
|
124
|
-
payload fields plus stop_reason) would silently widen a convention
|
|
125
|
-
nothing checks, and a test fails if one appears. Here the
|
|
126
|
-
discriminator is in the data, so a reader of `kind` cannot be wrong
|
|
127
|
-
about which fields to trust.
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
kind: str
|
|
131
|
-
pass_id: Optional[str] = None
|
|
132
|
-
text: Optional[str] = None
|
|
133
|
-
claim_id: Optional[str] = None
|
|
134
|
-
tier: Optional[str] = None
|
|
135
|
-
attempt: Optional[int] = None
|
|
136
|
-
# §26. `text` carries the tool's redacted param digest on a tool_call
|
|
137
|
-
# and the error message on a failed tool_result -- one field for "the
|
|
138
|
-
# human-readable detail", rather than two more that are each set on one
|
|
139
|
-
# kind.
|
|
140
|
-
tool: Optional[str] = None
|
|
141
|
-
ok: Optional[bool] = None
|
|
142
|
-
# Running total of characters the pass has streamed, on pass_activity.
|
|
143
|
-
# A total rather than a delta, so a consumer that drops an event (or
|
|
144
|
-
# attaches late) still renders the right number.
|
|
145
|
-
chars: Optional[int] = None
|
|
146
|
-
# PipelineRun on the terminal event. Typed Any to keep this module
|
|
147
|
-
# importable from anywhere without dragging base.py in behind it --
|
|
148
|
-
# the same reason LoopEvent.final_response is Any.
|
|
149
|
-
run: Optional[Any] = None
|
|
1
|
+
"""
|
|
2
|
+
core/reasoning/events.py
|
|
3
|
+
|
|
4
|
+
PipelineEvent is the single event type yielded by
|
|
5
|
+
core.reasoning.orchestrator.stream_deep_research_pipeline() as the
|
|
6
|
+
ten-pass research pipeline progresses. Consumers (the CLI's research
|
|
7
|
+
mode, the TUI's /research worker) iterate the generator and render what
|
|
8
|
+
they care about; run_pipeline_to_completion() drains it for callers that
|
|
9
|
+
only need the finished PipelineRun.
|
|
10
|
+
|
|
11
|
+
WHY THIS IS A SEPARATE TYPE FROM core.events.LoopEvent (ROADMAP_v2 §22
|
|
12
|
+
§22 AC4, decision P1). §22 required this decision be made and recorded
|
|
13
|
+
BEFORE any event was added, precisely so nobody discovered the problem at
|
|
14
|
+
§23. Three shapes were considered:
|
|
15
|
+
|
|
16
|
+
1. Add fields to LoopEvent. Rejected. LoopEvent is a flat dataclass
|
|
17
|
+
with an "exactly one field is populated" convention documented in a
|
|
18
|
+
docstring rather than in the type. That was right for six kinds;
|
|
19
|
+
§22 adds seven of a different family and §23 adds more, at which
|
|
20
|
+
point ~15 optional fields whose valid combinations live in prose
|
|
21
|
+
stops paying for itself.
|
|
22
|
+
2. A tagged union for both. Rejected as disproportionate: it rewrites
|
|
23
|
+
every `if event.token_delta:` read in tui/app.py, core/loop.py and
|
|
24
|
+
the streaming tests -- a §13-scale breakage inside a §22 change.
|
|
25
|
+
3. A separate, KIND-DISCRIMINATED type. Chosen. The two families have
|
|
26
|
+
different consumers and different lifetimes: a LoopEvent describes
|
|
27
|
+
one model call's progress and lives for a turn, a PipelineEvent
|
|
28
|
+
describes a ten-pass run and lives for the run. The `kind` field
|
|
29
|
+
puts the discriminator in the data rather than in a convention, so
|
|
30
|
+
adding a kind cannot silently widen what "exactly one field" means.
|
|
31
|
+
|
|
32
|
+
The two types deliberately do NOT compose, and ROADMAP_v2 §26 did not
|
|
33
|
+
change that. §22's P2 said a pass's LoopEvents are not forwarded up, on
|
|
34
|
+
the premise that a pass's internals are not worth seeing; a real ten-pass
|
|
35
|
+
run disproved the premise (a pass making fourteen tool calls over several
|
|
36
|
+
minutes was indistinguishable from one that had hung). So §26 amends P2:
|
|
37
|
+
core/reasoning/orchestrator.py now iterates
|
|
38
|
+
RunAgentLoop.stream_deep_research_mode() and TRANSLATES a chosen subset of
|
|
39
|
+
its LoopEvents into the pipeline kinds below.
|
|
40
|
+
|
|
41
|
+
Translated, not forwarded -- and the distinction is the whole amendment. A
|
|
42
|
+
consumer of this generator still receives exactly one event type, so no
|
|
43
|
+
`if event.token_delta:` read exists anywhere outside core/loop.py and the
|
|
44
|
+
streaming tests, which is what P1 and P2 were jointly protecting.
|
|
45
|
+
core/client.py, core/reasoning/json_retry.py and review.py's internals
|
|
46
|
+
remain untouched.
|
|
47
|
+
|
|
48
|
+
KNOWN LIMIT, stated rather than fixed: json_retry.py reaches the model via
|
|
49
|
+
continue_conversation(), which drains its own loop internally, so tool
|
|
50
|
+
calls made during a corrective JSON retry produce no tool_call event. The
|
|
51
|
+
retry itself is still visible -- that module appends a trace line per
|
|
52
|
+
failed parse, which _Progress's watermark carries as a trace_line.
|
|
53
|
+
|
|
54
|
+
ERROR HANDLING: there is deliberately no error variant, matching
|
|
55
|
+
core/events.py for the same reason. Exceptions raised mid-pipeline
|
|
56
|
+
propagate out of the generator unchanged, so the orchestrator's
|
|
57
|
+
`except Exception: update_pipeline_run(..., status="failed"); raise`
|
|
58
|
+
keeps working exactly as it did when the function was synchronous.
|
|
59
|
+
Turning failures into data-shaped events would require every consumer to
|
|
60
|
+
know to unpack and re-raise them.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
from dataclasses import dataclass
|
|
64
|
+
from typing import Any, Optional
|
|
65
|
+
|
|
66
|
+
# Every kind stream_deep_research_pipeline() can yield. Named here rather
|
|
67
|
+
# than left implicit in the emission sites so a consumer can be written
|
|
68
|
+
# against the list, and so an unknown kind in a test is a typo rather
|
|
69
|
+
# than a silently-ignored event.
|
|
70
|
+
PIPELINE_EVENT_KINDS = (
|
|
71
|
+
"pass_start", # pass_id -- an LLM-backed pass is about to run
|
|
72
|
+
"pass_complete", # pass_id (+ ok/text) -- it returned. ok=False
|
|
73
|
+
# marks a pass that ENDED BADLY (#115/E14): text
|
|
74
|
+
# carries a short reason, mirroring tool_result,
|
|
75
|
+
# and no success line may be printed for it. A
|
|
76
|
+
# skipped ensemble candidate resolves this way
|
|
77
|
+
# while the run continues; a fatal pass emits it
|
|
78
|
+
# before its exception propagates.
|
|
79
|
+
"trace_line", # text -- one line appended to PipelineRun.trace
|
|
80
|
+
"claim_extracted", # claim_id + text -- Pass 2 produced a claim
|
|
81
|
+
"claim_tiered", # claim_id + tier -- Pass 5 (or a 6b round) scored it
|
|
82
|
+
"retry", # claim_id + attempt -- Pass 6a revised a claim
|
|
83
|
+
"run_complete", # run -- the terminal event, carrying the PipelineRun
|
|
84
|
+
# --- §26 ---------------------------------------------------------
|
|
85
|
+
"stage", # pass_id -- a ZERO-LLM stage completed. Pass 5 and
|
|
86
|
+
# 6c are passes by the pipeline's numbering and
|
|
87
|
+
# stages by their cost: they make no model call,
|
|
88
|
+
# so they complete instantly and can never be
|
|
89
|
+
# meaningfully "running". Consumers distinguish
|
|
90
|
+
# them by THIS kind (tui/widgets.py's is_stage,
|
|
91
|
+
# main.py's '..'), never by matching pass-id
|
|
92
|
+
# strings -- #84 deleted CODE_STAGES, an unused
|
|
93
|
+
# list of those strings whose only future was to
|
|
94
|
+
# drift away from the orchestrator's _stage()
|
|
95
|
+
# call sites while looking like a contract.
|
|
96
|
+
"tool_call", # pass_id + tool + text -- a pass invoked a tool
|
|
97
|
+
"tool_result", # pass_id + tool + ok (+ text when it failed)
|
|
98
|
+
"pass_activity", # pass_id + chars -- output streamed so far, throttled
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# There is deliberately NO "step" kind. §26 set out to report which model
|
|
102
|
+
# call a pass was on, and _run() has no step marker to read: within one
|
|
103
|
+
# step it yields tool_call_start/tool_result in pairs, and BETWEEN steps it
|
|
104
|
+
# yields nothing at all unless the model happened to stream text. Inferring
|
|
105
|
+
# a boundary from that interleaving would be a guess presented as a fact,
|
|
106
|
+
# and growing LoopEvent to carry a real one is what P1's test forbids.
|
|
107
|
+
#
|
|
108
|
+
# So a consumer counts tool_call events itself -- derivation, not a second
|
|
109
|
+
# writer of related data -- and pass_activity covers the other half: a pass
|
|
110
|
+
# that calls no tools (Pass 1, final synthesis) still proves it is alive by
|
|
111
|
+
# how much it has written.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass
|
|
115
|
+
class PipelineEvent:
|
|
116
|
+
"""One event yielded by stream_deep_research_pipeline().
|
|
117
|
+
|
|
118
|
+
`kind` says which of the fields below are meaningful; the rest stay
|
|
119
|
+
None. See PIPELINE_EVENT_KINDS for the mapping.
|
|
120
|
+
|
|
121
|
+
This type GROWS with its kinds, which is what P1 chose it for. The
|
|
122
|
+
contrast is LoopEvent, whose "exactly one field is populated" rule
|
|
123
|
+
lives in a docstring -- so an EIGHTH field there (it has seven: six
|
|
124
|
+
payload fields plus stop_reason) would silently widen a convention
|
|
125
|
+
nothing checks, and a test fails if one appears. Here the
|
|
126
|
+
discriminator is in the data, so a reader of `kind` cannot be wrong
|
|
127
|
+
about which fields to trust.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
kind: str
|
|
131
|
+
pass_id: Optional[str] = None
|
|
132
|
+
text: Optional[str] = None
|
|
133
|
+
claim_id: Optional[str] = None
|
|
134
|
+
tier: Optional[str] = None
|
|
135
|
+
attempt: Optional[int] = None
|
|
136
|
+
# §26. `text` carries the tool's redacted param digest on a tool_call
|
|
137
|
+
# and the error message on a failed tool_result -- one field for "the
|
|
138
|
+
# human-readable detail", rather than two more that are each set on one
|
|
139
|
+
# kind.
|
|
140
|
+
tool: Optional[str] = None
|
|
141
|
+
ok: Optional[bool] = None
|
|
142
|
+
# Running total of characters the pass has streamed, on pass_activity.
|
|
143
|
+
# A total rather than a delta, so a consumer that drops an event (or
|
|
144
|
+
# attaches late) still renders the right number.
|
|
145
|
+
chars: Optional[int] = None
|
|
146
|
+
# PipelineRun on the terminal event. Typed Any to keep this module
|
|
147
|
+
# importable from anywhere without dragging base.py in behind it --
|
|
148
|
+
# the same reason LoopEvent.final_response is Any.
|
|
149
|
+
run: Optional[Any] = None
|
|
@@ -44,7 +44,8 @@ status='failed' record.
|
|
|
44
44
|
from __future__ import annotations
|
|
45
45
|
|
|
46
46
|
import json
|
|
47
|
-
from
|
|
47
|
+
from collections.abc import Callable
|
|
48
|
+
from typing import Any, Optional
|
|
48
49
|
|
|
49
50
|
import config
|
|
50
51
|
from core.reasoning.payload_validation import PayloadShapeError
|
|
@@ -85,6 +86,7 @@ def retry_until_json(
|
|
|
85
86
|
max_total_tokens: Optional[int] = None,
|
|
86
87
|
validate: Optional[Callable] = None,
|
|
87
88
|
effort: Optional[str] = None,
|
|
89
|
+
activity=None,
|
|
88
90
|
) -> str:
|
|
89
91
|
"""Returns the first response text that parses as JSON, retrying by
|
|
90
92
|
continuing `response`'s thread.
|
|
@@ -121,6 +123,16 @@ def retry_until_json(
|
|
|
121
123
|
PayloadShapeError re-enters this same loop. None means
|
|
122
124
|
"parse is the only contract", which is what the reviewer
|
|
123
125
|
wants and what every caller had before §30.
|
|
126
|
+
activity §47's agent-activity sink, forwarded for the same reason
|
|
127
|
+
as everything above it: a retry is the same run
|
|
128
|
+
continuing. It matters MORE here than elsewhere, not
|
|
129
|
+
less -- `continue_conversation` drains its own loop, so
|
|
130
|
+
a subagent spawned while the model is being corrected
|
|
131
|
+
reaches a shell through this channel or through nothing
|
|
132
|
+
(`tui/app.py`'s one-shot path carries it for exactly
|
|
133
|
+
that reason). No span is opened here: the caller's own
|
|
134
|
+
brackets the whole attempt-and-retry sequence, and a row
|
|
135
|
+
per correction would report one run as several.
|
|
124
136
|
"""
|
|
125
137
|
from core.loop import RunAgentLoop
|
|
126
138
|
|
|
@@ -165,6 +177,12 @@ def retry_until_json(
|
|
|
165
177
|
# continuing, so it carries the pass's effort too --
|
|
166
178
|
# effort_for re-validates against this thread's model.
|
|
167
179
|
effort=effort,
|
|
180
|
+
# And the same rule again for §47's sink (batch 75). This
|
|
181
|
+
# hop dropped it, so a spawn inside a corrective attempt
|
|
182
|
+
# was invisible -- and this is the one path where the
|
|
183
|
+
# channel is the ONLY route, because continue_conversation
|
|
184
|
+
# drains its own loop.
|
|
185
|
+
activity=activity,
|
|
168
186
|
**({} if max_total_tokens is None
|
|
169
187
|
else {"max_total_tokens": max_total_tokens}),
|
|
170
188
|
)
|