react-agent-harness 0.10.2__tar.gz → 0.11.0__tar.gz
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.
- {react_agent_harness-0.10.2/react_agent_harness.egg-info → react_agent_harness-0.11.0}/PKG-INFO +1 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/README.md +39 -3
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/agents/base.py +79 -25
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/console.py +284 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/events.py +4 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/hitl.py +5 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/anthropic.py +44 -5
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/persistent.py +402 -152
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/persistent_completion.py +54 -2
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/persistent_controls.py +102 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/persistent_prompt.py +4 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/working.py +46 -22
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/pyproject.toml +1 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0/react_agent_harness.egg-info}/PKG-INFO +1 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/react_agent_harness.egg-info/SOURCES.txt +2 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_agents_base.py +81 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_anthropic_llm.py +81 -0
- react_agent_harness-0.11.0/tests/test_console_renderer.py +321 -0
- react_agent_harness-0.11.0/tests/test_hitl_banner.py +34 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_persistent_agent.py +248 -1
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_persistent_completion.py +74 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_persistent_controls.py +80 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_subagent_tool.py +123 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_working_memory.py +57 -0
- react_agent_harness-0.11.0/tools/builtin/background.py +123 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/builtin/subagent.py +22 -1
- react_agent_harness-0.10.2/tests/test_console_renderer.py +0 -145
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/LICENSE +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/agents/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/annotation.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/cancellation.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/checkpoint.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/cli.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/executor_bridge.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/_streaming.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/auth.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/claude_code.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/fallback.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/openai.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/openai_codex.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/llm/routing.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/oauth_browser.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/otel.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/runtime.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/skills.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/steering.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/streaming.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/tool_policy.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/trace.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/trace_viewer.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/harness/utils.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/episodic_lance.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/manager.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/redis_store.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/memory/stores.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/orchestrator/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/orchestrator/planner.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/react_agent_harness.egg-info/dependency_links.txt +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/react_agent_harness.egg-info/entry_points.txt +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/react_agent_harness.egg-info/requires.txt +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/react_agent_harness.egg-info/top_level.txt +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/setup.cfg +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_annotation.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_budget_guard.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_cancellation.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_checkpoint_resume.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_claude_code_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_cli.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_executor_bridge.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_fallback_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_fan_in.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_http_fetch.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_llm_auth.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_mcp_adapter.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_mcp_auth.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_memory.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_memory_reconciler.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_memory_touchpoints.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_oauth_browser.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_openai_codex_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_openai_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_orchestrator.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_otel.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_parse_action_json.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_per_call_site_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_persistent_prompt.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_plan_approval.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_plan_mode.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_redis_store.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_resume_hint_banner.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_routing_llm.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_skills.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_steering.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_streaming.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_system_prompt_routing.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_tool_policy.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_trace.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_trailing_assistant_state.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_utils.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tests/test_vision.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/builtin/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/builtin/fetch_image.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/builtin/http_fetch.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/mcp/__init__.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/mcp/adapter.py +0 -0
- {react_agent_harness-0.10.2 → react_agent_harness-0.11.0}/tools/mcp/auth.py +0 -0
{react_agent_harness-0.10.2/react_agent_harness.egg-info → react_agent_harness-0.11.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: react-agent-harness
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Multi-agent LLM orchestration: hybrid DAG planning, two-tier memory, streaming, cost/token budgets with per-call-site breakdown
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
License-File: LICENSE
|
|
@@ -455,6 +455,18 @@ agents.register(AgentConfig(
|
|
|
455
455
|
))
|
|
456
456
|
```
|
|
457
457
|
|
|
458
|
+
### Tool observation budget
|
|
459
|
+
|
|
460
|
+
Tool results emitted on the event stream stay intact, but the observation
|
|
461
|
+
text appended back into the agent's working memory is capped by
|
|
462
|
+
`AgentConfig.max_observation_chars` (default `20_000`). This prevents a
|
|
463
|
+
single browser snapshot, MCP response, or shell output from dominating the
|
|
464
|
+
next LLM call. When capped, the model sees a structured JSON envelope with
|
|
465
|
+
`truncated`, `original_chars`, `shown_chars`, `omitted_chars`, and `content`.
|
|
466
|
+
|
|
467
|
+
Set `max_observation_chars=0` to disable this cap for agents that must feed
|
|
468
|
+
full raw tool output back into the next step.
|
|
469
|
+
|
|
458
470
|
Defaults are in-memory (`InMemorySemanticStore`, `InMemoryEpisodicStore`).
|
|
459
471
|
For durable storage:
|
|
460
472
|
|
|
@@ -623,8 +635,12 @@ main_agent = BaseAgent(
|
|
|
623
635
|
)
|
|
624
636
|
|
|
625
637
|
async for event in main_agent.run_stream(goal):
|
|
626
|
-
# Sub-agent
|
|
627
|
-
#
|
|
638
|
+
# Sub-agent events bubble up tagged with event.parent_agent_id so
|
|
639
|
+
# renderers can indent or group them.
|
|
640
|
+
# SUBAGENT_START fires before the sub's first event (payload:
|
|
641
|
+
# task, invocation_id).
|
|
642
|
+
# SUBAGENT_DONE fires after the sub's TASK_DONE (payload: success,
|
|
643
|
+
# steps, confidence, answer, error, invocation_id).
|
|
628
644
|
...
|
|
629
645
|
```
|
|
630
646
|
|
|
@@ -757,7 +773,7 @@ from harness.persistent_completion import SlashCommandCompleter
|
|
|
757
773
|
|
|
758
774
|
session = PromptSession(
|
|
759
775
|
history=FileHistory("~/.agent-harness/demo_history"),
|
|
760
|
-
completer=SlashCommandCompleter(app),
|
|
776
|
+
completer=SlashCommandCompleter(app, session_id_provider=lambda: session_id),
|
|
761
777
|
complete_while_typing=False, # Tab-triggered; doesn't query the store every keystroke
|
|
762
778
|
)
|
|
763
779
|
message = (await session.prompt_async("> ")).strip()
|
|
@@ -776,6 +792,8 @@ The demo uses that utility for:
|
|
|
776
792
|
- `/usage` shows persisted total and last-run provider-reported token usage
|
|
777
793
|
- `/models` lists switchable model names when an LLM registry is configured
|
|
778
794
|
- `/model [agent_id] [model|default]` shows or changes a session-scoped model override
|
|
795
|
+
- `/background <agent_id> <task>` launches a sub-agent task in the background for the current process
|
|
796
|
+
- `/tasks [collect|cancel] [id|all]` lists background tasks, appends completed results to the transcript, or cancels running work
|
|
779
797
|
- `/sessions [query]` lists known session ids, optionally filtered by id text
|
|
780
798
|
- `/memory` shows the cached per-session memory context
|
|
781
799
|
- `/save` flushes turns after the last reconcile checkpoint into long-term memory **without** evicting the cached prior (foreground prefix stays warm)
|
|
@@ -788,6 +806,22 @@ The demo uses that utility for:
|
|
|
788
806
|
- `/delete [id] confirm` deletes a transcript row; long-term memory is retained
|
|
789
807
|
- `/end` exits the demo — no auto-flush; call `/save` first if you want pending facts persisted
|
|
790
808
|
|
|
809
|
+
Background sub-agent tasks are process-local. They keep running while the
|
|
810
|
+
REPL/server process is alive; completed results become durable only when
|
|
811
|
+
collected into the session transcript with `/tasks collect <id|all>`. Avoid
|
|
812
|
+
launching overlapping work against the same sub-agent instance unless that
|
|
813
|
+
agent's tools and LLM adapter are safe for concurrent use.
|
|
814
|
+
|
|
815
|
+
When a `PersistentAgent` coordinator is wired with `SubAgentTool`s, it also
|
|
816
|
+
gets LLM-visible background tools automatically:
|
|
817
|
+
|
|
818
|
+
- `background_delegate_<agent_id>(task)` starts that sub-agent and returns a `task_id`
|
|
819
|
+
- `check_background_task(task_id)` reports status and any available result preview
|
|
820
|
+
- `collect_background_task(task_id)` returns the completed answer to the coordinator and appends it to the transcript
|
|
821
|
+
|
|
822
|
+
The regular `delegate_<agent_id>` tools remain blocking; background delegation
|
|
823
|
+
uses separate tool names so the model's intent is explicit in traces.
|
|
824
|
+
|
|
791
825
|
**Plan mode** (`/plan on`, or **Shift-Tab** at the prompt) gates each turn behind an approval step. The
|
|
792
826
|
coordinator's LLM produces a structured plan (`{summary, steps[]}`) before
|
|
793
827
|
any tools run; `PersistentAgent.chat` yields a `PLAN_PROPOSED` event so
|
|
@@ -935,6 +969,7 @@ Event types by path:
|
|
|
935
969
|
| `DISPATCH` | ✓ | — | — | — | — |
|
|
936
970
|
| `ROUTE` | ✓ (simple) | ✓ | — | — | — |
|
|
937
971
|
| `THOUGHT` / `TOKEN` / `ACTION` / `OBSERVATION` | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
972
|
+
| `SUBAGENT_START` / `SUBAGENT_DONE` | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
938
973
|
| `TASK_DONE` | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
939
974
|
| `PLAN` / `REPLAN` / `SYNTHESIS` / `DONE` | ✓ (complex) | — | — | ✓ | ✓ |
|
|
940
975
|
| `ERROR` | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
@@ -1781,6 +1816,7 @@ agents alongside HITL on the shell tool.
|
|
|
1781
1816
|
| `memory_context_enabled` | `True` | Prepend relevant long-term memory to the system prompt |
|
|
1782
1817
|
| `confidence_from_llm` | `True` | Use the `confidence` field from the LLM response; set `False` to always return `1.0` |
|
|
1783
1818
|
| `working_memory_max_tokens` | `None` (auto-derive from `llm.input_token_budget × 0.8`; pass an int to hard-cap) | Token budget for in-context working memory before rolling summarisation kicks in |
|
|
1819
|
+
| `max_observation_chars` | `20_000` | Character cap for model-facing tool observations appended to working memory; event payloads keep the original result. Set `0` to disable |
|
|
1784
1820
|
| `hitl_tools` | `[]` | Tool names that require human approval before execution |
|
|
1785
1821
|
| `checkpoint_every` | `0` | Write a crash-resumable checkpoint every N steps; `0` disables periodic checkpoints |
|
|
1786
1822
|
| `stream_tokens` | `False` | Emit `TOKEN` events as the LLM streams. Disabled by default — enable if you want to render partial output in real time: `AgentConfig(..., stream_tokens=True)` |
|
|
@@ -81,6 +81,11 @@ class AgentConfig:
|
|
|
81
81
|
# int to hard-cap the WorkingMemory eviction threshold — useful for
|
|
82
82
|
# cost-sensitive workloads or when feeding very small models.
|
|
83
83
|
working_memory_max_tokens: int | None = None
|
|
84
|
+
# Cap model-facing text appended after tool observations. Event payloads
|
|
85
|
+
# and traces still carry the original tool result; this only protects the
|
|
86
|
+
# next LLM prompt from oversized browser/MCP/shell observations. Set to
|
|
87
|
+
# 0 or a negative value to disable the cap.
|
|
88
|
+
max_observation_chars: int = 20_000
|
|
84
89
|
hitl_tools: list[str] = None # tools requiring human approval; None = no HITL
|
|
85
90
|
checkpoint_every: int = 0 # write a resumable checkpoint every N steps; 0 = disabled
|
|
86
91
|
# Cache tool results within a single run, keyed by (tool_name, args).
|
|
@@ -183,6 +188,8 @@ class BaseAgent:
|
|
|
183
188
|
self._guard = guard
|
|
184
189
|
self._llm = llm
|
|
185
190
|
self._checkpoint_store = checkpoint_store
|
|
191
|
+
self._checkpoint_resume_enabled: bool = True
|
|
192
|
+
self._hitl_resume_hint: str | None = None
|
|
186
193
|
self._working_memory: WorkingMemory | None = None
|
|
187
194
|
self._task: str = ""
|
|
188
195
|
self._last_think_error: str | None = None
|
|
@@ -479,7 +486,7 @@ class BaseAgent:
|
|
|
479
486
|
# ── ReAct Loop (stream) ───────────────────────────────────────────────────
|
|
480
487
|
|
|
481
488
|
async def _write_step_checkpoint(self, run_id: str, step: int) -> None:
|
|
482
|
-
if self._checkpoint_store is None:
|
|
489
|
+
if self._checkpoint_store is None or not self._checkpoint_resume_enabled:
|
|
483
490
|
return
|
|
484
491
|
await self._checkpoint_store.write(
|
|
485
492
|
self._ckp_id,
|
|
@@ -702,7 +709,9 @@ class BaseAgent:
|
|
|
702
709
|
for i, (act, obs) in enumerate(zip(parallel_actions, observations, strict=False)):
|
|
703
710
|
tool_name = act.get("tool", "")
|
|
704
711
|
tool_args = act.get("args", {})
|
|
705
|
-
|
|
712
|
+
is_img = _is_image_block(obs)
|
|
713
|
+
obs_raw = "[image]" if is_img else str(obs)
|
|
714
|
+
obs_display = obs_raw if is_img else obs_raw[:500]
|
|
706
715
|
self._tracer.log(
|
|
707
716
|
"action",
|
|
708
717
|
self.config.agent_id,
|
|
@@ -717,10 +726,10 @@ class BaseAgent:
|
|
|
717
726
|
BusEvent(
|
|
718
727
|
type=EventType.OBSERVATION,
|
|
719
728
|
agent_id=self.config.agent_id,
|
|
720
|
-
payload={"step": step, "tool": tool_name, "observation":
|
|
729
|
+
payload={"step": step, "tool": tool_name, "observation": obs_raw},
|
|
721
730
|
)
|
|
722
731
|
)
|
|
723
|
-
combined.append({"tool": tool_name, "result":
|
|
732
|
+
combined.append({"tool": tool_name, "result": obs_raw})
|
|
724
733
|
if obs and not isinstance(obs, str) and not _is_image_block(obs):
|
|
725
734
|
fire(
|
|
726
735
|
self._memory.write_working_fact(
|
|
@@ -776,7 +785,9 @@ class BaseAgent:
|
|
|
776
785
|
continue
|
|
777
786
|
|
|
778
787
|
await self._record_tool_observation(response, tool_name, observation)
|
|
779
|
-
|
|
788
|
+
is_img = _is_image_block(observation)
|
|
789
|
+
obs_raw = "[image]" if is_img else str(observation)
|
|
790
|
+
obs_display = obs_raw if is_img else obs_raw[:500]
|
|
780
791
|
self._tracer.log(
|
|
781
792
|
"action",
|
|
782
793
|
self.config.agent_id,
|
|
@@ -793,7 +804,7 @@ class BaseAgent:
|
|
|
793
804
|
payload={
|
|
794
805
|
"step": step,
|
|
795
806
|
"tool": tool_name,
|
|
796
|
-
"observation":
|
|
807
|
+
"observation": obs_raw,
|
|
797
808
|
},
|
|
798
809
|
)
|
|
799
810
|
|
|
@@ -1024,6 +1035,10 @@ class BaseAgent:
|
|
|
1024
1035
|
if not isinstance(observation, str)
|
|
1025
1036
|
else observation
|
|
1026
1037
|
)
|
|
1038
|
+
obs_text = _format_model_observation(
|
|
1039
|
+
obs_text,
|
|
1040
|
+
max_chars=self.config.max_observation_chars,
|
|
1041
|
+
)
|
|
1027
1042
|
await self._working_memory.append("user", f"Observation: {obs_text}")
|
|
1028
1043
|
|
|
1029
1044
|
async def _record_parallel_observations(
|
|
@@ -1038,7 +1053,11 @@ class BaseAgent:
|
|
|
1038
1053
|
content: list = [
|
|
1039
1054
|
{
|
|
1040
1055
|
"type": "text",
|
|
1041
|
-
"text":
|
|
1056
|
+
"text": "Observations:\n"
|
|
1057
|
+
+ _format_model_observation(
|
|
1058
|
+
json.dumps(combined, default=str),
|
|
1059
|
+
max_chars=self.config.max_observation_chars,
|
|
1060
|
+
),
|
|
1042
1061
|
}
|
|
1043
1062
|
]
|
|
1044
1063
|
for tool_name_img, img_block in image_blocks:
|
|
@@ -1048,7 +1067,11 @@ class BaseAgent:
|
|
|
1048
1067
|
return
|
|
1049
1068
|
await self._working_memory.append(
|
|
1050
1069
|
"user",
|
|
1051
|
-
|
|
1070
|
+
"Observations:\n"
|
|
1071
|
+
+ _format_model_observation(
|
|
1072
|
+
json.dumps(combined, default=str),
|
|
1073
|
+
max_chars=self.config.max_observation_chars,
|
|
1074
|
+
),
|
|
1052
1075
|
)
|
|
1053
1076
|
|
|
1054
1077
|
# ── Tool Execution ────────────────────────────────────────────────────────
|
|
@@ -1108,9 +1131,12 @@ class BaseAgent:
|
|
|
1108
1131
|
Run the HITL approval gate for one tool.
|
|
1109
1132
|
|
|
1110
1133
|
Returns ApprovalResponse if the tool is gated, None if not.
|
|
1111
|
-
Writes a crash-resumable checkpoint
|
|
1134
|
+
Writes a crash-resumable checkpoint before blocking when checkpoint
|
|
1135
|
+
resume is enabled.
|
|
1112
1136
|
"""
|
|
1113
|
-
if not
|
|
1137
|
+
if tool_name not in self.config.hitl_tools:
|
|
1138
|
+
return None
|
|
1139
|
+
if self._checkpoint_store is None and self._checkpoint_resume_enabled:
|
|
1114
1140
|
return None
|
|
1115
1141
|
|
|
1116
1142
|
from harness.hitl import ApprovalRequest, is_allowed, request_approval
|
|
@@ -1119,23 +1145,24 @@ class BaseAgent:
|
|
|
1119
1145
|
return None # fast-path: human already allowed this tool/prefix
|
|
1120
1146
|
|
|
1121
1147
|
approval_id = str(uuid.uuid4())
|
|
1122
|
-
|
|
1123
|
-
self.
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
"memory": self._working_memory.to_dict(),
|
|
1130
|
-
"pending": {
|
|
1131
|
-
"approval_id": approval_id,
|
|
1132
|
-
"tool": tool_name,
|
|
1133
|
-
"args": tool_args,
|
|
1148
|
+
if self._checkpoint_store is not None and self._checkpoint_resume_enabled:
|
|
1149
|
+
await self._checkpoint_store.write(
|
|
1150
|
+
self._ckp_id,
|
|
1151
|
+
{
|
|
1152
|
+
"run_id": run_id,
|
|
1153
|
+
"agent_id": self.config.agent_id,
|
|
1154
|
+
"task": self._task,
|
|
1134
1155
|
"step": step,
|
|
1135
|
-
"
|
|
1156
|
+
"memory": self._working_memory.to_dict(),
|
|
1157
|
+
"pending": {
|
|
1158
|
+
"approval_id": approval_id,
|
|
1159
|
+
"tool": tool_name,
|
|
1160
|
+
"args": tool_args,
|
|
1161
|
+
"step": step,
|
|
1162
|
+
"llm_response": llm_response,
|
|
1163
|
+
},
|
|
1136
1164
|
},
|
|
1137
|
-
|
|
1138
|
-
)
|
|
1165
|
+
)
|
|
1139
1166
|
return await request_approval(
|
|
1140
1167
|
ApprovalRequest(
|
|
1141
1168
|
approval_id=approval_id,
|
|
@@ -1145,6 +1172,7 @@ class BaseAgent:
|
|
|
1145
1172
|
args=tool_args,
|
|
1146
1173
|
step=step,
|
|
1147
1174
|
timestamp=datetime.now(timezone.utc).isoformat(),
|
|
1175
|
+
resume_hint=self._hitl_resume_hint if not self._checkpoint_resume_enabled else None,
|
|
1148
1176
|
),
|
|
1149
1177
|
self._guard,
|
|
1150
1178
|
)
|
|
@@ -1388,6 +1416,32 @@ def _split_system(messages: list[dict]) -> tuple[str | None, list[dict]]:
|
|
|
1388
1416
|
return system_text, rest
|
|
1389
1417
|
|
|
1390
1418
|
|
|
1419
|
+
# ── Tool observation shaping ─────────────────────────────────────────────────
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
def _format_model_observation(text: str, *, max_chars: int) -> str:
|
|
1423
|
+
"""Return the observation text appended to WorkingMemory.
|
|
1424
|
+
|
|
1425
|
+
The raw tool result is still emitted on the event stream before this
|
|
1426
|
+
method is involved. This cap only protects the *next* LLM call from
|
|
1427
|
+
oversized observations.
|
|
1428
|
+
"""
|
|
1429
|
+
if max_chars <= 0 or len(text) <= max_chars:
|
|
1430
|
+
return text
|
|
1431
|
+
omitted = len(text) - max_chars
|
|
1432
|
+
return json.dumps(
|
|
1433
|
+
{
|
|
1434
|
+
"truncated": True,
|
|
1435
|
+
"original_chars": len(text),
|
|
1436
|
+
"shown_chars": max_chars,
|
|
1437
|
+
"omitted_chars": omitted,
|
|
1438
|
+
"content": text[:max_chars],
|
|
1439
|
+
"note": "Tool observation was capped before the next LLM call.",
|
|
1440
|
+
},
|
|
1441
|
+
ensure_ascii=False,
|
|
1442
|
+
)
|
|
1443
|
+
|
|
1444
|
+
|
|
1391
1445
|
# ── Response normalization (module-level for testability) ────────────────────
|
|
1392
1446
|
|
|
1393
1447
|
|
|
@@ -4,7 +4,9 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import sys
|
|
7
|
+
import threading
|
|
7
8
|
from collections.abc import AsyncIterator
|
|
9
|
+
from dataclasses import dataclass
|
|
8
10
|
from typing import NamedTuple, TextIO
|
|
9
11
|
|
|
10
12
|
from harness.events import BusEvent, EventType
|
|
@@ -44,6 +46,8 @@ class ConsoleRenderer:
|
|
|
44
46
|
sep_width: Width of separator lines.
|
|
45
47
|
agent_label_width: Width of the ``[agent_id]`` label column.
|
|
46
48
|
show_tokens: If True, TOKEN events are printed inline.
|
|
49
|
+
spinner: If True, show a TTY-only busy spinner between events.
|
|
50
|
+
spinner_delay: Seconds to wait before drawing the spinner.
|
|
47
51
|
out: Output stream (defaults to ``sys.stdout``).
|
|
48
52
|
"""
|
|
49
53
|
|
|
@@ -55,6 +59,8 @@ class ConsoleRenderer:
|
|
|
55
59
|
sep_width: int = 72,
|
|
56
60
|
agent_label_width: int = 16,
|
|
57
61
|
show_tokens: bool = False,
|
|
62
|
+
spinner: bool = True,
|
|
63
|
+
spinner_delay: float = 0.4,
|
|
58
64
|
out: TextIO | None = None,
|
|
59
65
|
) -> None:
|
|
60
66
|
self._truncate = truncate
|
|
@@ -64,6 +70,17 @@ class ConsoleRenderer:
|
|
|
64
70
|
self._show_tokens = show_tokens
|
|
65
71
|
self._out = out or sys.stdout
|
|
66
72
|
self._in_token_stream = False
|
|
73
|
+
is_tty = bool(getattr(self._out, "isatty", lambda: False)())
|
|
74
|
+
self._spinner = _Spinner(
|
|
75
|
+
out=self._out,
|
|
76
|
+
enabled=spinner and is_tty,
|
|
77
|
+
delay=spinner_delay,
|
|
78
|
+
)
|
|
79
|
+
self._subagent_panel = _SubagentPanel(
|
|
80
|
+
out=self._out,
|
|
81
|
+
enabled=is_tty,
|
|
82
|
+
label_width=agent_label_width,
|
|
83
|
+
)
|
|
67
84
|
|
|
68
85
|
# ── public helpers ────────────────────────────────────────────────────────
|
|
69
86
|
|
|
@@ -73,6 +90,8 @@ class ConsoleRenderer:
|
|
|
73
90
|
|
|
74
91
|
def render(self, event: BusEvent) -> None:
|
|
75
92
|
"""Print formatted output for one BusEvent."""
|
|
93
|
+
self._spinner.stop()
|
|
94
|
+
self._subagent_panel.erase()
|
|
76
95
|
if event.type == EventType.TOKEN:
|
|
77
96
|
if self._show_tokens:
|
|
78
97
|
if not self._in_token_stream:
|
|
@@ -213,6 +232,27 @@ class ConsoleRenderer:
|
|
|
213
232
|
file=self._out,
|
|
214
233
|
)
|
|
215
234
|
|
|
235
|
+
elif t == EventType.SUBAGENT_START:
|
|
236
|
+
indent = " " if event.parent_agent_id else ""
|
|
237
|
+
print(
|
|
238
|
+
f"{indent}[{event.agent_id:<{self._label_w}}] → start {trunc(p.get('task', ''), 90)}",
|
|
239
|
+
file=self._out,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
elif t == EventType.SUBAGENT_DONE:
|
|
243
|
+
indent = " " if event.parent_agent_id else ""
|
|
244
|
+
if p.get("success"):
|
|
245
|
+
status = (
|
|
246
|
+
f"✓ done confidence={p.get('confidence', 0):.2f} steps={p.get('steps', '?')}"
|
|
247
|
+
)
|
|
248
|
+
else:
|
|
249
|
+
err = trunc(p.get("error", "unknown error"), 80)
|
|
250
|
+
status = f"✗ failed {err}"
|
|
251
|
+
print(
|
|
252
|
+
f"{indent}[{event.agent_id:<{self._label_w}}] {status}",
|
|
253
|
+
file=self._out,
|
|
254
|
+
)
|
|
255
|
+
|
|
216
256
|
elif t == EventType.TASK_DONE:
|
|
217
257
|
print(
|
|
218
258
|
f"{self._label(event)} ✓ done "
|
|
@@ -254,6 +294,17 @@ class ConsoleRenderer:
|
|
|
254
294
|
elif t == EventType.ERROR:
|
|
255
295
|
print(f"\n[error] {event.error}", file=sys.stderr)
|
|
256
296
|
|
|
297
|
+
self._subagent_panel.update(event)
|
|
298
|
+
if self._subagent_panel.should_draw:
|
|
299
|
+
self._subagent_panel.draw()
|
|
300
|
+
else:
|
|
301
|
+
self._schedule_spinner(event)
|
|
302
|
+
|
|
303
|
+
def close(self) -> None:
|
|
304
|
+
"""Stop any background spinner owned by this renderer."""
|
|
305
|
+
self._spinner.stop()
|
|
306
|
+
self._subagent_panel.erase()
|
|
307
|
+
|
|
257
308
|
def render_budget(self, budget: dict | None) -> None:
|
|
258
309
|
"""Print tokens + per-call-site breakdown from a ``BudgetGuard.snapshot()``
|
|
259
310
|
dict. Safe to call with ``{}`` or ``None`` — prints nothing when
|
|
@@ -323,7 +374,10 @@ class ConsoleRenderer:
|
|
|
323
374
|
return
|
|
324
375
|
terminal_holder[0] = event
|
|
325
376
|
|
|
326
|
-
|
|
377
|
+
try:
|
|
378
|
+
cancelled = await consume_with_cancel(events, on_event=_on_event)
|
|
379
|
+
finally:
|
|
380
|
+
self.close()
|
|
327
381
|
if cancelled and print_cancel_banner:
|
|
328
382
|
self.sep("═")
|
|
329
383
|
print(cancel_message, file=self._out)
|
|
@@ -336,3 +390,232 @@ class ConsoleRenderer:
|
|
|
336
390
|
if event.agent_id:
|
|
337
391
|
return f"[{event.agent_id:<{self._label_w}}]"
|
|
338
392
|
return f"[{event.type.value:<{self._label_w}}]"
|
|
393
|
+
|
|
394
|
+
def _schedule_spinner(self, event: BusEvent) -> None:
|
|
395
|
+
label = self._spinner_label(event)
|
|
396
|
+
if label:
|
|
397
|
+
self._spinner.start_later(label)
|
|
398
|
+
|
|
399
|
+
def _spinner_label(self, event: BusEvent) -> str | None:
|
|
400
|
+
if event.type in {
|
|
401
|
+
EventType.TASK_DONE,
|
|
402
|
+
EventType.DONE,
|
|
403
|
+
EventType.ERROR,
|
|
404
|
+
EventType.PLAN_PROPOSED,
|
|
405
|
+
EventType.HUMAN_GUIDANCE,
|
|
406
|
+
EventType.SYNTHESIS,
|
|
407
|
+
}:
|
|
408
|
+
return None
|
|
409
|
+
agent = event.agent_id or (
|
|
410
|
+
str(event.payload.get("agent_id")) if isinstance(event.payload, dict) else ""
|
|
411
|
+
)
|
|
412
|
+
agent = agent or event.type.value
|
|
413
|
+
if event.type == EventType.ACTION:
|
|
414
|
+
tool = event.payload.get("tool") if isinstance(event.payload, dict) else None
|
|
415
|
+
return f"[{agent}] using {tool or 'tool'}..."
|
|
416
|
+
if event.type in {EventType.OBSERVATION, EventType.CONTEXT, EventType.ROUTE}:
|
|
417
|
+
return f"[{agent}] thinking..."
|
|
418
|
+
if event.type in {EventType.DISPATCH, EventType.PLAN, EventType.REPLAN, EventType.MEMORY}:
|
|
419
|
+
return "[agent-harness] working..."
|
|
420
|
+
return None
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
class _Spinner:
|
|
424
|
+
_FRAMES = ("|", "/", "-", "\\")
|
|
425
|
+
|
|
426
|
+
def __init__(self, *, out: TextIO, enabled: bool, delay: float) -> None:
|
|
427
|
+
self._out = out
|
|
428
|
+
self._enabled = enabled
|
|
429
|
+
self._delay = max(0.0, delay)
|
|
430
|
+
self._stop = threading.Event()
|
|
431
|
+
self._thread: threading.Thread | None = None
|
|
432
|
+
|
|
433
|
+
def start_later(self, text: str) -> None:
|
|
434
|
+
if not self._enabled:
|
|
435
|
+
return
|
|
436
|
+
self.stop()
|
|
437
|
+
self._stop.clear()
|
|
438
|
+
self._thread = threading.Thread(
|
|
439
|
+
target=self._run,
|
|
440
|
+
args=(text,),
|
|
441
|
+
daemon=True,
|
|
442
|
+
)
|
|
443
|
+
self._thread.start()
|
|
444
|
+
|
|
445
|
+
def stop(self) -> None:
|
|
446
|
+
thread = self._thread
|
|
447
|
+
if thread is None:
|
|
448
|
+
return
|
|
449
|
+
self._stop.set()
|
|
450
|
+
if thread is not threading.current_thread():
|
|
451
|
+
thread.join(timeout=self._delay + 0.2)
|
|
452
|
+
self._thread = None
|
|
453
|
+
self._clear_line()
|
|
454
|
+
|
|
455
|
+
def _run(self, text: str) -> None:
|
|
456
|
+
if self._stop.wait(self._delay):
|
|
457
|
+
return
|
|
458
|
+
idx = 0
|
|
459
|
+
while not self._stop.is_set():
|
|
460
|
+
self._out.write(f"\r{text} {self._FRAMES[idx % len(self._FRAMES)]}")
|
|
461
|
+
self._out.flush()
|
|
462
|
+
idx += 1
|
|
463
|
+
if self._stop.wait(0.1):
|
|
464
|
+
break
|
|
465
|
+
|
|
466
|
+
def _clear_line(self) -> None:
|
|
467
|
+
if not self._enabled:
|
|
468
|
+
return
|
|
469
|
+
self._out.write("\r\033[K")
|
|
470
|
+
self._out.flush()
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
@dataclass
|
|
474
|
+
class _AgentRow:
|
|
475
|
+
agent_id: str
|
|
476
|
+
parent_agent_id: str
|
|
477
|
+
phase: str = "starting"
|
|
478
|
+
detail: str = ""
|
|
479
|
+
step: int | None = None
|
|
480
|
+
confidence: float | None = None
|
|
481
|
+
steps: int | None = None
|
|
482
|
+
active: bool = True
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
class _SubagentPanel:
|
|
486
|
+
"""TTY-only live table for concurrent sub-agent delegations."""
|
|
487
|
+
|
|
488
|
+
def __init__(self, *, out: TextIO, enabled: bool, label_width: int) -> None:
|
|
489
|
+
self._out = out
|
|
490
|
+
self._enabled = enabled
|
|
491
|
+
self._label_width = label_width
|
|
492
|
+
self._rows: dict[str, _AgentRow] = {}
|
|
493
|
+
self._drawn = 0
|
|
494
|
+
self._saw_parallel = False
|
|
495
|
+
|
|
496
|
+
@property
|
|
497
|
+
def should_draw(self) -> bool:
|
|
498
|
+
if not self._enabled or not self._rows:
|
|
499
|
+
return False
|
|
500
|
+
active = self._active_count()
|
|
501
|
+
return active >= 2 or (self._saw_parallel and active > 0)
|
|
502
|
+
|
|
503
|
+
def update(self, event: BusEvent) -> None:
|
|
504
|
+
if not self._enabled:
|
|
505
|
+
return
|
|
506
|
+
if event.type == EventType.SUBAGENT_START:
|
|
507
|
+
key = self._key(event)
|
|
508
|
+
self._rows[key] = _AgentRow(
|
|
509
|
+
agent_id=event.agent_id,
|
|
510
|
+
parent_agent_id=event.parent_agent_id,
|
|
511
|
+
)
|
|
512
|
+
if self._active_count() >= 2:
|
|
513
|
+
self._saw_parallel = True
|
|
514
|
+
return
|
|
515
|
+
|
|
516
|
+
if not event.parent_agent_id:
|
|
517
|
+
return
|
|
518
|
+
|
|
519
|
+
row = self._row_for(event)
|
|
520
|
+
if row is None:
|
|
521
|
+
return
|
|
522
|
+
|
|
523
|
+
if event.type == EventType.THOUGHT:
|
|
524
|
+
row.phase = "thinking"
|
|
525
|
+
row.detail = trunc(str(event.payload.get("thought", "")), 36)
|
|
526
|
+
step = _payload_int(event.payload.get("step"))
|
|
527
|
+
row.step = step if step is not None else row.step
|
|
528
|
+
elif event.type == EventType.ACTION:
|
|
529
|
+
row.phase = "action"
|
|
530
|
+
row.detail = str(event.payload.get("tool") or "tool")
|
|
531
|
+
step = _payload_int(event.payload.get("step"))
|
|
532
|
+
row.step = step if step is not None else row.step
|
|
533
|
+
elif event.type == EventType.CONTEXT:
|
|
534
|
+
row.phase = "context"
|
|
535
|
+
row.detail = f"{int(event.payload.get('tokens') or 0):,} tokens"
|
|
536
|
+
elif event.type == EventType.SUBAGENT_DONE:
|
|
537
|
+
row.active = False
|
|
538
|
+
row.phase = "done" if event.payload.get("success") else "failed"
|
|
539
|
+
row.detail = str(event.payload.get("error") or "")
|
|
540
|
+
row.confidence = _payload_float(event.payload.get("confidence"))
|
|
541
|
+
row.steps = _payload_int(event.payload.get("steps"))
|
|
542
|
+
if self._active_count() == 0:
|
|
543
|
+
self._rows.clear()
|
|
544
|
+
self._saw_parallel = False
|
|
545
|
+
|
|
546
|
+
def draw(self) -> None:
|
|
547
|
+
if not self.should_draw:
|
|
548
|
+
return
|
|
549
|
+
lines = ["Subagents"]
|
|
550
|
+
for row in self._rows.values():
|
|
551
|
+
lines.append(self._format_row(row))
|
|
552
|
+
self._out.write("\n".join(lines) + "\n")
|
|
553
|
+
self._out.flush()
|
|
554
|
+
self._drawn = len(lines)
|
|
555
|
+
|
|
556
|
+
def erase(self) -> None:
|
|
557
|
+
if not self._enabled or self._drawn <= 0:
|
|
558
|
+
return
|
|
559
|
+
for _ in range(self._drawn):
|
|
560
|
+
self._out.write("\033[A\r\033[2K")
|
|
561
|
+
self._out.flush()
|
|
562
|
+
self._drawn = 0
|
|
563
|
+
|
|
564
|
+
def _active_count(self) -> int:
|
|
565
|
+
return sum(1 for row in self._rows.values() if row.active)
|
|
566
|
+
|
|
567
|
+
def _row_for(self, event: BusEvent) -> _AgentRow | None:
|
|
568
|
+
key = self._key(event)
|
|
569
|
+
row = self._rows.get(key)
|
|
570
|
+
if row is not None:
|
|
571
|
+
return row
|
|
572
|
+
candidates = [
|
|
573
|
+
item
|
|
574
|
+
for item in self._rows.values()
|
|
575
|
+
if item.agent_id == event.agent_id
|
|
576
|
+
and item.parent_agent_id == event.parent_agent_id
|
|
577
|
+
and item.active
|
|
578
|
+
]
|
|
579
|
+
return candidates[-1] if candidates else None
|
|
580
|
+
|
|
581
|
+
def _key(self, event: BusEvent) -> str:
|
|
582
|
+
invocation_id = ""
|
|
583
|
+
if isinstance(event.payload, dict):
|
|
584
|
+
invocation_id = str(event.payload.get("invocation_id") or "")
|
|
585
|
+
if invocation_id:
|
|
586
|
+
return invocation_id
|
|
587
|
+
return f"{event.parent_agent_id}:{event.agent_id}"
|
|
588
|
+
|
|
589
|
+
def _format_row(self, row: _AgentRow) -> str:
|
|
590
|
+
agent = row.agent_id[: self._label_width]
|
|
591
|
+
status = "running" if row.active else row.phase
|
|
592
|
+
if row.active:
|
|
593
|
+
detail = f"{row.phase} {row.detail}".strip()
|
|
594
|
+
suffix = f"step {row.step}" if row.step is not None else ""
|
|
595
|
+
elif row.phase == "done":
|
|
596
|
+
detail = (
|
|
597
|
+
f"confidence {row.confidence:.2f}" if row.confidence is not None else "complete"
|
|
598
|
+
)
|
|
599
|
+
suffix = f"{row.steps} steps" if row.steps is not None else ""
|
|
600
|
+
else:
|
|
601
|
+
detail = trunc(row.detail or "failed", 36)
|
|
602
|
+
suffix = f"{row.steps} steps" if row.steps is not None else ""
|
|
603
|
+
return f" {agent:<{self._label_width}} {status:<8} {detail:<28} {suffix}".rstrip()
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def _payload_int(value: object) -> int | None:
|
|
607
|
+
if value is None:
|
|
608
|
+
return None
|
|
609
|
+
try:
|
|
610
|
+
return int(value)
|
|
611
|
+
except (TypeError, ValueError):
|
|
612
|
+
return None
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
def _payload_float(value: object) -> float | None:
|
|
616
|
+
if value is None:
|
|
617
|
+
return None
|
|
618
|
+
try:
|
|
619
|
+
return float(value)
|
|
620
|
+
except (TypeError, ValueError):
|
|
621
|
+
return None
|
|
@@ -21,12 +21,14 @@ Event lifecycle within a single goal:
|
|
|
21
21
|
HUMAN_GUIDANCE? — async steering drained at top of step
|
|
22
22
|
CONTEXT — working-memory context budget estimate
|
|
23
23
|
MEMORY — working-memory compaction/summarization marker
|
|
24
|
+
SUBAGENT_START? — SubAgentTool delegation began (before sub's first event)
|
|
24
25
|
THOUGHT — agent's next-step reasoning
|
|
25
26
|
TOKEN* — partial LLM output (only when client streams)
|
|
26
27
|
ACTION — agent chose a tool + args
|
|
27
28
|
OBSERVATION — tool returned a result
|
|
28
29
|
... (loop until)
|
|
29
30
|
TASK_DONE — agent finished a task; carries result payload
|
|
31
|
+
SUBAGENT_DONE? — SubAgentTool delegation finished (after sub's TASK_DONE)
|
|
30
32
|
REPLAN? — replan fired (low confidence or failure)
|
|
31
33
|
SYNTHESIS — synthesizer merged task results
|
|
32
34
|
DONE — orchestrator finished; payload is the final result dict
|
|
@@ -53,6 +55,8 @@ class EventType(str, Enum):
|
|
|
53
55
|
CONTEXT = "context"
|
|
54
56
|
MEMORY = "memory"
|
|
55
57
|
HUMAN_GUIDANCE = "human_guidance" # async steering injected at step boundary
|
|
58
|
+
SUBAGENT_START = "subagent_start" # SubAgentTool begins; payload: task, invocation_id
|
|
59
|
+
SUBAGENT_DONE = "subagent_done" # SubAgentTool finished; payload: success, steps, confidence
|
|
56
60
|
TASK_DONE = "task_done"
|
|
57
61
|
REPLAN = "replan"
|
|
58
62
|
SYNTHESIS = "synthesis"
|