react-agent-harness 0.10.2__tar.gz → 0.10.3__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 (107) hide show
  1. {react_agent_harness-0.10.2/react_agent_harness.egg-info → react_agent_harness-0.10.3}/PKG-INFO +1 -1
  2. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/working.py +46 -22
  3. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/pyproject.toml +1 -1
  4. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3/react_agent_harness.egg-info}/PKG-INFO +1 -1
  5. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_working_memory.py +57 -0
  6. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/LICENSE +0 -0
  7. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/README.md +0 -0
  8. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/agents/__init__.py +0 -0
  9. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/agents/base.py +0 -0
  10. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/__init__.py +0 -0
  11. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/annotation.py +0 -0
  12. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/cancellation.py +0 -0
  13. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/checkpoint.py +0 -0
  14. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/cli.py +0 -0
  15. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/console.py +0 -0
  16. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/events.py +0 -0
  17. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/executor_bridge.py +0 -0
  18. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/hitl.py +0 -0
  19. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/__init__.py +0 -0
  20. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/_streaming.py +0 -0
  21. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/anthropic.py +0 -0
  22. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/auth.py +0 -0
  23. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/claude_code.py +0 -0
  24. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/fallback.py +0 -0
  25. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/openai.py +0 -0
  26. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/openai_codex.py +0 -0
  27. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/llm/routing.py +0 -0
  28. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/oauth_browser.py +0 -0
  29. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/otel.py +0 -0
  30. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/persistent.py +0 -0
  31. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/persistent_completion.py +0 -0
  32. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/persistent_controls.py +0 -0
  33. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/persistent_prompt.py +0 -0
  34. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/runtime.py +0 -0
  35. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/skills.py +0 -0
  36. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/steering.py +0 -0
  37. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/streaming.py +0 -0
  38. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/tool_policy.py +0 -0
  39. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/trace.py +0 -0
  40. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/trace_viewer.py +0 -0
  41. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/harness/utils.py +0 -0
  42. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/__init__.py +0 -0
  43. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/episodic_lance.py +0 -0
  44. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/manager.py +0 -0
  45. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/redis_store.py +0 -0
  46. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/memory/stores.py +0 -0
  47. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/orchestrator/__init__.py +0 -0
  48. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/orchestrator/planner.py +0 -0
  49. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/react_agent_harness.egg-info/SOURCES.txt +0 -0
  50. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/react_agent_harness.egg-info/dependency_links.txt +0 -0
  51. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/react_agent_harness.egg-info/entry_points.txt +0 -0
  52. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/react_agent_harness.egg-info/requires.txt +0 -0
  53. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/react_agent_harness.egg-info/top_level.txt +0 -0
  54. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/setup.cfg +0 -0
  55. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_agents_base.py +0 -0
  56. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_annotation.py +0 -0
  57. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_anthropic_llm.py +0 -0
  58. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_budget_guard.py +0 -0
  59. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_cancellation.py +0 -0
  60. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_checkpoint_resume.py +0 -0
  61. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_claude_code_llm.py +0 -0
  62. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_cli.py +0 -0
  63. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_console_renderer.py +0 -0
  64. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_executor_bridge.py +0 -0
  65. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_fallback_llm.py +0 -0
  66. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_fan_in.py +0 -0
  67. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_http_fetch.py +0 -0
  68. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_llm_auth.py +0 -0
  69. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_mcp_adapter.py +0 -0
  70. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_mcp_auth.py +0 -0
  71. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_memory.py +0 -0
  72. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_memory_reconciler.py +0 -0
  73. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_memory_touchpoints.py +0 -0
  74. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_oauth_browser.py +0 -0
  75. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_openai_codex_llm.py +0 -0
  76. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_openai_llm.py +0 -0
  77. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_orchestrator.py +0 -0
  78. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_otel.py +0 -0
  79. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_parse_action_json.py +0 -0
  80. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_per_call_site_llm.py +0 -0
  81. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_persistent_agent.py +0 -0
  82. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_persistent_completion.py +0 -0
  83. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_persistent_controls.py +0 -0
  84. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_persistent_prompt.py +0 -0
  85. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_plan_approval.py +0 -0
  86. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_plan_mode.py +0 -0
  87. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_redis_store.py +0 -0
  88. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_resume_hint_banner.py +0 -0
  89. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_routing_llm.py +0 -0
  90. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_skills.py +0 -0
  91. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_steering.py +0 -0
  92. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_streaming.py +0 -0
  93. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_subagent_tool.py +0 -0
  94. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_system_prompt_routing.py +0 -0
  95. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_tool_policy.py +0 -0
  96. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_trace.py +0 -0
  97. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_trailing_assistant_state.py +0 -0
  98. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_utils.py +0 -0
  99. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tests/test_vision.py +0 -0
  100. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/__init__.py +0 -0
  101. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/builtin/__init__.py +0 -0
  102. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/builtin/fetch_image.py +0 -0
  103. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/builtin/http_fetch.py +0 -0
  104. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/builtin/subagent.py +0 -0
  105. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/mcp/__init__.py +0 -0
  106. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/mcp/adapter.py +0 -0
  107. {react_agent_harness-0.10.2 → react_agent_harness-0.10.3}/tools/mcp/auth.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: react-agent-harness
3
- Version: 0.10.2
3
+ Version: 0.10.3
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
@@ -27,6 +27,7 @@ zero dependencies. For exact counts, pass a custom `token_counter`:
27
27
 
28
28
  from __future__ import annotations
29
29
 
30
+ import asyncio
30
31
  from collections.abc import Callable
31
32
  from dataclasses import dataclass
32
33
  from typing import Any, Protocol
@@ -207,6 +208,7 @@ class WorkingMemory:
207
208
  self._messages: list[Message] = []
208
209
  self._token_total: int = 0
209
210
  self._summarization_count: int = 0
211
+ self._eviction_lock = asyncio.Lock()
210
212
 
211
213
  # ── Public API ────────────────────────────────────────────────────────────
212
214
 
@@ -221,7 +223,9 @@ class WorkingMemory:
221
223
  self._token_total += msg.token_count
222
224
 
223
225
  if self._token_total > self.max_tokens:
224
- await self._evict()
226
+ async with self._eviction_lock:
227
+ if self._token_total > self.max_tokens:
228
+ await self._evict_unlocked()
225
229
 
226
230
  def get_messages(self) -> list[dict]:
227
231
  return [{"role": m.role, "content": m.content} for m in self._messages]
@@ -333,7 +337,7 @@ class WorkingMemory:
333
337
  # candidates_back is newest-first; protect the first `protect` of them.
334
338
  return sorted(candidates_back[protect:])
335
339
 
336
- async def _evict(self, _depth: int = 0) -> None:
340
+ async def _evict_unlocked(self, _depth: int = 0) -> None:
337
341
  # Find eligible messages, relaxing recency_window only if necessary.
338
342
  relax = 0
339
343
  eligible_idx = self._eligible_indices(relax)
@@ -347,6 +351,17 @@ class WorkingMemory:
347
351
  to_summarize = [self._messages[i] for i in chosen_idx]
348
352
 
349
353
  prior_summary = next((m for m in self._messages if m.is_summary), None)
354
+ prior_summary_idx = (
355
+ next(
356
+ (i for i, m in enumerate(self._messages) if m is prior_summary),
357
+ None,
358
+ )
359
+ if prior_summary is not None
360
+ else None
361
+ )
362
+ insert_idx = min(
363
+ [*chosen_idx, *([] if prior_summary_idx is None else [prior_summary_idx])]
364
+ )
350
365
  if prior_summary is None:
351
366
  summary_text = await self._summarize_initial(to_summarize)
352
367
  else:
@@ -364,32 +379,41 @@ class WorkingMemory:
364
379
  if prior_summary is not None:
365
380
  removed_ids.add(id(prior_summary))
366
381
 
367
- insert_idx = next(i for i, m in enumerate(self._messages) if id(m) in removed_ids)
368
- remaining = [m for m in self._messages if id(m) not in removed_ids]
382
+ if not any(id(m) in removed_ids for m in self._messages):
383
+ # The summarizer is awaited above. If callers accidentally
384
+ # mutate the same WorkingMemory concurrently, the selected
385
+ # messages may already be gone. Do not reinsert a stale
386
+ # summary or leak StopIteration out of this coroutine; fall
387
+ # through to the second-pass / hard-drop safety logic.
388
+ self._token_total = sum(m.token_count for m in self._messages)
389
+ else:
390
+ remaining = [m for m in self._messages if id(m) not in removed_ids]
369
391
 
370
- # Role = opposite of the next non-pinned non-summary message so
371
- # the ReAct alternating invariant holds. No such message → "user".
372
- first_after = next(
373
- (m for m in remaining if not m.pinned and not m.is_summary),
374
- None,
375
- )
376
- summary_role = "assistant" if (first_after and first_after.role == "user") else "user"
392
+ # Role = opposite of the next non-pinned non-summary message so
393
+ # the ReAct alternating invariant holds. No such message → "user".
394
+ first_after = next(
395
+ (m for m in remaining if not m.pinned and not m.is_summary),
396
+ None,
397
+ )
398
+ summary_role = (
399
+ "assistant" if (first_after and first_after.role == "user") else "user"
400
+ )
377
401
 
378
- summary_msg = Message(
379
- role=summary_role,
380
- content=summary_content,
381
- token_count=self._count(summary_content),
382
- is_summary=True,
383
- )
402
+ summary_msg = Message(
403
+ role=summary_role,
404
+ content=summary_content,
405
+ token_count=self._count(summary_content),
406
+ is_summary=True,
407
+ )
384
408
 
385
- self._messages = remaining
386
- self._messages.insert(insert_idx, summary_msg)
387
- self._token_total = sum(m.token_count for m in self._messages)
388
- self._summarization_count += 1
409
+ self._messages = remaining
410
+ self._messages.insert(min(insert_idx, len(self._messages)), summary_msg)
411
+ self._token_total = sum(m.token_count for m in self._messages)
412
+ self._summarization_count += 1
389
413
 
390
414
  # Second pass before resorting to hard drops (max 2 passes).
391
415
  if self._token_total > self.max_tokens and _depth < 1:
392
- await self._evict(_depth=_depth + 1)
416
+ await self._evict_unlocked(_depth=_depth + 1)
393
417
  return
394
418
 
395
419
  # Safety valve: hard FIFO drop. Drops oldest non-pinned, non-summary,
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "react-agent-harness"
7
- version = "0.10.2"
7
+ version = "0.10.3"
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 = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: react-agent-harness
3
- Version: 0.10.2
3
+ Version: 0.10.3
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
@@ -9,6 +9,7 @@ recency window separately.
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
+ import asyncio
12
13
  from typing import Any
13
14
 
14
15
  import pytest
@@ -378,6 +379,62 @@ async def test_recency_window_relaxes_when_budget_forces_it():
378
379
  assert wm.summarization_count >= 1
379
380
 
380
381
 
382
+ @pytest.mark.asyncio
383
+ async def test_evict_tolerates_selected_messages_removed_during_summary():
384
+ """Regression: do not leak StopIteration if messages disappear during await."""
385
+
386
+ class MutatingLLM:
387
+ def __init__(self) -> None:
388
+ self.wm: WorkingMemory | None = None
389
+
390
+ async def complete(self, system: Any, messages: Any, **_: Any) -> dict:
391
+ assert self.wm is not None
392
+ self.wm._messages = [m for m in self.wm._messages if m.pinned]
393
+ self.wm._token_total = sum(m.token_count for m in self.wm._messages)
394
+ return {"text": "ok"}
395
+
396
+ llm = MutatingLLM()
397
+ wm = WorkingMemory(llm=llm, max_tokens=150, recency_window=0, token_counter=len)
398
+ llm.wm = wm
399
+
400
+ await wm.append("system", "s", pinned=True)
401
+ await wm.append("user", MSG)
402
+ await wm.append("assistant", MSG)
403
+
404
+ assert wm.get_messages() == [{"role": "system", "content": "s"}]
405
+ assert wm.token_count() == 1
406
+
407
+
408
+ @pytest.mark.asyncio
409
+ async def test_concurrent_appends_do_not_create_duplicate_summaries():
410
+ """Concurrent append-triggered evictions are serialized into one summary stream."""
411
+
412
+ class SlowLLM:
413
+ def __init__(self) -> None:
414
+ self.calls = 0
415
+
416
+ async def complete(self, system: Any, messages: Any, **_: Any) -> dict:
417
+ self.calls += 1
418
+ await asyncio.sleep(0)
419
+ return {"text": f"summary {self.calls}"}
420
+
421
+ llm = SlowLLM()
422
+ wm = WorkingMemory(llm=llm, max_tokens=250, recency_window=0, token_counter=len)
423
+ await wm.append("system", "s", pinned=True)
424
+ await wm.append("user", MSG)
425
+
426
+ await asyncio.gather(
427
+ wm.append("assistant", MSG),
428
+ wm.append("user", MSG),
429
+ )
430
+
431
+ summary_messages = [
432
+ m for m in wm._messages if m.is_summary or str(m.content).startswith(SUMMARY_HEADER)
433
+ ]
434
+ assert len(summary_messages) <= 1
435
+ assert wm.token_count() == sum(m.token_count for m in wm._messages)
436
+
437
+
381
438
  @pytest.mark.asyncio
382
439
  async def test_hard_drop_preserves_recent_user_observation_shape():
383
440
  """Hard-drop fallback must not leave a trailing assistant action.