react-agent-harness 0.12.0__tar.gz → 0.12.1__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 (121) hide show
  1. {react_agent_harness-0.12.0/react_agent_harness.egg-info → react_agent_harness-0.12.1}/PKG-INFO +1 -1
  2. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/README.md +20 -0
  3. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/agents/base.py +14 -0
  4. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/__init__.py +2 -0
  5. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/anthropic.py +34 -0
  6. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/claude_code.py +44 -6
  7. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/openai.py +35 -0
  8. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/openai_codex.py +32 -4
  9. react_agent_harness-0.12.1/harness/llm/reasoning.py +37 -0
  10. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/pyproject.toml +1 -1
  11. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1/react_agent_harness.egg-info}/PKG-INFO +1 -1
  12. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/react_agent_harness.egg-info/SOURCES.txt +1 -0
  13. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_agents_base.py +28 -0
  14. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_anthropic_llm.py +26 -0
  15. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_claude_code_llm.py +32 -0
  16. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_openai_codex_llm.py +30 -0
  17. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_openai_llm.py +24 -0
  18. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/LICENSE +0 -0
  19. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/agents/__init__.py +0 -0
  20. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/__init__.py +0 -0
  21. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/agent_tree.py +0 -0
  22. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/annotation.py +0 -0
  23. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/background_tasks.py +0 -0
  24. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/cancellation.py +0 -0
  25. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/checkpoint.py +0 -0
  26. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/cli.py +0 -0
  27. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/console.py +0 -0
  28. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/events.py +0 -0
  29. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/executor_bridge.py +0 -0
  30. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/hitl.py +0 -0
  31. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/_streaming.py +0 -0
  32. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/auth.py +0 -0
  33. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/fallback.py +0 -0
  34. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/llm/routing.py +0 -0
  35. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/model_switching.py +0 -0
  36. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/oauth_browser.py +0 -0
  37. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/otel.py +0 -0
  38. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/persistent.py +0 -0
  39. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/persistent_completion.py +0 -0
  40. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/persistent_controls.py +0 -0
  41. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/persistent_prompt.py +0 -0
  42. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/plan_mode.py +0 -0
  43. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/runtime.py +0 -0
  44. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/session_memory.py +0 -0
  45. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/skills.py +0 -0
  46. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/steering.py +0 -0
  47. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/streaming.py +0 -0
  48. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/tool_policy.py +0 -0
  49. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/trace.py +0 -0
  50. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/trace_viewer.py +0 -0
  51. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/harness/utils.py +0 -0
  52. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/__init__.py +0 -0
  53. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/episodic_lance.py +0 -0
  54. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/manager.py +0 -0
  55. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/redis_store.py +0 -0
  56. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/stores.py +0 -0
  57. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/memory/working.py +0 -0
  58. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/orchestrator/__init__.py +0 -0
  59. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/orchestrator/planner.py +0 -0
  60. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/react_agent_harness.egg-info/dependency_links.txt +0 -0
  61. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/react_agent_harness.egg-info/entry_points.txt +0 -0
  62. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/react_agent_harness.egg-info/requires.txt +0 -0
  63. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/react_agent_harness.egg-info/top_level.txt +0 -0
  64. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/setup.cfg +0 -0
  65. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_annotation.py +0 -0
  66. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_background_tasks.py +0 -0
  67. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_budget_guard.py +0 -0
  68. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_cancellation.py +0 -0
  69. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_checkpoint_resume.py +0 -0
  70. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_cli.py +0 -0
  71. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_console_renderer.py +0 -0
  72. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_event_payloads.py +0 -0
  73. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_executor_bridge.py +0 -0
  74. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_fallback_llm.py +0 -0
  75. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_fan_in.py +0 -0
  76. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_hitl_banner.py +0 -0
  77. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_http_fetch.py +0 -0
  78. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_llm_auth.py +0 -0
  79. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_mcp_adapter.py +0 -0
  80. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_mcp_auth.py +0 -0
  81. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_mcp_streamable_http.py +0 -0
  82. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_memory.py +0 -0
  83. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_memory_reconciler.py +0 -0
  84. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_memory_touchpoints.py +0 -0
  85. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_model_switching.py +0 -0
  86. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_oauth_browser.py +0 -0
  87. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_orchestrator.py +0 -0
  88. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_otel.py +0 -0
  89. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_parse_action_json.py +0 -0
  90. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_per_call_site_llm.py +0 -0
  91. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_persistent_agent.py +0 -0
  92. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_persistent_completion.py +0 -0
  93. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_persistent_controls.py +0 -0
  94. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_persistent_prompt.py +0 -0
  95. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_plan_approval.py +0 -0
  96. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_plan_mode.py +0 -0
  97. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_plan_mode_controller.py +0 -0
  98. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_redis_store.py +0 -0
  99. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_resume_hint_banner.py +0 -0
  100. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_routing_llm.py +0 -0
  101. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_session_memory.py +0 -0
  102. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_skills.py +0 -0
  103. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_steering.py +0 -0
  104. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_streaming.py +0 -0
  105. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_subagent_tool.py +0 -0
  106. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_system_prompt_routing.py +0 -0
  107. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_tool_policy.py +0 -0
  108. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_trace.py +0 -0
  109. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_trailing_assistant_state.py +0 -0
  110. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_utils.py +0 -0
  111. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_vision.py +0 -0
  112. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tests/test_working_memory.py +0 -0
  113. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/__init__.py +0 -0
  114. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/builtin/__init__.py +0 -0
  115. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/builtin/background.py +0 -0
  116. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/builtin/fetch_image.py +0 -0
  117. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/builtin/http_fetch.py +0 -0
  118. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/builtin/subagent.py +0 -0
  119. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/mcp/__init__.py +0 -0
  120. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/tools/mcp/adapter.py +0 -0
  121. {react_agent_harness-0.12.0 → react_agent_harness-0.12.1}/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.12.0
3
+ Version: 0.12.1
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
@@ -177,6 +177,25 @@ llm = OpenAILLM(model="gpt-4o-mini") # reads OPENAI_API_KEY from
177
177
  runtime = AgentRuntime(..., llm=llm)
178
178
  ```
179
179
 
180
+ Reasoning effort can be set once on an adapter, or overridden for one agent:
181
+
182
+ ```python
183
+ llm = OpenAILLM(model="gpt-5", reasoning_effort="high")
184
+
185
+ researcher = AgentConfig(
186
+ agent_id="researcher",
187
+ role="deep research",
188
+ system_prompt="Research carefully.",
189
+ allowed_tools=["web_search"],
190
+ reasoning_effort="medium", # overrides the adapter default for this agent
191
+ )
192
+ ```
193
+
194
+ The adapter includes the configured value on every provider request. OpenAI
195
+ supports `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`; Anthropic
196
+ supports `low`, `medium`, `high`, `xhigh`, and `max` on compatible models.
197
+ Unsupported provider/value combinations fail before the request is sent.
198
+
180
199
  Credential-backed adapters can also plug into the same contract. This is the
181
200
  shape used for provider-specific subscription or OAuth flows without teaching
182
201
  agents about auth:
@@ -1820,3 +1839,4 @@ agents alongside HITL on the shell tool.
1820
1839
  | `hitl_tools` | `[]` | Tool names that require human approval before execution |
1821
1840
  | `checkpoint_every` | `0` | Write a crash-resumable checkpoint every N steps; `0` disables periodic checkpoints |
1822
1841
  | `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)` |
1842
+ | `reasoning_effort` | `None` (adapter/provider default) | Per-agent reasoning depth override. Supported values depend on the provider; set it once on the LLM adapter to apply across all calls instead. |
@@ -39,6 +39,7 @@ from typing import Any, Final
39
39
 
40
40
  from harness.checkpoint import _ResumeHint
41
41
  from harness.events import BusEvent, EventType
42
+ from harness.llm.reasoning import ReasoningEffort, validate_reasoning_effort
42
43
  from harness.skills import Skill
43
44
  from harness.utils import fire
44
45
  from memory.manager import MemoryManager
@@ -75,6 +76,10 @@ class AgentConfig:
75
76
  memory_context_enabled: bool = True
76
77
  confidence_from_llm: bool = True # if False, confidence=1.0 on success
77
78
  stream_tokens: bool = False # if True, TOKEN events are emitted as the LLM streams
79
+ # Optional per-agent reasoning depth. Overrides the LLM adapter's default
80
+ # for ReAct calls, including retries. Provider adapters validate which
81
+ # levels their backend supports.
82
+ reasoning_effort: ReasoningEffort | None = None
78
83
  # ``None`` → derive from ``llm.input_token_budget * 0.8`` at runtime
79
84
  # (each adapter reports a per-model context window; OpenAILLM /
80
85
  # AnthropicLLM / etc. expose ``input_token_budget``). Pass an explicit
@@ -108,6 +113,7 @@ class AgentConfig:
108
113
  max_subagent_depth: int = 3
109
114
 
110
115
  def __post_init__(self):
116
+ self.reasoning_effort = validate_reasoning_effort(self.reasoning_effort)
111
117
  if self.hitl_tools is None:
112
118
  self.hitl_tools = []
113
119
  if self.skills is None:
@@ -870,6 +876,7 @@ class BaseAgent:
870
876
  messages=messages,
871
877
  source=react_source,
872
878
  response_format={"type": "json_object"},
879
+ **self._reasoning_options(),
873
880
  ):
874
881
  accumulated += token
875
882
  if self.config.stream_tokens:
@@ -888,6 +895,7 @@ class BaseAgent:
888
895
  messages=messages,
889
896
  response_format={"type": "json_object"},
890
897
  source=react_source,
898
+ **self._reasoning_options(),
891
899
  )
892
900
  response = _normalize_response(raw)
893
901
  if response is None:
@@ -956,6 +964,7 @@ class BaseAgent:
956
964
  ],
957
965
  response_format={"type": "json_object"},
958
966
  source=react_source,
967
+ **self._reasoning_options(),
959
968
  )
960
969
  response = _normalize_response(raw)
961
970
  except Exception as e:
@@ -967,6 +976,11 @@ class BaseAgent:
967
976
  self._last_think_error = f"Unparseable stream response: {accumulated[:300]}"
968
977
  return response
969
978
 
979
+ def _reasoning_options(self) -> dict[str, ReasoningEffort]:
980
+ if self.config.reasoning_effort is None:
981
+ return {}
982
+ return {"reasoning_effort": self.config.reasoning_effort}
983
+
970
984
  async def _record_tool_observation(
971
985
  self,
972
986
  response: dict,
@@ -8,6 +8,7 @@ from harness.llm.auth import (
8
8
  )
9
9
  from harness.llm.claude_code import ClaudeCodeLLM
10
10
  from harness.llm.openai_codex import OpenAICodexLLM
11
+ from harness.llm.reasoning import ReasoningEffort
11
12
 
12
13
  __all__ = [
13
14
  "AnthropicClaudeCodeOAuthClient",
@@ -16,4 +17,5 @@ __all__ = [
16
17
  "OAuthCredential",
17
18
  "OpenAICodexLLM",
18
19
  "OpenAICodexOAuthClient",
20
+ "ReasoningEffort",
19
21
  ]
@@ -51,6 +51,12 @@ import os
51
51
  from collections.abc import AsyncGenerator, Callable
52
52
  from typing import Any
53
53
 
54
+ from harness.llm.reasoning import (
55
+ ANTHROPIC_REASONING_EFFORTS,
56
+ ReasoningEffort,
57
+ validate_reasoning_effort,
58
+ )
59
+
54
60
  logger = logging.getLogger(__name__)
55
61
 
56
62
 
@@ -131,6 +137,7 @@ class AnthropicLLM:
131
137
  prompt_caching: bool = True,
132
138
  # Explicit context window override; see ``_lookup_anthropic_context_window``.
133
139
  context_window: int | None = None,
140
+ reasoning_effort: ReasoningEffort | None = None,
134
141
  ) -> None:
135
142
  try:
136
143
  import anthropic
@@ -146,6 +153,11 @@ class AnthropicLLM:
146
153
  self._cost_fn = cost_fn
147
154
  self._prompt_caching = prompt_caching
148
155
  self._context_window = context_window or _lookup_anthropic_context_window(model)
156
+ self._reasoning_effort = validate_reasoning_effort(
157
+ reasoning_effort,
158
+ provider="anthropic",
159
+ allowed=ANTHROPIC_REASONING_EFFORTS,
160
+ )
149
161
  self._budget: Any = None
150
162
  # Populated after every successful call; streaming callers read it here.
151
163
  self.last_usage: dict | None = None
@@ -190,6 +202,9 @@ class AnthropicLLM:
190
202
  }
191
203
  if sys_blocks:
192
204
  request["system"] = sys_blocks
205
+ output_config = self._reasoning_output_config(kwargs)
206
+ if output_config is not None:
207
+ request["output_config"] = output_config
193
208
 
194
209
  resp = await self._client.messages.create(**request)
195
210
  usage = _extract_usage(resp.usage, resp.model or self._model)
@@ -225,6 +240,9 @@ class AnthropicLLM:
225
240
  }
226
241
  if sys_blocks:
227
242
  request["system"] = sys_blocks
243
+ output_config = self._reasoning_output_config(kwargs)
244
+ if output_config is not None:
245
+ request["output_config"] = output_config
228
246
 
229
247
  async with self._client.messages.stream(**request) as stream:
230
248
  yielded = False
@@ -249,6 +267,22 @@ class AnthropicLLM:
249
267
  self._record_usage(usage, source=source)
250
268
  self.last_usage = usage
251
269
 
270
+ def _reasoning_output_config(self, kwargs: dict[str, Any]) -> dict[str, Any] | None:
271
+ existing = kwargs.get("output_config")
272
+ output_config = dict(existing) if isinstance(existing, dict) else {}
273
+ effort = (
274
+ validate_reasoning_effort(
275
+ kwargs["reasoning_effort"],
276
+ provider="anthropic",
277
+ allowed=ANTHROPIC_REASONING_EFFORTS,
278
+ )
279
+ if "reasoning_effort" in kwargs
280
+ else self._reasoning_effort
281
+ )
282
+ if effort is not None:
283
+ output_config["effort"] = effort
284
+ return output_config or None
285
+
252
286
  # ── Internals ─────────────────────────────────────────────────────────────
253
287
 
254
288
  def _record_usage(self, usage: dict, *, source: str | None) -> None:
@@ -16,6 +16,11 @@ from harness.llm.auth import (
16
16
  AuthFileOAuthProvider,
17
17
  OAuthCredential,
18
18
  )
19
+ from harness.llm.reasoning import (
20
+ ANTHROPIC_REASONING_EFFORTS,
21
+ ReasoningEffort,
22
+ validate_reasoning_effort,
23
+ )
19
24
 
20
25
  CLAUDE_CODE_BETAS = os.environ.get(
21
26
  "CLAUDE_CODE_BETAS",
@@ -49,6 +54,7 @@ class ClaudeCodeLLM:
49
54
  # Explicit context window override; falls back to the Anthropic
50
55
  # lookup table since Claude Code is Anthropic underneath.
51
56
  context_window: int | None = None,
57
+ reasoning_effort: ReasoningEffort | None = None,
52
58
  ) -> None:
53
59
  if credential_provider is None:
54
60
  if auth_file is None:
@@ -74,6 +80,11 @@ class ClaudeCodeLLM:
74
80
  self._user_agent = user_agent or _default_user_agent()
75
81
  self._betas = betas
76
82
  self._prompt_caching = prompt_caching
83
+ self._reasoning_effort = validate_reasoning_effort(
84
+ reasoning_effort,
85
+ provider="claude-code",
86
+ allowed=ANTHROPIC_REASONING_EFFORTS,
87
+ )
77
88
  # Reuse Anthropic's table — Claude Code is Anthropic underneath.
78
89
  from harness.llm.anthropic import ( # noqa: PLC0415
79
90
  _ANTHROPIC_TOKEN_BUDGET_SAFETY,
@@ -119,9 +130,10 @@ class ClaudeCodeLLM:
119
130
  `stream=true` and accumulate the deltas.
120
131
  """
121
132
  max_tokens = int(kwargs.pop("max_tokens", self._max_tokens))
133
+ extra = self._request_extra(kwargs)
122
134
  parts: list[str] = []
123
135
  async for delta in self._iter_stream(
124
- system, messages, max_tokens=max_tokens, extra=kwargs, source=source
136
+ system, messages, max_tokens=max_tokens, extra=extra, source=source
125
137
  ):
126
138
  parts.append(delta)
127
139
  text = "".join(parts)
@@ -135,12 +147,12 @@ class ClaudeCodeLLM:
135
147
  messages: list[dict],
136
148
  *,
137
149
  source: str | None = None,
138
- **_kwargs: Any,
150
+ **kwargs: Any,
139
151
  ) -> AsyncGenerator[str, None]:
140
- # ``_kwargs`` swallows OpenAI-style hints like ``response_format``;
141
- # Claude Code (Anthropic underneath) doesn't expose an equivalent.
152
+ max_tokens = int(kwargs.pop("max_tokens", self._max_tokens))
153
+ extra = self._request_extra(kwargs)
142
154
  async for delta in self._iter_stream(
143
- system, messages, max_tokens=self._max_tokens, extra={}, source=source
155
+ system, messages, max_tokens=max_tokens, extra=extra, source=source
144
156
  ):
145
157
  yield delta
146
158
 
@@ -148,6 +160,25 @@ class ClaudeCodeLLM:
148
160
  if self._owns_client and self._client is not None:
149
161
  await self._client.aclose()
150
162
 
163
+ def _request_extra(self, kwargs: dict[str, Any]) -> dict[str, Any]:
164
+ extra = dict(kwargs)
165
+ extra.pop("response_format", None)
166
+ effort = (
167
+ validate_reasoning_effort(
168
+ extra.pop("reasoning_effort"),
169
+ provider="claude-code",
170
+ allowed=ANTHROPIC_REASONING_EFFORTS,
171
+ )
172
+ if "reasoning_effort" in extra
173
+ else self._reasoning_effort
174
+ )
175
+ if effort is not None:
176
+ output_config = extra.get("output_config")
177
+ output_config = dict(output_config) if isinstance(output_config, dict) else {}
178
+ output_config["effort"] = effort
179
+ extra["output_config"] = output_config
180
+ return extra
181
+
151
182
  # ── Streaming core ────────────────────────────────────────────────────────
152
183
 
153
184
  async def _iter_stream(
@@ -347,7 +378,14 @@ def _build_payload(
347
378
  "system": _system_blocks(instructions, prompt_caching=prompt_caching),
348
379
  "messages": built_messages,
349
380
  }
350
- for key in ("temperature", "top_p", "top_k", "stop_sequences", "thinking"):
381
+ for key in (
382
+ "temperature",
383
+ "top_p",
384
+ "top_k",
385
+ "stop_sequences",
386
+ "thinking",
387
+ "output_config",
388
+ ):
351
389
  if key in extra:
352
390
  payload[key] = extra[key]
353
391
  return payload
@@ -49,6 +49,12 @@ import logging
49
49
  from collections.abc import AsyncGenerator, Callable
50
50
  from typing import Any
51
51
 
52
+ from harness.llm.reasoning import (
53
+ OPENAI_REASONING_EFFORTS,
54
+ ReasoningEffort,
55
+ validate_reasoning_effort,
56
+ )
57
+
52
58
  logger = logging.getLogger(__name__)
53
59
 
54
60
  # Response headers commonly emitted by proxy gateways for per-request cost.
@@ -105,6 +111,7 @@ class OpenAILLM:
105
111
  # which truncated JSON-mode responses inside ``BaseAgent``'s loop.
106
112
  # Per-call override available via ``complete(..., max_completion_tokens=N)``.
107
113
  max_completion_tokens: int | None = 4096,
114
+ reasoning_effort: ReasoningEffort | None = None,
108
115
  # Explicit context window override. When None (default), the
109
116
  # adapter consults ``_OPENAI_CONTEXT_WINDOWS`` and falls back to
110
117
  # 8K + a warning for models it doesn't recognise. Pass an int when
@@ -126,6 +133,11 @@ class OpenAILLM:
126
133
  self._model = model
127
134
  self._cost_fn = cost_fn
128
135
  self._max_completion_tokens = max_completion_tokens
136
+ self._reasoning_effort = validate_reasoning_effort(
137
+ reasoning_effort,
138
+ provider="openai",
139
+ allowed=OPENAI_REASONING_EFFORTS,
140
+ )
129
141
  self._context_window = context_window or _lookup_openai_context_window(model)
130
142
  self._budget = None
131
143
  # Last observed usage dict. Populated after every successful call; useful
@@ -177,6 +189,17 @@ class OpenAILLM:
177
189
  # supports {"type": "json_object"} to enforce strict JSON output.
178
190
  if "response_format" in kwargs:
179
191
  request["response_format"] = kwargs["response_format"]
192
+ effort = (
193
+ validate_reasoning_effort(
194
+ kwargs["reasoning_effort"],
195
+ provider="openai",
196
+ allowed=OPENAI_REASONING_EFFORTS,
197
+ )
198
+ if "reasoning_effort" in kwargs
199
+ else self._reasoning_effort
200
+ )
201
+ if effort is not None:
202
+ request["reasoning_effort"] = effort
180
203
  # Per-call override wins over the instance default; explicit ``None``
181
204
  # means "let the model use its own ceiling" so callers can opt out.
182
205
  max_completion_tokens = kwargs.get("max_completion_tokens", self._max_completion_tokens)
@@ -206,6 +229,7 @@ class OpenAILLM:
206
229
  source: str | None = None,
207
230
  response_format: dict | None = None,
208
231
  max_completion_tokens: int | None = _SENTINEL,
232
+ reasoning_effort: ReasoningEffort | None | object = _SENTINEL,
209
233
  ) -> AsyncGenerator[str, None]:
210
234
  full_messages = _prepend_system(system, messages)
211
235
  # include_usage adds a final SSE chunk with the same usage block as
@@ -223,6 +247,17 @@ class OpenAILLM:
223
247
  # accepting prose responses and crashing in ``_parse_action_json``.
224
248
  if response_format is not None:
225
249
  request_kwargs["response_format"] = response_format
250
+ effective_effort = (
251
+ self._reasoning_effort
252
+ if reasoning_effort is _SENTINEL
253
+ else validate_reasoning_effort(
254
+ reasoning_effort,
255
+ provider="openai",
256
+ allowed=OPENAI_REASONING_EFFORTS,
257
+ )
258
+ )
259
+ if effective_effort is not None:
260
+ request_kwargs["reasoning_effort"] = effective_effort
226
261
  # Sentinel-vs-None distinction so callers can explicitly pass
227
262
  # ``max_completion_tokens=None`` to opt out of the cap (let model
228
263
  # use its own ceiling). The instance default fills in otherwise.
@@ -17,6 +17,11 @@ from typing import Any
17
17
 
18
18
  from harness.llm._streaming import aiter_sse_events, format_streaming_error, read_error_body
19
19
  from harness.llm.auth import AuthFileOAuthProvider, OAuthCredential, OpenAICodexOAuthClient
20
+ from harness.llm.reasoning import (
21
+ OPENAI_REASONING_EFFORTS,
22
+ ReasoningEffort,
23
+ validate_reasoning_effort,
24
+ )
20
25
 
21
26
 
22
27
  class OpenAICodexLLM:
@@ -37,6 +42,7 @@ class OpenAICodexLLM:
37
42
  # OpenAILLM's max_completion_tokens; Codex calls this
38
43
  # max_output_tokens.
39
44
  max_output_tokens: int | None = 4096,
45
+ reasoning_effort: ReasoningEffort | None = None,
40
46
  ) -> None:
41
47
  if credential_provider is None:
42
48
  if auth_file is None:
@@ -55,6 +61,11 @@ class OpenAICodexLLM:
55
61
  self._owns_client = http_client is None
56
62
  self._codex_originator = codex_originator
57
63
  self._max_output_tokens = max_output_tokens
64
+ self._reasoning_effort = validate_reasoning_effort(
65
+ reasoning_effort,
66
+ provider="openai-codex",
67
+ allowed=OPENAI_REASONING_EFFORTS,
68
+ )
58
69
  # Reuse OpenAI's table — Codex models share the gpt-5 / o-series
59
70
  # lineage so the same context windows apply.
60
71
  from harness.llm.openai import ( # noqa: PLC0415
@@ -104,8 +115,7 @@ class OpenAICodexLLM:
104
115
  there is no separate non-streaming code path. The Codex backend
105
116
  only returns SSE; we just buffer the deltas before returning.
106
117
  """
107
- extra = dict(kwargs)
108
- extra.pop("max_output_tokens", None)
118
+ extra = self._request_extra(kwargs)
109
119
  text_parts: list[str] = []
110
120
  async for delta in self._iter_stream(system, messages, extra=extra, source=source):
111
121
  text_parts.append(delta)
@@ -132,8 +142,7 @@ class OpenAICodexLLM:
132
142
  rejects ``max_output_tokens``, so that public Responses API option is
133
143
  filtered out when shared harness code passes it through.
134
144
  """
135
- extra = dict(kwargs)
136
- extra.pop("max_output_tokens", None)
145
+ extra = self._request_extra(kwargs)
137
146
  async for delta in self._iter_stream(system, messages, extra=extra, source=source):
138
147
  yield delta
139
148
 
@@ -141,6 +150,25 @@ class OpenAICodexLLM:
141
150
  if self._owns_client and self._client is not None:
142
151
  await self._client.aclose()
143
152
 
153
+ def _request_extra(self, kwargs: dict[str, Any]) -> dict[str, Any]:
154
+ extra = dict(kwargs)
155
+ extra.pop("max_output_tokens", None)
156
+ effort = (
157
+ validate_reasoning_effort(
158
+ extra.pop("reasoning_effort"),
159
+ provider="openai-codex",
160
+ allowed=OPENAI_REASONING_EFFORTS,
161
+ )
162
+ if "reasoning_effort" in extra
163
+ else self._reasoning_effort
164
+ )
165
+ if effort is not None:
166
+ reasoning = extra.get("reasoning")
167
+ reasoning = dict(reasoning) if isinstance(reasoning, dict) else {}
168
+ reasoning["effort"] = effort
169
+ extra["reasoning"] = reasoning
170
+ return extra
171
+
144
172
  # ── Streaming core ────────────────────────────────────────────────────────
145
173
 
146
174
  async def _iter_stream(
@@ -0,0 +1,37 @@
1
+ """Provider-neutral reasoning-effort configuration."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, TypeAlias, cast
6
+
7
+ ReasoningEffort: TypeAlias = Literal[
8
+ "none",
9
+ "minimal",
10
+ "low",
11
+ "medium",
12
+ "high",
13
+ "xhigh",
14
+ "max",
15
+ ]
16
+
17
+ REASONING_EFFORTS = frozenset({"none", "minimal", "low", "medium", "high", "xhigh", "max"})
18
+ OPENAI_REASONING_EFFORTS = frozenset({"none", "minimal", "low", "medium", "high", "xhigh"})
19
+ ANTHROPIC_REASONING_EFFORTS = frozenset({"low", "medium", "high", "xhigh", "max"})
20
+
21
+
22
+ def validate_reasoning_effort(
23
+ effort: str | None,
24
+ *,
25
+ provider: str = "harness",
26
+ allowed: frozenset[str] = REASONING_EFFORTS,
27
+ ) -> ReasoningEffort | None:
28
+ """Validate and normalize one reasoning-effort value."""
29
+ if effort is None:
30
+ return None
31
+ normalized = effort.strip().lower()
32
+ if normalized not in allowed:
33
+ choices = ", ".join(sorted(allowed))
34
+ raise ValueError(
35
+ f"unsupported reasoning_effort {effort!r} for {provider}; expected one of: {choices}"
36
+ )
37
+ return cast(ReasoningEffort, normalized)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "react-agent-harness"
7
- version = "0.12.0"
7
+ version = "0.12.1"
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.12.0
3
+ Version: 0.12.1
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
@@ -39,6 +39,7 @@ harness/llm/claude_code.py
39
39
  harness/llm/fallback.py
40
40
  harness/llm/openai.py
41
41
  harness/llm/openai_codex.py
42
+ harness/llm/reasoning.py
42
43
  harness/llm/routing.py
43
44
  memory/__init__.py
44
45
  memory/episodic_lance.py
@@ -2,6 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import pytest
6
+
5
7
  from agents.base import AgentConfig
6
8
  from harness.events import EventType
7
9
  from harness.skills import Skill
@@ -33,6 +35,32 @@ async def test_finish_on_first_step_returns_answer(agent_factory, llm: ScriptedL
33
35
  assert "done:" in result["answer"]
34
36
 
35
37
 
38
+ async def test_agent_forwards_reasoning_effort_to_llm(agent_factory, llm: ScriptedLLM):
39
+ config = AgentConfig(
40
+ agent_id="reasoner",
41
+ role="reasons",
42
+ system_prompt="finish.",
43
+ allowed_tools=[],
44
+ reasoning_effort="high",
45
+ )
46
+ agent = agent_factory(config)
47
+
48
+ await agent.run("solve this")
49
+
50
+ assert llm.calls[0]["kwargs"]["reasoning_effort"] == "high"
51
+
52
+
53
+ def test_agent_config_rejects_unknown_reasoning_effort():
54
+ with pytest.raises(ValueError, match="unsupported reasoning_effort"):
55
+ AgentConfig(
56
+ agent_id="reasoner",
57
+ role="reasons",
58
+ system_prompt="finish.",
59
+ allowed_tools=[],
60
+ reasoning_effort="extreme",
61
+ )
62
+
63
+
36
64
  async def test_agent_skills_are_injected_without_granting_tools(agent_factory, llm: ScriptedLLM):
37
65
  config = AgentConfig(
38
66
  agent_id="skilled",
@@ -250,6 +250,23 @@ async def test_complete_no_system_omits_system_param(monkeypatch):
250
250
  assert "system" not in call
251
251
 
252
252
 
253
+ async def test_complete_maps_reasoning_effort_to_output_config(monkeypatch):
254
+ llm, messages = _build(monkeypatch, reasoning_effort="high")
255
+ messages.next_response = _FakeMessage([_FakeContentBlock("ok")])
256
+
257
+ await llm.complete(system=None, messages=[])
258
+ assert messages.calls[0]["output_config"] == {"effort": "high"}
259
+
260
+ messages.next_response = _FakeMessage([_FakeContentBlock("ok")])
261
+ await llm.complete(system=None, messages=[], reasoning_effort="low")
262
+ assert messages.calls[1]["output_config"] == {"effort": "low"}
263
+
264
+
265
+ def test_anthropic_rejects_openai_only_minimal_effort(monkeypatch):
266
+ with pytest.raises(ValueError, match="unsupported reasoning_effort"):
267
+ _build(monkeypatch, reasoning_effort="minimal")
268
+
269
+
253
270
  # ── last_usage includes cache fields ─────────────────────────────────────────
254
271
 
255
272
 
@@ -294,6 +311,15 @@ async def test_stream_complete_yields_tokens(monkeypatch):
294
311
  assert tokens == ["He", "llo", " world"]
295
312
 
296
313
 
314
+ async def test_stream_complete_forwards_reasoning_effort(monkeypatch):
315
+ llm, messages = _build(monkeypatch, reasoning_effort="medium")
316
+ messages.next_stream_tokens = ["ok"]
317
+ messages.next_stream_final = _FakeMessage([], usage=_FakeUsage())
318
+
319
+ assert [token async for token in llm.stream_complete(system=None, messages=[])] == ["ok"]
320
+ assert messages.calls[0]["output_config"] == {"effort": "medium"}
321
+
322
+
297
323
  async def test_stream_complete_sets_last_usage(monkeypatch):
298
324
  llm, messages = _build(monkeypatch)
299
325
  messages.next_stream_tokens = ["ok"]
@@ -213,6 +213,38 @@ async def test_stream_complete_yields_deltas_incrementally():
213
213
  assert "oauth-2025-04-20" in client.calls[0]["headers"]["anthropic-beta"]
214
214
 
215
215
 
216
+ async def test_stream_complete_maps_reasoning_effort_to_output_config():
217
+ body = _sse(
218
+ [
219
+ {"type": "message_start", "message": {"usage": {"input_tokens": 1}}},
220
+ {"type": "content_block_delta", "delta": {"type": "text_delta", "text": "ok"}},
221
+ {"type": "message_delta", "usage": {"output_tokens": 1}},
222
+ ]
223
+ )
224
+ client = _Client([_StreamResponse(200, body), _StreamResponse(200, body)])
225
+ llm = ClaudeCodeLLM(
226
+ model="claude-sonnet-4-6",
227
+ credential_provider=_Creds(),
228
+ base_url="https://api.anthropic.com",
229
+ http_client=client,
230
+ user_agent="claude-cli/2.1.150 (external, cli)",
231
+ reasoning_effort="high",
232
+ )
233
+
234
+ [delta async for delta in llm.stream_complete(system=None, messages=[])]
235
+ [
236
+ delta
237
+ async for delta in llm.stream_complete(
238
+ system=None,
239
+ messages=[],
240
+ reasoning_effort="low",
241
+ )
242
+ ]
243
+
244
+ assert client.calls[0]["json"]["output_config"] == {"effort": "high"}
245
+ assert client.calls[1]["json"]["output_config"] == {"effort": "low"}
246
+
247
+
216
248
  async def test_stream_complete_refreshes_creds_on_401():
217
249
  body = _sse(
218
250
  [
@@ -147,6 +147,36 @@ async def test_stream_complete_filters_unsupported_max_output_tokens():
147
147
  assert "max_output_tokens" not in client.calls[0]["json"]
148
148
 
149
149
 
150
+ async def test_stream_complete_maps_reasoning_effort_to_responses_payload():
151
+ body = (
152
+ "event: response.output_text.delta\n"
153
+ 'data: {"delta":"ok"}\n\n'
154
+ "event: response.completed\n"
155
+ 'data: {"response":{"usage":{"input_tokens":1,"output_tokens":1}}}\n\n'
156
+ )
157
+ client = _Client([_StreamResponse(200, body), _StreamResponse(200, body)])
158
+ llm = OpenAICodexLLM(
159
+ model="gpt-5.5",
160
+ credential_provider=_Creds(),
161
+ base_url="https://chatgpt.com/backend-api",
162
+ http_client=client,
163
+ reasoning_effort="high",
164
+ )
165
+
166
+ [delta async for delta in llm.stream_complete(system=None, messages=[])]
167
+ [
168
+ delta
169
+ async for delta in llm.stream_complete(
170
+ system=None,
171
+ messages=[],
172
+ reasoning_effort="low",
173
+ )
174
+ ]
175
+
176
+ assert client.calls[0]["json"]["reasoning"] == {"effort": "high"}
177
+ assert client.calls[1]["json"]["reasoning"] == {"effort": "low"}
178
+
179
+
150
180
  async def test_stream_complete_refreshes_creds_on_401():
151
181
  body = (
152
182
  "event: response.output_text.delta\n"
@@ -200,6 +200,30 @@ async def test_complete_allows_max_completion_tokens_override_and_opt_out(monkey
200
200
  assert "max_completion_tokens" not in raw.calls[1]
201
201
 
202
202
 
203
+ async def test_reasoning_effort_constructor_default_and_per_call_override(monkeypatch):
204
+ llm, raw = _build(monkeypatch, reasoning_effort="high")
205
+ raw.next_body = _fake_response("{}")
206
+ await llm.complete(system=None, messages=[])
207
+ assert raw.calls[0]["reasoning_effort"] == "high"
208
+
209
+ raw.next_body = _fake_response("{}")
210
+ await llm.complete(system=None, messages=[], reasoning_effort="low")
211
+ assert raw.calls[1]["reasoning_effort"] == "low"
212
+
213
+
214
+ async def test_stream_complete_forwards_reasoning_effort(monkeypatch):
215
+ llm, raw = _build(monkeypatch, reasoning_effort="medium")
216
+ raw.next_stream_chunks = [_fake_chunk("ok")]
217
+
218
+ assert [token async for token in llm.stream_complete(system=None, messages=[])] == ["ok"]
219
+ assert raw.calls[0]["reasoning_effort"] == "medium"
220
+
221
+
222
+ def test_openai_rejects_anthropic_only_max_effort(monkeypatch):
223
+ with pytest.raises(ValueError, match="unsupported reasoning_effort"):
224
+ _build(monkeypatch, reasoning_effort="max")
225
+
226
+
203
227
  # ── cost: gateway header takes precedence ────────────────────────────────────
204
228
 
205
229