react-agent-harness 0.11.1__tar.gz → 0.12.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.
Files changed (120) hide show
  1. {react_agent_harness-0.11.1/react_agent_harness.egg-info → react_agent_harness-0.12.0}/PKG-INFO +3 -3
  2. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/console.py +112 -4
  3. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/pyproject.toml +3 -3
  4. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0/react_agent_harness.egg-info}/PKG-INFO +3 -3
  5. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/react_agent_harness.egg-info/SOURCES.txt +1 -0
  6. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/react_agent_harness.egg-info/requires.txt +2 -2
  7. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_console_renderer.py +135 -1
  8. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_mcp_auth.py +14 -0
  9. react_agent_harness-0.12.0/tests/test_mcp_streamable_http.py +99 -0
  10. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/mcp/adapter.py +17 -7
  11. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/mcp/auth.py +5 -5
  12. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/LICENSE +0 -0
  13. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/README.md +0 -0
  14. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/agents/__init__.py +0 -0
  15. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/agents/base.py +0 -0
  16. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/__init__.py +0 -0
  17. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/agent_tree.py +0 -0
  18. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/annotation.py +0 -0
  19. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/background_tasks.py +0 -0
  20. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/cancellation.py +0 -0
  21. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/checkpoint.py +0 -0
  22. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/cli.py +0 -0
  23. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/events.py +0 -0
  24. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/executor_bridge.py +0 -0
  25. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/hitl.py +0 -0
  26. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/__init__.py +0 -0
  27. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/_streaming.py +0 -0
  28. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/anthropic.py +0 -0
  29. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/auth.py +0 -0
  30. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/claude_code.py +0 -0
  31. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/fallback.py +0 -0
  32. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/openai.py +0 -0
  33. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/openai_codex.py +0 -0
  34. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/llm/routing.py +0 -0
  35. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/model_switching.py +0 -0
  36. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/oauth_browser.py +0 -0
  37. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/otel.py +0 -0
  38. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/persistent.py +0 -0
  39. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/persistent_completion.py +0 -0
  40. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/persistent_controls.py +0 -0
  41. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/persistent_prompt.py +0 -0
  42. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/plan_mode.py +0 -0
  43. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/runtime.py +0 -0
  44. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/session_memory.py +0 -0
  45. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/skills.py +0 -0
  46. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/steering.py +0 -0
  47. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/streaming.py +0 -0
  48. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/tool_policy.py +0 -0
  49. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/trace.py +0 -0
  50. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/trace_viewer.py +0 -0
  51. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/harness/utils.py +0 -0
  52. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/__init__.py +0 -0
  53. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/episodic_lance.py +0 -0
  54. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/manager.py +0 -0
  55. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/redis_store.py +0 -0
  56. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/stores.py +0 -0
  57. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/memory/working.py +0 -0
  58. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/orchestrator/__init__.py +0 -0
  59. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/orchestrator/planner.py +0 -0
  60. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/react_agent_harness.egg-info/dependency_links.txt +0 -0
  61. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/react_agent_harness.egg-info/entry_points.txt +0 -0
  62. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/react_agent_harness.egg-info/top_level.txt +0 -0
  63. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/setup.cfg +0 -0
  64. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_agents_base.py +0 -0
  65. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_annotation.py +0 -0
  66. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_anthropic_llm.py +0 -0
  67. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_background_tasks.py +0 -0
  68. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_budget_guard.py +0 -0
  69. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_cancellation.py +0 -0
  70. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_checkpoint_resume.py +0 -0
  71. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_claude_code_llm.py +0 -0
  72. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_cli.py +0 -0
  73. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_event_payloads.py +0 -0
  74. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_executor_bridge.py +0 -0
  75. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_fallback_llm.py +0 -0
  76. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_fan_in.py +0 -0
  77. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_hitl_banner.py +0 -0
  78. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_http_fetch.py +0 -0
  79. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_llm_auth.py +0 -0
  80. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_mcp_adapter.py +0 -0
  81. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_memory.py +0 -0
  82. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_memory_reconciler.py +0 -0
  83. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_memory_touchpoints.py +0 -0
  84. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_model_switching.py +0 -0
  85. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_oauth_browser.py +0 -0
  86. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_openai_codex_llm.py +0 -0
  87. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_openai_llm.py +0 -0
  88. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_orchestrator.py +0 -0
  89. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_otel.py +0 -0
  90. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_parse_action_json.py +0 -0
  91. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_per_call_site_llm.py +0 -0
  92. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_persistent_agent.py +0 -0
  93. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_persistent_completion.py +0 -0
  94. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_persistent_controls.py +0 -0
  95. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_persistent_prompt.py +0 -0
  96. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_plan_approval.py +0 -0
  97. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_plan_mode.py +0 -0
  98. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_plan_mode_controller.py +0 -0
  99. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_redis_store.py +0 -0
  100. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_resume_hint_banner.py +0 -0
  101. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_routing_llm.py +0 -0
  102. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_session_memory.py +0 -0
  103. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_skills.py +0 -0
  104. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_steering.py +0 -0
  105. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_streaming.py +0 -0
  106. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_subagent_tool.py +0 -0
  107. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_system_prompt_routing.py +0 -0
  108. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_tool_policy.py +0 -0
  109. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_trace.py +0 -0
  110. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_trailing_assistant_state.py +0 -0
  111. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_utils.py +0 -0
  112. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_vision.py +0 -0
  113. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tests/test_working_memory.py +0 -0
  114. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/__init__.py +0 -0
  115. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/builtin/__init__.py +0 -0
  116. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/builtin/background.py +0 -0
  117. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/builtin/fetch_image.py +0 -0
  118. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/builtin/http_fetch.py +0 -0
  119. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/builtin/subagent.py +0 -0
  120. {react_agent_harness-0.11.1 → react_agent_harness-0.12.0}/tools/mcp/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: react-agent-harness
3
- Version: 0.11.1
3
+ Version: 0.12.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
@@ -18,7 +18,7 @@ Requires-Dist: openai>=1.0; extra == "openai"
18
18
  Provides-Extra: http
19
19
  Requires-Dist: httpx>=0.27; extra == "http"
20
20
  Provides-Extra: mcp
21
- Requires-Dist: mcp>=1.0; extra == "mcp"
21
+ Requires-Dist: mcp>=2; extra == "mcp"
22
22
  Provides-Extra: otel
23
23
  Requires-Dist: opentelemetry-api>=1.20; extra == "otel"
24
24
  Requires-Dist: opentelemetry-sdk>=1.20; extra == "otel"
@@ -34,7 +34,7 @@ Requires-Dist: fakeredis>=2.20; extra == "dev"
34
34
  Requires-Dist: httpx>=0.27; extra == "dev"
35
35
  Requires-Dist: openai>=1.0; extra == "dev"
36
36
  Requires-Dist: respx>=0.21; extra == "dev"
37
- Requires-Dist: mcp>=1.0; extra == "dev"
37
+ Requires-Dist: mcp>=2; extra == "dev"
38
38
  Requires-Dist: opentelemetry-api>=1.20; extra == "dev"
39
39
  Requires-Dist: opentelemetry-sdk>=1.20; extra == "dev"
40
40
  Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20; extra == "dev"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import shutil
6
7
  import sys
7
8
  import threading
8
9
  from collections.abc import AsyncIterator
@@ -34,6 +35,65 @@ def trunc(s: str, n: int) -> str:
34
35
  return s if len(s) <= n else s[:n] + "…"
35
36
 
36
37
 
38
+ def clip_middle(s: str, n: int) -> str:
39
+ """Fit *s* into *n* characters by eliding its middle.
40
+
41
+ Unlike :func:`trunc` this keeps the end of the line, which is where a
42
+ single-line tool result (a status, an error) usually carries its point.
43
+ """
44
+ if len(s) <= n or n <= 1:
45
+ return trunc(s, n)
46
+ head = (n - 1) * 2 // 3
47
+ tail = n - 1 - head
48
+ return f"{s[:head]}…{s[-tail:]}" if tail else f"{s[:head]}…"
49
+
50
+
51
+ class _Excerpt(NamedTuple):
52
+ """A head+tail view of multi-line text, with the middle elided.
53
+
54
+ Tool output carries context at the top (the command, a header row) and
55
+ the verdict at the bottom, so both ends are worth keeping.
56
+ """
57
+
58
+ head: list[str]
59
+ tail: list[str]
60
+ elided: int
61
+ total_lines: int
62
+ total_chars: int
63
+
64
+ @property
65
+ def truncated(self) -> bool:
66
+ return self.elided > 0
67
+
68
+
69
+ def excerpt(text: str, *, head_lines: int, tail_lines: int) -> _Excerpt:
70
+ """Split *text* into leading and trailing line windows.
71
+
72
+ When the text fits within ``head_lines + tail_lines`` every line lands in
73
+ ``head`` and ``tail`` is empty, so callers can render the two windows
74
+ unconditionally.
75
+ """
76
+ head_lines = max(0, head_lines)
77
+ tail_lines = max(0, tail_lines)
78
+ lines = text.splitlines()
79
+ total = len(lines)
80
+ if total <= head_lines + tail_lines:
81
+ return _Excerpt(
82
+ head=lines,
83
+ tail=[],
84
+ elided=0,
85
+ total_lines=total,
86
+ total_chars=len(text),
87
+ )
88
+ return _Excerpt(
89
+ head=lines[:head_lines],
90
+ tail=lines[total - tail_lines :] if tail_lines else [],
91
+ elided=total - head_lines - tail_lines,
92
+ total_lines=total,
93
+ total_chars=len(text),
94
+ )
95
+
96
+
37
97
  class ConsoleRenderer:
38
98
  """Renders BusEvent objects to a text stream.
39
99
 
@@ -48,6 +108,12 @@ class ConsoleRenderer:
48
108
  show_tokens: If True, TOKEN events are printed inline.
49
109
  spinner: If True, show a TTY-only busy spinner between events.
50
110
  spinner_delay: Seconds to wait before drawing the spinner.
111
+ excerpt_large_outputs: Render large observations as a head+tail excerpt
112
+ instead of first-N-character truncation.
113
+ excerpt_head_lines: Lines to show from the start of an observation.
114
+ excerpt_tail_lines: Lines to show from the end of an observation.
115
+ width: Display width for excerpt lines; None auto-detects
116
+ the terminal size at render time.
51
117
  out: Output stream (defaults to ``sys.stdout``).
52
118
  """
53
119
 
@@ -61,6 +127,10 @@ class ConsoleRenderer:
61
127
  show_tokens: bool = False,
62
128
  spinner: bool = True,
63
129
  spinner_delay: float = 0.4,
130
+ excerpt_large_outputs: bool = True,
131
+ excerpt_head_lines: int = 2,
132
+ excerpt_tail_lines: int = 5,
133
+ width: int | None = None,
64
134
  out: TextIO | None = None,
65
135
  ) -> None:
66
136
  self._truncate = truncate
@@ -68,6 +138,10 @@ class ConsoleRenderer:
68
138
  self._sep_width = sep_width
69
139
  self._label_w = agent_label_width
70
140
  self._show_tokens = show_tokens
141
+ self._excerpt_large_outputs = excerpt_large_outputs
142
+ self._excerpt_head_lines = excerpt_head_lines
143
+ self._excerpt_tail_lines = excerpt_tail_lines
144
+ self._width = width
71
145
  self._out = out or sys.stdout
72
146
  self._in_token_stream = False
73
147
  is_tty = bool(getattr(self._out, "isatty", lambda: False)())
@@ -190,10 +264,7 @@ class ConsoleRenderer:
190
264
 
191
265
  elif t == EventType.OBSERVATION:
192
266
  obs = p.get("observation", "")
193
- print(
194
- f"{self._label(event)} obs {trunc(obs, 110)}",
195
- file=self._out,
196
- )
267
+ self._render_observation(event, str(obs))
197
268
 
198
269
  elif t == EventType.CONTEXT:
199
270
  tokens = int(p.get("tokens") or 0)
@@ -391,6 +462,43 @@ class ConsoleRenderer:
391
462
  return f"[{event.agent_id:<{self._label_w}}]"
392
463
  return f"[{event.type.value:<{self._label_w}}]"
393
464
 
465
+ def _render_observation(self, event: BusEvent, obs: str) -> None:
466
+ label = self._label(event)
467
+ large = len(obs) > self._truncate or "\n" in obs
468
+ if not (self._excerpt_large_outputs and large):
469
+ print(f"{label} obs {trunc(obs, self._truncate)}", file=self._out)
470
+ return
471
+
472
+ view = excerpt(
473
+ obs,
474
+ head_lines=self._excerpt_head_lines,
475
+ tail_lines=self._excerpt_tail_lines,
476
+ )
477
+ self._print_excerpt(label, view)
478
+
479
+ def _print_excerpt(self, label: str, view: _Excerpt) -> None:
480
+ shown = len(view.head) + len(view.tail)
481
+ if view.truncated:
482
+ summary = f"{shown} of {view.total_lines:,} lines / {view.total_chars:,} chars"
483
+ else:
484
+ plural = "" if view.total_lines == 1 else "s"
485
+ summary = f"{view.total_lines:,} line{plural} / {view.total_chars:,} chars"
486
+ print(f"{label} obs [{summary}]", file=self._out)
487
+
488
+ indent = self._label_w + 11
489
+ avail = max(20, self._line_width() - indent - 1)
490
+ for line in view.head:
491
+ print(f"{'':<{indent}}{clip_middle(line, avail)}", file=self._out)
492
+ if view.truncated:
493
+ print(f"{'':<{indent}}… {view.elided:,} lines elided …", file=self._out)
494
+ for line in view.tail:
495
+ print(f"{'':<{indent}}{clip_middle(line, avail)}", file=self._out)
496
+
497
+ def _line_width(self) -> int:
498
+ if self._width is not None:
499
+ return self._width
500
+ return shutil.get_terminal_size((100, 24)).columns
501
+
394
502
  def _schedule_spinner(self, event: BusEvent) -> None:
395
503
  label = self._spinner_label(event)
396
504
  if label:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "react-agent-harness"
7
- version = "0.11.1"
7
+ version = "0.12.0"
8
8
  description = "Multi-agent LLM orchestration: hybrid DAG planning, two-tier memory, streaming, cost/token budgets with per-call-site breakdown"
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
@@ -33,7 +33,7 @@ openai = ["openai>=1.0"]
33
33
  # HTTP-fetch builtin tool — async client.
34
34
  http = ["httpx>=0.27"]
35
35
  # MCP (Model Context Protocol) tool adapter.
36
- mcp = ["mcp>=1.0"]
36
+ mcp = ["mcp>=2"]
37
37
  # OpenTelemetry tracing — visualise runs in Jaeger / Datadog / etc.
38
38
  otel = [
39
39
  "opentelemetry-api>=1.20",
@@ -52,7 +52,7 @@ dev = [
52
52
  "httpx>=0.27",
53
53
  "openai>=1.0",
54
54
  "respx>=0.21",
55
- "mcp>=1.0",
55
+ "mcp>=2",
56
56
  "opentelemetry-api>=1.20",
57
57
  "opentelemetry-sdk>=1.20",
58
58
  "opentelemetry-exporter-otlp-proto-http>=1.20",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: react-agent-harness
3
- Version: 0.11.1
3
+ Version: 0.12.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
@@ -18,7 +18,7 @@ Requires-Dist: openai>=1.0; extra == "openai"
18
18
  Provides-Extra: http
19
19
  Requires-Dist: httpx>=0.27; extra == "http"
20
20
  Provides-Extra: mcp
21
- Requires-Dist: mcp>=1.0; extra == "mcp"
21
+ Requires-Dist: mcp>=2; extra == "mcp"
22
22
  Provides-Extra: otel
23
23
  Requires-Dist: opentelemetry-api>=1.20; extra == "otel"
24
24
  Requires-Dist: opentelemetry-sdk>=1.20; extra == "otel"
@@ -34,7 +34,7 @@ Requires-Dist: fakeredis>=2.20; extra == "dev"
34
34
  Requires-Dist: httpx>=0.27; extra == "dev"
35
35
  Requires-Dist: openai>=1.0; extra == "dev"
36
36
  Requires-Dist: respx>=0.21; extra == "dev"
37
- Requires-Dist: mcp>=1.0; extra == "dev"
37
+ Requires-Dist: mcp>=2; extra == "dev"
38
38
  Requires-Dist: opentelemetry-api>=1.20; extra == "dev"
39
39
  Requires-Dist: opentelemetry-sdk>=1.20; extra == "dev"
40
40
  Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20; extra == "dev"
@@ -73,6 +73,7 @@ tests/test_http_fetch.py
73
73
  tests/test_llm_auth.py
74
74
  tests/test_mcp_adapter.py
75
75
  tests/test_mcp_auth.py
76
+ tests/test_mcp_streamable_http.py
76
77
  tests/test_memory.py
77
78
  tests/test_memory_reconciler.py
78
79
  tests/test_memory_touchpoints.py
@@ -14,7 +14,7 @@ fakeredis>=2.20
14
14
  httpx>=0.27
15
15
  openai>=1.0
16
16
  respx>=0.21
17
- mcp>=1.0
17
+ mcp>=2
18
18
  opentelemetry-api>=1.20
19
19
  opentelemetry-sdk>=1.20
20
20
  opentelemetry-exporter-otlp-proto-http>=1.20
@@ -28,7 +28,7 @@ pyarrow>=14
28
28
  sentence-transformers>=2.7
29
29
 
30
30
  [mcp]
31
- mcp>=1.0
31
+ mcp>=2
32
32
 
33
33
  [openai]
34
34
  openai>=1.0
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import time
4
4
  from io import StringIO
5
5
 
6
- from harness.console import ConsoleRenderer
6
+ from harness.console import ConsoleRenderer, excerpt
7
7
  from harness.events import BusEvent, EventType
8
8
 
9
9
 
@@ -195,6 +195,140 @@ def test_console_renderer_spinner_draws_and_clears_before_next_event():
195
195
  assert "[agent ] obs" in text
196
196
 
197
197
 
198
+ def test_console_renderer_small_observation_stays_single_line():
199
+ out = StringIO()
200
+ renderer = ConsoleRenderer(out=out)
201
+
202
+ renderer.render(
203
+ BusEvent(
204
+ type=EventType.OBSERVATION,
205
+ agent_id="agent",
206
+ payload={"observation": "done"},
207
+ )
208
+ )
209
+
210
+ text = out.getvalue()
211
+ assert "[agent ] obs done" in text
212
+ assert "lines /" not in text
213
+
214
+
215
+ def test_excerpt_splits_head_and_tail_with_elided_middle():
216
+ view = excerpt("\n".join(f"line {i}" for i in range(1, 11)), head_lines=2, tail_lines=3)
217
+
218
+ assert view.head == ["line 1", "line 2"]
219
+ assert view.tail == ["line 8", "line 9", "line 10"]
220
+ assert view.elided == 5
221
+ assert view.total_lines == 10
222
+ assert view.truncated is True
223
+
224
+
225
+ def test_excerpt_keeps_everything_when_text_fits():
226
+ view = excerpt("a\nb\nc", head_lines=2, tail_lines=3)
227
+
228
+ assert view.head == ["a", "b", "c"]
229
+ assert view.tail == []
230
+ assert view.elided == 0
231
+ assert view.truncated is False
232
+
233
+
234
+ def test_console_renderer_large_observation_keeps_head_and_tail():
235
+ out = StringIO()
236
+ renderer = ConsoleRenderer(out=out, truncate=20, width=200)
237
+ observation = "\n".join(f"line {idx}" for idx in range(1, 21))
238
+
239
+ renderer.render(
240
+ BusEvent(
241
+ type=EventType.OBSERVATION,
242
+ agent_id="agent",
243
+ payload={"observation": observation},
244
+ )
245
+ )
246
+
247
+ text = out.getvalue()
248
+ assert "[7 of 20 lines /" in text
249
+ assert "line 1" in text
250
+ assert "line 2" in text
251
+ assert "… 13 lines elided …" in text
252
+ assert "line 20" in text
253
+ assert "line 10" not in text
254
+
255
+
256
+ def test_console_renderer_short_multiline_observation_shows_every_line():
257
+ out = StringIO()
258
+ renderer = ConsoleRenderer(out=out, truncate=20, width=200)
259
+ observation = "\n".join(f"line {idx}" for idx in range(1, 6))
260
+
261
+ renderer.render(
262
+ BusEvent(
263
+ type=EventType.OBSERVATION,
264
+ agent_id="agent",
265
+ payload={"observation": observation},
266
+ )
267
+ )
268
+
269
+ text = out.getvalue()
270
+ assert "[5 lines /" in text
271
+ assert "elided" not in text
272
+ for idx in range(1, 6):
273
+ assert f"line {idx}" in text
274
+
275
+
276
+ def test_console_renderer_clips_wide_lines_to_display_width():
277
+ out = StringIO()
278
+ renderer = ConsoleRenderer(out=out, truncate=20, width=80)
279
+ observation = "prefix-" + ("x" * 4_000) + "-tail"
280
+
281
+ renderer.render(
282
+ BusEvent(
283
+ type=EventType.OBSERVATION,
284
+ agent_id="agent",
285
+ payload={"observation": observation},
286
+ )
287
+ )
288
+
289
+ text = out.getvalue()
290
+ assert "prefix-" in text
291
+ assert "-tail" in text
292
+ assert len(observation) not in {len(line) for line in text.splitlines()}
293
+ assert max(len(line) for line in text.splitlines()) <= 80
294
+
295
+
296
+ def test_console_renderer_tty_observation_renders_once_for_completed_event():
297
+ out = _TTYStringIO()
298
+ renderer = ConsoleRenderer(out=out, truncate=20, width=200)
299
+ observation = "\n".join(f"line {idx}" for idx in range(1, 21))
300
+
301
+ renderer.render(
302
+ BusEvent(
303
+ type=EventType.OBSERVATION,
304
+ agent_id="agent",
305
+ payload={"observation": observation},
306
+ )
307
+ )
308
+
309
+ text = out.getvalue()
310
+ assert text.count("lines elided") == 1
311
+ assert "\033[A\r\033[2K" not in text
312
+
313
+
314
+ def test_console_renderer_excerpt_can_be_disabled_for_old_truncation():
315
+ out = StringIO()
316
+ renderer = ConsoleRenderer(out=out, truncate=20, excerpt_large_outputs=False)
317
+
318
+ renderer.render(
319
+ BusEvent(
320
+ type=EventType.OBSERVATION,
321
+ agent_id="agent",
322
+ payload={"observation": "prefix-" + ("x" * 80) + "-tail"},
323
+ )
324
+ )
325
+
326
+ text = out.getvalue()
327
+ assert "prefix-" in text
328
+ assert "-tail" not in text
329
+ assert "lines /" not in text
330
+
331
+
198
332
  def test_console_renderer_terminal_events_do_not_restart_spinner():
199
333
  out = _TTYStringIO()
200
334
  renderer = ConsoleRenderer(out=out, spinner=True, spinner_delay=0)
@@ -291,6 +291,20 @@ def test_browser_oauth_httpx_auth_constructs_lazily():
291
291
  assert auth.httpx_auth is provider
292
292
 
293
293
 
294
+ def test_browser_oauth_provider_is_an_httpx2_auth():
295
+ """The transport hands this to httpx2.AsyncClient(auth=...), which rejects
296
+ anything that isn't an httpx2.Auth. mcp>=2 moved off httpx, so this pins
297
+ the provider to the client library the transport actually uses."""
298
+ import httpx2
299
+
300
+ auth = BrowserOAuthMCPAuth(
301
+ server_url="https://mcp.example.com/",
302
+ provider_name="mcp:example",
303
+ )
304
+
305
+ assert isinstance(auth.httpx_auth, httpx2.Auth)
306
+
307
+
294
308
  async def test_browser_oauth_static_client_id_seeds_storage(tmp_path):
295
309
  """Pre-registered client_id should be written to storage so the SDK skips
296
310
  dynamic registration (which would fail against providers that don't
@@ -0,0 +1,99 @@
1
+ """End-to-end streamable-HTTP transport test against a real in-process MCP server.
2
+
3
+ The streamable-HTTP path is pure SDK wiring — headers, timeouts and auth are
4
+ folded into an ``httpx2.AsyncClient`` that we hand to ``streamable_http_client``.
5
+ Mocks would only assert that we call what we think we call, so this starts an
6
+ actual server on a loopback port and drives a real connection through it.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import asyncio
12
+ import socket
13
+
14
+ import pytest
15
+
16
+ from tools.mcp.adapter import MCPServerConnection
17
+ from tools.mcp.auth import ApiKeyMCPAuth, StreamableHttpServerParams
18
+
19
+ pytestmark = pytest.mark.anyio
20
+
21
+
22
+ def _free_port() -> int:
23
+ with socket.socket() as s:
24
+ s.bind(("127.0.0.1", 0))
25
+ return int(s.getsockname()[1])
26
+
27
+
28
+ @pytest.fixture
29
+ def anyio_backend() -> str:
30
+ return "asyncio"
31
+
32
+
33
+ async def _serve(port: int, seen_headers: dict[str, str]) -> asyncio.Task[None]:
34
+ """Start an MCP server exposing one tool; return the serving task."""
35
+ import uvicorn
36
+ from mcp.server import MCPServer
37
+
38
+ server = MCPServer(name="test-server")
39
+
40
+ @server.tool()
41
+ def add(a: int, b: int) -> int:
42
+ """Add two numbers."""
43
+ return a + b
44
+
45
+ app = server.streamable_http_app()
46
+
47
+ class _CaptureHeaders:
48
+ def __init__(self, inner):
49
+ self._inner = inner
50
+
51
+ async def __call__(self, scope, receive, send):
52
+ if scope["type"] == "http":
53
+ seen_headers.update({k.decode(): v.decode() for k, v in scope.get("headers", [])})
54
+ await self._inner(scope, receive, send)
55
+
56
+ config = uvicorn.Config(
57
+ _CaptureHeaders(app),
58
+ host="127.0.0.1",
59
+ port=port,
60
+ log_level="error",
61
+ lifespan="on",
62
+ )
63
+ uv = uvicorn.Server(config)
64
+ task = asyncio.create_task(uv.serve())
65
+
66
+ for _ in range(200):
67
+ if uv.started:
68
+ return task
69
+ await asyncio.sleep(0.05)
70
+ task.cancel()
71
+ raise RuntimeError("server did not start")
72
+
73
+
74
+ async def test_streamable_http_connect_discovers_and_calls_tool(monkeypatch):
75
+ port = _free_port()
76
+ seen_headers: dict[str, str] = {}
77
+ task = await _serve(port, seen_headers)
78
+
79
+ try:
80
+ monkeypatch.setenv("TEST_MCP_KEY", "secret-value")
81
+ params = StreamableHttpServerParams(
82
+ url=f"http://127.0.0.1:{port}/mcp",
83
+ headers={"X-Custom": "from-params"},
84
+ timeout=10.0,
85
+ sse_read_timeout=30.0,
86
+ )
87
+ auth = ApiKeyMCPAuth({"X-Api-Key": "TEST_MCP_KEY"})
88
+
89
+ async with MCPServerConnection(params, auth=auth) as conn:
90
+ assert "add" in conn.tool_names
91
+ tool = next(t for t in conn.tools if t.name == "add")
92
+ assert await tool.execute(a=2, b=3) == 5
93
+ finally:
94
+ task.cancel()
95
+ await asyncio.gather(task, return_exceptions=True)
96
+
97
+ # Both the params headers and the resolved auth headers must reach the wire.
98
+ assert seen_headers.get("x-custom") == "from-params"
99
+ assert seen_headers.get("x-api-key") == "secret-value"
@@ -158,7 +158,7 @@ class MCPServerConnection:
158
158
  await self._exit_stack.__aenter__()
159
159
 
160
160
  try:
161
- # OAuth (httpx.Auth) providers bypass the static-headers path —
161
+ # OAuth (httpx2.Auth) providers bypass the static-headers path —
162
162
  # the transport client drives the OAuth dance itself.
163
163
  httpx_auth = getattr(self._auth_provider, "httpx_auth", None)
164
164
  auth = (
@@ -169,18 +169,28 @@ class MCPServerConnection:
169
169
  auth_headers = dict(auth.headers) if auth else {}
170
170
 
171
171
  if isinstance(self._params, StreamableHttpServerParams):
172
- from mcp.client.streamable_http import streamablehttp_client
172
+ import httpx2
173
+ from mcp.client.streamable_http import streamable_http_client
173
174
 
175
+ # mcp>=2 configures the streamable-HTTP transport through a
176
+ # caller-supplied client rather than per-call kwargs, so headers,
177
+ # timeouts and auth are folded into the AsyncClient here. We
178
+ # create it, so we own closing it.
174
179
  headers = {**self._params.headers, **auth_headers}
175
- read, write, _ = await self._exit_stack.enter_async_context(
176
- streamablehttp_client(
177
- self._params.url,
180
+ http_client = await self._exit_stack.enter_async_context(
181
+ httpx2.AsyncClient(
178
182
  headers=headers or None,
179
- timeout=self._params.timeout,
180
- sse_read_timeout=self._params.sse_read_timeout,
183
+ timeout=httpx2.Timeout(
184
+ self._params.timeout,
185
+ read=self._params.sse_read_timeout,
186
+ ),
181
187
  auth=httpx_auth,
188
+ follow_redirects=True,
182
189
  )
183
190
  )
191
+ read, write = await self._exit_stack.enter_async_context(
192
+ streamable_http_client(self._params.url, http_client=http_client)
193
+ )
184
194
  elif isinstance(self._params, StdioServerParameters):
185
195
  params = merge_mcp_auth(self._params, auth)
186
196
  read, write = await self._exit_stack.enter_async_context(stdio_client(params))
@@ -226,7 +226,7 @@ class BrowserOAuthMCPAuth:
226
226
 
227
227
  @property
228
228
  def httpx_auth(self) -> Any:
229
- """The ``httpx.Auth`` instance for streamable-HTTP / SSE transports.
229
+ """The ``httpx2.Auth`` instance for streamable-HTTP / SSE transports.
230
230
 
231
231
  ``MCPServerConnection`` detects this attribute and passes the
232
232
  provider straight to the transport client's ``auth=`` parameter,
@@ -241,7 +241,7 @@ class BrowserOAuthMCPAuth:
241
241
  return MCPAuth()
242
242
 
243
243
  def _build_provider(self) -> Any:
244
- from mcp.client.auth import OAuthClientProvider
244
+ from mcp.client.auth import AuthorizationCodeResult, OAuthClientProvider
245
245
  from mcp.shared.auth import OAuthClientInformationFull, OAuthClientMetadata
246
246
 
247
247
  storage = _FileTokenStorage(self._auth_file, self._provider_name)
@@ -288,14 +288,15 @@ class BrowserOAuthMCPAuth:
288
288
  else:
289
289
  print(f"{prefix} {url}")
290
290
 
291
- async def callback_handler() -> tuple[str, str | None]:
291
+ async def callback_handler() -> AuthorizationCodeResult:
292
292
  from harness.oauth_browser import wait_for_oauth_callback
293
293
 
294
- return await wait_for_oauth_callback(
294
+ code, state = await wait_for_oauth_callback(
295
295
  port=port,
296
296
  path=self._callback_path,
297
297
  timeout=self._callback_timeout,
298
298
  )
299
+ return AuthorizationCodeResult(code=code, state=state)
299
300
 
300
301
  return OAuthClientProvider(
301
302
  server_url=self._server_url,
@@ -303,7 +304,6 @@ class BrowserOAuthMCPAuth:
303
304
  storage=storage,
304
305
  redirect_handler=redirect_handler,
305
306
  callback_handler=callback_handler,
306
- timeout=self._callback_timeout,
307
307
  )
308
308
 
309
309