react-agent-harness 0.13.0__tar.gz → 0.15.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 (131) hide show
  1. {react_agent_harness-0.13.0/react_agent_harness.egg-info → react_agent_harness-0.15.0}/PKG-INFO +2 -1
  2. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/README.md +54 -7
  3. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/agents/base.py +58 -16
  4. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/hitl.py +61 -14
  5. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/anthropic.py +73 -12
  6. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/claude_code.py +18 -6
  7. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/openai.py +7 -4
  8. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/openai_codex.py +2 -3
  9. react_agent_harness-0.15.0/harness/llm/server_tools.py +113 -0
  10. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/runtime.py +8 -0
  11. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/tool_policy.py +30 -7
  12. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/pyproject.toml +3 -2
  13. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0/react_agent_harness.egg-info}/PKG-INFO +2 -1
  14. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/react_agent_harness.egg-info/SOURCES.txt +3 -0
  15. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/react_agent_harness.egg-info/requires.txt +1 -0
  16. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_anthropic_llm.py +21 -0
  17. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_claude_code_llm.py +20 -2
  18. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_hitl_gate.py +103 -0
  19. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_openai_codex_llm.py +17 -1
  20. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_openai_llm.py +19 -2
  21. react_agent_harness-0.15.0/tests/test_resumable_delegation.py +342 -0
  22. react_agent_harness-0.15.0/tests/test_server_tool_events.py +312 -0
  23. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_tool_policy.py +51 -0
  24. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/builtin/subagent.py +83 -2
  25. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/LICENSE +0 -0
  26. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/agents/__init__.py +0 -0
  27. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/__init__.py +0 -0
  28. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/agent_tree.py +0 -0
  29. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/annotation.py +0 -0
  30. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/background_tasks.py +0 -0
  31. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/cancellation.py +0 -0
  32. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/checkpoint.py +0 -0
  33. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/cli.py +0 -0
  34. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/console.py +0 -0
  35. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/events.py +0 -0
  36. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/executor_bridge.py +0 -0
  37. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/__init__.py +0 -0
  38. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/_streaming.py +0 -0
  39. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/auth.py +0 -0
  40. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/fallback.py +0 -0
  41. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/reasoning.py +0 -0
  42. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/llm/routing.py +0 -0
  43. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/model_switching.py +0 -0
  44. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/oauth_browser.py +0 -0
  45. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/otel.py +0 -0
  46. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/persistent.py +0 -0
  47. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/persistent_completion.py +0 -0
  48. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/persistent_controls.py +0 -0
  49. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/persistent_prompt.py +0 -0
  50. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/plan_mode.py +0 -0
  51. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/runstate.py +0 -0
  52. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/session_memory.py +0 -0
  53. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/skills.py +0 -0
  54. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/steering.py +0 -0
  55. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/streaming.py +0 -0
  56. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/trace.py +0 -0
  57. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/trace_viewer.py +0 -0
  58. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/harness/utils.py +0 -0
  59. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/__init__.py +0 -0
  60. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/episodic_lance.py +0 -0
  61. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/manager.py +0 -0
  62. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/redis_store.py +0 -0
  63. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/stores.py +0 -0
  64. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/memory/working.py +0 -0
  65. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/orchestrator/__init__.py +0 -0
  66. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/orchestrator/planner.py +0 -0
  67. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/react_agent_harness.egg-info/dependency_links.txt +0 -0
  68. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/react_agent_harness.egg-info/entry_points.txt +0 -0
  69. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/react_agent_harness.egg-info/top_level.txt +0 -0
  70. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/setup.cfg +0 -0
  71. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_agents_base.py +0 -0
  72. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_annotation.py +0 -0
  73. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_background_tasks.py +0 -0
  74. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_budget_guard.py +0 -0
  75. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_budget_restore.py +0 -0
  76. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_cancellation.py +0 -0
  77. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_checkpoint_resume.py +0 -0
  78. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_cli.py +0 -0
  79. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_concurrent_same_agent.py +0 -0
  80. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_console_renderer.py +0 -0
  81. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_event_payloads.py +0 -0
  82. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_executor_bridge.py +0 -0
  83. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_fallback_llm.py +0 -0
  84. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_fan_in.py +0 -0
  85. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_hitl_banner.py +0 -0
  86. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_http_fetch.py +0 -0
  87. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_llm_auth.py +0 -0
  88. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_mcp_adapter.py +0 -0
  89. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_mcp_auth.py +0 -0
  90. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_mcp_streamable_http.py +0 -0
  91. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_memory.py +0 -0
  92. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_memory_reconciler.py +0 -0
  93. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_memory_touchpoints.py +0 -0
  94. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_model_switching.py +0 -0
  95. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_oauth_browser.py +0 -0
  96. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_orchestrator.py +0 -0
  97. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_orchestrator_task_state.py +0 -0
  98. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_otel.py +0 -0
  99. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_parse_action_json.py +0 -0
  100. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_per_call_site_llm.py +0 -0
  101. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_persistent_agent.py +0 -0
  102. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_persistent_completion.py +0 -0
  103. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_persistent_controls.py +0 -0
  104. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_persistent_prompt.py +0 -0
  105. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_plan_approval.py +0 -0
  106. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_plan_mode.py +0 -0
  107. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_plan_mode_controller.py +0 -0
  108. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_redis_store.py +0 -0
  109. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_resume_hint_banner.py +0 -0
  110. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_routing_llm.py +0 -0
  111. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_run_state_machine.py +0 -0
  112. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_runstate.py +0 -0
  113. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_session_memory.py +0 -0
  114. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_skills.py +0 -0
  115. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_steering.py +0 -0
  116. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_streaming.py +0 -0
  117. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_subagent_tool.py +0 -0
  118. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_system_prompt_routing.py +0 -0
  119. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_trace.py +0 -0
  120. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_trailing_assistant_state.py +0 -0
  121. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_utils.py +0 -0
  122. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_vision.py +0 -0
  123. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tests/test_working_memory.py +0 -0
  124. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/__init__.py +0 -0
  125. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/builtin/__init__.py +0 -0
  126. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/builtin/background.py +0 -0
  127. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/builtin/fetch_image.py +0 -0
  128. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/builtin/http_fetch.py +0 -0
  129. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/mcp/__init__.py +0 -0
  130. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/tools/mcp/adapter.py +0 -0
  131. {react_agent_harness-0.13.0 → react_agent_harness-0.15.0}/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.13.0
3
+ Version: 0.15.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
@@ -33,6 +33,7 @@ Requires-Dist: redis>=5.0; extra == "dev"
33
33
  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
+ Requires-Dist: anthropic>=0.25; extra == "dev"
36
37
  Requires-Dist: respx>=0.21; extra == "dev"
37
38
  Requires-Dist: mcp>=2; extra == "dev"
38
39
  Requires-Dist: opentelemetry-api>=1.20; extra == "dev"
@@ -197,6 +197,32 @@ supports `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`; Anthropic
197
197
  supports `low`, `medium`, `high`, `xhigh`, and `max` on compatible models.
198
198
  Unsupported provider/value combinations fail before the request is sent.
199
199
 
200
+ ### Server tools (web search) and their events
201
+
202
+ `AnthropicLLM` and `ClaudeCodeLLM` forward `tools` to the Messages API, so
203
+ Anthropic's server tools (such as web search) run inside the call. Pass
204
+ `on_event` to see what they do while the text streams. Text still arrives as
205
+ the string deltas; `on_event` receives normalized dicts alongside it
206
+ (`harness.llm.server_tools`):
207
+
208
+ ```python
209
+ seen = []
210
+ async for delta in llm.stream_complete(
211
+ system, messages,
212
+ tools=[{"type": "web_search_20250305", "name": "web_search", "max_uses": 3}],
213
+ on_event=seen.append,
214
+ ):
215
+ ...
216
+ # seen: {"type": "tool_use", "name": "web_search", "input": {"query": ...}} before the search runs
217
+ # {"type": "tool_result", "name": "web_search", "results": [{"url", "title", "page_age"}]}
218
+ # {"type": "citation", "url": ..., "title": ..., "cited_text": ...} sources the text cites
219
+ # {"type": "stop", "reason": "end_turn" | "pause_turn" | ...}
220
+ ```
221
+
222
+ Show citations to your users when you display search-backed answers. Clients
223
+ that support this set `SERVER_TOOL_EVENTS = True`, so callers can feature-detect
224
+ it. Without `on_event`, both clients behave exactly as before.
225
+
200
226
  Credential-backed adapters can also plug into the same contract. This is the
201
227
  shape used for provider-specific subscription or OAuth flows without teaching
202
228
  agents about auth:
@@ -243,7 +269,7 @@ Codex OAuth client id can be overridden with
243
269
  from harness.llm.openai_codex import OpenAICodexLLM
244
270
 
245
271
  llm = OpenAICodexLLM(
246
- model="gpt-5.5",
272
+ model="gpt-6.1-sol",
247
273
  auth_file="~/.agent-harness/auth/auth.json", # Pi-shaped openai-codex OAuth entry
248
274
  )
249
275
  runtime = AgentRuntime(..., llm=llm)
@@ -367,7 +393,7 @@ selector.
367
393
  `ClaudeCodeLLM` reads a `claude-code` OAuth entry, refreshes it automatically
368
394
  when expired, and retries once after `401`/`403`. This mirrors Pi's Claude
369
395
  Pro/Max extension approach rather than shelling out to the Claude CLI. The
370
- default model is the current canonical Sonnet release ID, `claude-sonnet-4-6`;
396
+ default model is `claude-sonnet-5-5`;
371
397
  set `CLAUDE_CODE_MODEL` or pass `model="claude-opus-4-7"` to choose another
372
398
  model.
373
399
 
@@ -672,6 +698,15 @@ continuity flows through long-term memory (`MemoryManager.build_context(
672
698
  agent_id=…)`), not through WM carry-over — same model as the
673
699
  orchestrator's per-task agents.
674
700
 
701
+ **Crash-resume.** A delegation mints its own `run_id`, which reaches the
702
+ parent on the `subagent_start` event and is recorded on the action. If the
703
+ process dies mid-delegation, resuming the parent continues the sub-agent from
704
+ its own checkpoint instead of re-running it. Resuming is best-effort: with no
705
+ checkpoint store, no stored state, or a pre-0.13 checkpoint, the delegation
706
+ simply runs again. Execution is at-least-once either way — the step in flight
707
+ when the checkpoint was written is replayed, which `ActionState.attempts`
708
+ records.
709
+
675
710
  Parallel delegation works via the existing `actions: [...]` shape:
676
711
 
677
712
  ```json
@@ -828,9 +863,13 @@ The demo uses that utility for:
828
863
 
829
864
  Background sub-agent tasks are process-local. They keep running while the
830
865
  REPL/server process is alive; completed results become durable only when
831
- collected into the session transcript with `/tasks collect <id|all>`. Avoid
832
- launching overlapping work against the same sub-agent instance unless that
833
- agent's tools and LLM adapter are safe for concurrent use.
866
+ collected into the session transcript with `/tasks collect <id|all>`.
867
+
868
+ Overlapping delegations to one sub-agent are safe as of 0.13: each invocation
869
+ runs on its own copy of the tool and its nested agent, so concurrent runs no
870
+ longer share working memory. What remains your responsibility is whether that
871
+ agent's **tools and LLM adapter** tolerate concurrent use — a tool holding a
872
+ single connection or a non-reentrant client still needs its own guarding.
834
873
 
835
874
  When a `PersistentAgent` coordinator is wired with `SubAgentTool`s, it also
836
875
  gets LLM-visible background tools automatically:
@@ -1042,12 +1081,20 @@ a string to `n` characters with a trailing `…`.
1042
1081
 
1043
1082
  `AgentConfig.working_memory_max_tokens` controls per-agent eviction. **Default
1044
1083
  is `None` — auto-derived from the LLM's context window at runtime** so the
1045
- threshold adapts when you swap models (a 128K `gpt-5.4-mini` gets ~99K of WM
1046
- headroom; a 200K `claude-sonnet-4-6` gets ~159K; a tiny 8K fallback gets ~6K).
1084
+ threshold adapts when you swap models (the 1.05M `gpt-6.1-sol` default gets ~836K of WM
1085
+ headroom; the 1M `claude-sonnet-5-5` default gets ~796K; a tiny 8K fallback gets ~6K).
1047
1086
  Concretely the WM compacts at `0.8 × llm.input_token_budget`, leaving 20%
1048
1087
  headroom for system prompt, memory context, tool schemas, and tokeniser
1049
1088
  variance.
1050
1089
 
1090
+ OpenAI adapters default to `gpt-6.1-sol`; Anthropic adapters default to
1091
+ `claude-sonnet-5-5`. Their context windows use the documented model limits:
1092
+ [1,050,000 tokens for GPT-6.1 Sol](https://developers.openai.com/api/docs/models/gpt-6.1-sol)
1093
+ and [1,000,000 for Sonnet 5.5](https://platform.claude.com/docs/en/models/sonnet-5-5/overview).
1094
+ OpenAI documents a separate 500K default for its Codex and ChatGPT Work apps;
1095
+ the harness uses the model maximum. Input budgets reserve output capacity
1096
+ and safety slack. Explicit model and context overrides remain supported.
1097
+
1051
1098
  Each shipped adapter (`OpenAILLM`, `AnthropicLLM`, `ClaudeCodeLLM`,
1052
1099
  `OpenAICodexLLM`) exposes `context_window` and `input_token_budget`
1053
1100
  properties driven by a per-provider lookup table. For models the table
@@ -62,6 +62,19 @@ def _assistant_message(response: dict) -> str:
62
62
  return json.dumps(response, default=str)
63
63
 
64
64
 
65
+ def _resume_factory(tool: Any, state: Any) -> Any:
66
+ """Zero-arg factory that continues a delegation from stored state.
67
+
68
+ Mirrors :func:`_freeze_factory` — the fan-in helper takes factories, not
69
+ iterators, so the captured value stays bound per driver.
70
+ """
71
+
72
+ def factory() -> Any:
73
+ return tool.resume_stream(state)
74
+
75
+ return factory
76
+
77
+
65
78
  def _freeze_factory(tool: Any, args: dict) -> Any:
66
79
  """Bind ``tool`` and ``args`` into a zero-arg factory the fan-in helper
67
80
  can call to spawn one driver per parallel streaming tool.
@@ -195,6 +208,7 @@ class BaseAgent:
195
208
  llm,
196
209
  checkpoint_store: Any | None = None, # FileCheckpointStore / RedisCheckpointStore
197
210
  steering_source_factory: Any | None = None, # (BaseAgent) -> async ctx mgr
211
+ approver: Any | None = None, # async (ApprovalRequest) -> ApprovalResponse
198
212
  ) -> None:
199
213
  self.config = config
200
214
  self.role = config.role # exposed for orchestrator planner prompt
@@ -222,6 +236,8 @@ class BaseAgent:
222
236
  # async context manager that, while active, may call agent.steer().
223
237
  # The agent owns the source's lifecycle — no live-instance registry.
224
238
  self._steering_source_factory = steering_source_factory
239
+ # Who approves gated tool calls. None → the terminal prompt.
240
+ self._approver = approver
225
241
  self._resume_key: str = (
226
242
  "" # key printed in --resume banner; set by orchestrator to outer run_id
227
243
  )
@@ -852,14 +868,16 @@ class BaseAgent:
852
868
  if gated:
853
869
  await self._persist(state)
854
870
 
855
- async for event in self._execute_actions(runnable):
871
+ async for event in self._execute_actions(state, runnable):
856
872
  yield event
857
873
 
858
874
  if gated:
859
875
  await self._persist(state)
860
876
  state.phase = Phase.OBSERVE
861
877
 
862
- async def _execute_actions(self, actions: list[ActionState]) -> AsyncGenerator[BusEvent, None]:
878
+ async def _execute_actions(
879
+ self, state: RunState, actions: list[ActionState]
880
+ ) -> AsyncGenerator[BusEvent, None]:
863
881
  """Execute actions concurrently, bubbling any streaming tool's events.
864
882
 
865
883
  Mixed batches are supported: streaming tools push their events through
@@ -875,7 +893,20 @@ class BaseAgent:
875
893
  tool = self._tool_for_invocation(action.tool)
876
894
  if tool is not None and hasattr(tool, "execute_stream"):
877
895
  self._prepare_delegation(tool)
878
- streaming.append((action, _freeze_factory(tool, action.args)))
896
+ # A delegation that started before a crash carries the id of
897
+ # its own run. If that run's state is still live, continue it
898
+ # rather than discarding however many steps it had done.
899
+ resume_state = None
900
+ if action.invocation_id and hasattr(tool, "load_resume_state"):
901
+ resume_state = await tool.load_resume_state(action.invocation_id)
902
+ streaming.append(
903
+ (
904
+ action,
905
+ _resume_factory(tool, resume_state)
906
+ if resume_state is not None
907
+ else _freeze_factory(tool, action.args),
908
+ )
909
+ )
879
910
  else:
880
911
  plain.append(action)
881
912
  plain_tasks.append(self._execute_tool(action.tool, action.args, tool=tool))
@@ -891,6 +922,17 @@ class BaseAgent:
891
922
  try:
892
923
  async for idx, item in fan_in([factory for _, factory in streaming]):
893
924
  if isinstance(item, BusEvent):
925
+ # A delegation's run id exists only inside the tool
926
+ # until it rides out on this event. Recording it is
927
+ # what makes the sub-agent's checkpoint addressable —
928
+ # without it that state is written and then orphaned
929
+ # under a key nobody can name.
930
+ if item.type is EventType.SUBAGENT_START:
931
+ captured = item.payload.get("invocation_id")
932
+ started = streaming[idx][0]
933
+ if captured and started.invocation_id != captured:
934
+ started.invocation_id = captured
935
+ await self._persist(state)
894
936
  yield item
895
937
  else:
896
938
  # Streaming tools yield exactly one non-BusEvent
@@ -1315,7 +1357,7 @@ class BaseAgent:
1315
1357
  if action.tool not in self.config.hitl_tools:
1316
1358
  return None
1317
1359
 
1318
- from harness.hitl import ApprovalRequest, is_allowed, request_approval
1360
+ from harness.hitl import ApprovalRequest, ask_approver, is_allowed, request_approval
1319
1361
 
1320
1362
  if is_allowed(action.tool, action.args):
1321
1363
  return None # fast-path: human already allowed this tool/prefix
@@ -1327,19 +1369,19 @@ class BaseAgent:
1327
1369
  # dropping the rest of the batch.
1328
1370
  await self._persist(state)
1329
1371
 
1330
- return await request_approval(
1331
- ApprovalRequest(
1332
- approval_id=action.approval_id,
1333
- run_id=self._resume_key, # standalone: ckp_id; orchestrated: outer run_id
1334
- agent_id=self.config.agent_id,
1335
- tool=action.tool,
1336
- args=action.args,
1337
- step=state.step,
1338
- timestamp=datetime.now(timezone.utc).isoformat(),
1339
- resume_hint=self._hitl_resume_hint if not self._checkpoint_resume_enabled else None,
1340
- ),
1341
- self._guard,
1372
+ req = ApprovalRequest(
1373
+ approval_id=action.approval_id,
1374
+ run_id=self._resume_key, # standalone: ckp_id; orchestrated: outer run_id
1375
+ agent_id=self.config.agent_id,
1376
+ tool=action.tool,
1377
+ args=action.args,
1378
+ step=state.step,
1379
+ timestamp=datetime.now(timezone.utc).isoformat(),
1380
+ resume_hint=self._hitl_resume_hint if not self._checkpoint_resume_enabled else None,
1342
1381
  )
1382
+ if self._approver is not None:
1383
+ return await ask_approver(self._approver, req, self._guard)
1384
+ return await request_approval(req, self._guard)
1343
1385
 
1344
1386
  async def _inject_human_guidance(self, assistant_message: str, correction: str) -> None:
1345
1387
  """Record a human correction in working memory.
@@ -30,9 +30,20 @@ Session allow:
30
30
  Typing a or allow approves the current call AND adds a (tool, prefix)
31
31
  key to a process-scoped allow-list. For shell-like tools the prefix is the
32
32
  first word of the command arg (e.g. 'git'), so allowing 'git' doesn't also
33
- allow 'rm'. Subsequent calls matching the key skip checkpoint + banner.
33
+ allow 'rm'. A compound command (``;``, ``&``, ``|``, backticks, ``$(``,
34
+ ``<``, ``>``, newlines) is allowed only exactly as written, so allowing
35
+ 'git' doesn't allow ``git log; rm -rf ~`` either.
36
+ Subsequent calls matching the key skip checkpoint + banner.
34
37
  Use is_session_allowed(tool, args) to query the list from outside.
35
38
 
39
+ Approving from somewhere other than a terminal:
40
+ Pass ``approver=`` to AgentRuntime (or BaseAgent): an async callable that
41
+ takes the ApprovalRequest and returns an ApprovalResponse, e.g. by showing
42
+ the request in a web page and waiting for a click. The budget clock is
43
+ suspended while it waits, and session / persistent allows it returns are
44
+ remembered exactly as the terminal prompt's are. An approver that raises
45
+ counts as a rejection: the gate fails closed.
46
+
36
47
  Persistent allow:
37
48
  Typing A or always approves the current call and writes a user-scoped
38
49
  allow rule to ~/.agent-harness/policies/tool_policy.json. Rules are narrow:
@@ -65,11 +76,15 @@ _session_allowed: set[tuple[str, str | None]] = set()
65
76
 
66
77
 
67
78
  def _session_key(tool: str, args: dict) -> tuple[str, str | None]:
68
- """Return the (tool, prefix) key used for session-allow scoping."""
69
- if tool in ("shell", "bash", "run", "exec"):
70
- cmd = (args.get("cmd") or args.get("command") or "").strip()
71
- prefix = cmd.split()[0] if cmd else None
72
- return (tool, prefix)
79
+ """Return the (tool, prefix) key used for session-allow scoping. A compound
80
+ shell command (chained, substituted or redirected) keys to itself exactly,
81
+ so allowing it never allows anything else."""
82
+ from harness.tool_policy import SHELL_TOOLS, command_word, shell_command
83
+
84
+ if tool in SHELL_TOOLS:
85
+ cmd = shell_command(args)
86
+ word = command_word(cmd)
87
+ return (tool, word if word is not None else f"={cmd}")
73
88
  return (tool, None)
74
89
 
75
90
 
@@ -93,6 +108,8 @@ def is_allowed(tool: str, args: dict) -> bool:
93
108
  def _session_label(tool: str, args: dict) -> str:
94
109
  """Human-readable description of what 'a' would allow."""
95
110
  _, prefix = _session_key(tool, args)
111
+ if prefix and prefix.startswith("="):
112
+ return f"{tool} exactly `{prefix[1:]}`"
96
113
  return f"{tool} {prefix}" if prefix else tool
97
114
 
98
115
 
@@ -397,12 +414,42 @@ async def request_approval(
397
414
 
398
415
  print()
399
416
  resp = _parse_stdin(req.approval_id, raw)
400
- if resp.session_allow:
401
- _session_allowed.add(_session_key(req.tool, req.args))
402
- print(f" ✓ '{_session_label(req.tool, req.args)}' allowed for this session\n")
403
- if resp.persistent_allow:
404
- from harness.tool_policy import ToolPolicyStore
405
-
406
- rule = ToolPolicyStore().add_allow_rule(tool=req.tool, args=req.args)
407
- print(f" ✓ '{_session_label(req.tool, req.args)}' always allowed ({rule.id})\n")
417
+ for line in remember_allow(req, resp):
418
+ print(f" ✓ {line}\n")
408
419
  return resp
420
+
421
+
422
+ def remember_allow(req: ApprovalRequest, resp: ApprovalResponse) -> list[str]:
423
+ """Record the session / persistent allow a response carries; what was allowed."""
424
+ done: list[str] = []
425
+ if not resp.approved:
426
+ return done
427
+ label = _session_label(req.tool, req.args)
428
+ if resp.session_allow:
429
+ _session_allowed.add(_session_key(req.tool, req.args))
430
+ done.append(f"'{label}' allowed for this session")
431
+ if resp.persistent_allow:
432
+ from harness.tool_policy import ToolPolicyStore
433
+
434
+ rule = ToolPolicyStore().add_allow_rule(tool=req.tool, args=req.args)
435
+ done.append(f"'{label}' always allowed ({rule.id})")
436
+ return done
437
+
438
+
439
+ async def ask_approver(approver: Any, req: ApprovalRequest, guard: Any) -> ApprovalResponse:
440
+ """Ask a caller-supplied approver instead of the terminal. Fails closed."""
441
+ guard.suspend()
442
+ try:
443
+ resp = await approver(req)
444
+ except asyncio.CancelledError:
445
+ raise
446
+ except Exception as exc: # noqa: BLE001 — any failure to get an answer is a "no"
447
+ logger.warning("approver failed for %s: %r; rejecting", req.tool, exc)
448
+ return ApprovalResponse(approval_id=req.approval_id, approved=False)
449
+ finally:
450
+ guard.resume()
451
+ if not isinstance(resp, ApprovalResponse):
452
+ logger.warning("approver returned %r for %s; rejecting", type(resp).__name__, req.tool)
453
+ return ApprovalResponse(approval_id=req.approval_id, approved=False)
454
+ remember_allow(req, resp)
455
+ return resp
@@ -56,6 +56,7 @@ from harness.llm.reasoning import (
56
56
  ReasoningEffort,
57
57
  validate_reasoning_effort,
58
58
  )
59
+ from harness.llm.server_tools import ServerToolEvents
59
60
 
60
61
  logger = logging.getLogger(__name__)
61
62
 
@@ -64,10 +65,11 @@ logger = logging.getLogger(__name__)
64
65
  # per-model context limits. Maintain a small lookup; users running new
65
66
  # models pass ``context_window=N`` explicitly.
66
67
  #
67
- # Anthropic frames "context window" as input-only — output has its own
68
- # ``max_tokens`` ceiling, billed separately. So ``input_token_budget``
69
- # below is just the window minus a safety slack.
68
+ # Context includes input and output; reserve ``max_tokens`` plus safety slack
69
+ # when calculating the input budget.
70
70
  _ANTHROPIC_CONTEXT_WINDOWS: dict[str, int] = {
71
+ # https://platform.claude.com/docs/en/models/sonnet-5-5/overview
72
+ "claude-sonnet-5-5": 1_000_000,
71
73
  "claude-sonnet-4-6": 200_000,
72
74
  "claude-sonnet-4": 200_000,
73
75
  "claude-opus-4": 200_000,
@@ -123,10 +125,13 @@ def _append_json_reminder(messages: list[dict]) -> list[dict]:
123
125
 
124
126
 
125
127
  class AnthropicLLM:
128
+ # stream_complete/complete accept on_event and tools (see harness.llm.server_tools).
129
+ SERVER_TOOL_EVENTS = True
130
+
126
131
  def __init__(
127
132
  self,
128
133
  *,
129
- model: str = "claude-sonnet-4-6",
134
+ model: str = "claude-sonnet-5-5",
130
135
  api_key: str | None = None, # falls back to ANTHROPIC_API_KEY env
131
136
  # Generous default — matches OpenAILLM's max_completion_tokens=4096.
132
137
  # ReAct ``thought`` fields + finish answers were getting clipped at
@@ -164,15 +169,13 @@ class AnthropicLLM:
164
169
 
165
170
  @property
166
171
  def context_window(self) -> int:
167
- """Input-token context window for the configured model."""
172
+ """Total context window (input + output) for the configured model."""
168
173
  return self._context_window
169
174
 
170
175
  @property
171
176
  def input_token_budget(self) -> int:
172
- """Tokens available for the prompt. Anthropic frames context as
173
- input-only; ``max_tokens`` for output is enforced separately, so
174
- no output-reserve subtraction is needed here."""
175
- return max(1024, self._context_window - _ANTHROPIC_TOKEN_BUDGET_SAFETY)
177
+ """Prompt budget after reserving output capacity and safety slack."""
178
+ return max(1024, self._context_window - self._max_tokens - _ANTHROPIC_TOKEN_BUDGET_SAFETY)
176
179
 
177
180
  def set_budget(self, guard: Any) -> None:
178
181
  """Inject a BudgetGuard; AgentRuntime calls this at the start of each run."""
@@ -189,6 +192,7 @@ class AnthropicLLM:
189
192
  **kwargs: Any,
190
193
  ) -> dict:
191
194
  max_tokens = int(kwargs.pop("max_tokens", self._max_tokens))
195
+ on_event = kwargs.pop("on_event", None)
192
196
  json_mode = kwargs.get("response_format", {}).get("type") == "json_object"
193
197
  sys_blocks = _system_blocks(system, prompt_caching=self._prompt_caching)
194
198
  built_messages = _build_messages(messages, prompt_caching=self._prompt_caching)
@@ -206,7 +210,12 @@ class AnthropicLLM:
206
210
  if output_config is not None:
207
211
  request["output_config"] = output_config
208
212
 
213
+ if kwargs.get("tools"):
214
+ request["tools"] = kwargs["tools"]
215
+
209
216
  resp = await self._client.messages.create(**request)
217
+ if on_event is not None:
218
+ _replay_server_tool_events(resp, ServerToolEvents(on_event))
210
219
  usage = _extract_usage(resp.usage, resp.model or self._model)
211
220
  cost = _compute_cost(usage, self._cost_fn)
212
221
  if cost is not None:
@@ -227,6 +236,7 @@ class AnthropicLLM:
227
236
  source: str | None = None,
228
237
  **kwargs: Any,
229
238
  ) -> AsyncGenerator[str, None]:
239
+ on_event = kwargs.pop("on_event", None)
230
240
  json_mode = kwargs.get("response_format", {}).get("type") == "json_object"
231
241
  sys_blocks = _system_blocks(system, prompt_caching=self._prompt_caching)
232
242
  built_messages = _build_messages(messages, prompt_caching=self._prompt_caching)
@@ -244,11 +254,30 @@ class AnthropicLLM:
244
254
  if output_config is not None:
245
255
  request["output_config"] = output_config
246
256
 
257
+ if kwargs.get("tools"):
258
+ request["tools"] = kwargs["tools"]
259
+
247
260
  async with self._client.messages.stream(**request) as stream:
248
261
  yielded = False
249
- async for text in stream.text_stream:
250
- yielded = True
251
- yield text
262
+ if on_event is None:
263
+ async for text in stream.text_stream:
264
+ yielded = True
265
+ yield text
266
+ else: # same text, read from the raw events so tool events can be reported
267
+ events = ServerToolEvents(on_event)
268
+ async for event in stream:
269
+ raw = _event_dict(event)
270
+ if raw is None:
271
+ continue
272
+ events.feed(raw)
273
+ delta = raw.get("delta") or {}
274
+ if (
275
+ raw.get("type") == "content_block_delta"
276
+ and delta.get("type") == "text_delta"
277
+ ):
278
+ if delta.get("text"):
279
+ yielded = True
280
+ yield delta["text"]
252
281
 
253
282
  final = await stream.get_final_message()
254
283
  # Bedrock (AnthropicBedrock client) sometimes delivers the full
@@ -394,3 +423,35 @@ def _compute_cost(usage: dict, cost_fn: Callable[[dict], float] | None) -> float
394
423
  except Exception as e:
395
424
  logger.warning("cost_fn raised: %s — skipping cost for this call", e)
396
425
  return None
426
+
427
+
428
+ def _event_dict(event: Any) -> dict | None:
429
+ """A raw stream event as a plain dict; the SDK's own helper events are skipped."""
430
+ if isinstance(event, dict):
431
+ return event
432
+ dump = getattr(event, "model_dump", None)
433
+ if dump is None:
434
+ return None
435
+ raw = dump()
436
+ # The SDK interleaves convenience events (text, citation, input_json, ...) with the raw
437
+ # ones; only the raw Messages API events are fed on.
438
+ raw_types = {
439
+ "message_start",
440
+ "message_delta",
441
+ "message_stop",
442
+ "content_block_start",
443
+ "content_block_delta",
444
+ "content_block_stop",
445
+ }
446
+ return raw if raw.get("type") in raw_types else None
447
+
448
+
449
+ def _replay_server_tool_events(resp: Any, events: ServerToolEvents) -> None:
450
+ """Non-streaming: report the final message's tool blocks and citations as events."""
451
+ for index, block in enumerate(getattr(resp, "content", None) or []):
452
+ raw = block if isinstance(block, dict) else block.model_dump()
453
+ events.feed({"type": "content_block_start", "index": index, "content_block": raw})
454
+ events.feed({"type": "content_block_stop", "index": index})
455
+ reason = getattr(resp, "stop_reason", None)
456
+ if reason:
457
+ events.feed({"type": "message_delta", "delta": {"stop_reason": reason}})
@@ -21,6 +21,7 @@ from harness.llm.reasoning import (
21
21
  ReasoningEffort,
22
22
  validate_reasoning_effort,
23
23
  )
24
+ from harness.llm.server_tools import OnEvent, ServerToolEvents
24
25
 
25
26
  CLAUDE_CODE_BETAS = os.environ.get(
26
27
  "CLAUDE_CODE_BETAS",
@@ -35,6 +36,9 @@ _cli_version_probed = False
35
36
 
36
37
 
37
38
  class ClaudeCodeLLM:
39
+ # stream_complete/complete accept on_event (see harness.llm.server_tools).
40
+ SERVER_TOOL_EVENTS = True
41
+
38
42
  def __init__(
39
43
  self,
40
44
  *,
@@ -70,7 +74,7 @@ class ClaudeCodeLLM:
70
74
  model
71
75
  or os.environ.get("CLAUDE_CODE_MODEL")
72
76
  or os.environ.get("ANTHROPIC_MODEL")
73
- or "claude-sonnet-4-6"
77
+ or "claude-sonnet-5-5"
74
78
  )
75
79
  self._base_url = base_url.rstrip("/")
76
80
  self._timeout = request_timeout_seconds
@@ -102,9 +106,8 @@ class ClaudeCodeLLM:
102
106
 
103
107
  @property
104
108
  def input_token_budget(self) -> int:
105
- """Tokens available for the prompt; Anthropic semantics — context is
106
- input-only, output cap is separate."""
107
- return max(1024, self._context_window - self._token_budget_safety)
109
+ """Prompt budget after reserving output capacity and safety slack."""
110
+ return max(1024, self._context_window - self._max_tokens - self._token_budget_safety)
108
111
 
109
112
  def set_budget(self, guard: Any) -> None:
110
113
  """Inject a BudgetGuard so token caps fire on subscription-auth runs.
@@ -130,10 +133,11 @@ class ClaudeCodeLLM:
130
133
  `stream=true` and accumulate the deltas.
131
134
  """
132
135
  max_tokens = int(kwargs.pop("max_tokens", self._max_tokens))
136
+ on_event = kwargs.pop("on_event", None)
133
137
  extra = self._request_extra(kwargs)
134
138
  parts: list[str] = []
135
139
  async for delta in self._iter_stream(
136
- system, messages, max_tokens=max_tokens, extra=extra, source=source
140
+ system, messages, max_tokens=max_tokens, extra=extra, source=source, on_event=on_event
137
141
  ):
138
142
  parts.append(delta)
139
143
  text = "".join(parts)
@@ -150,9 +154,10 @@ class ClaudeCodeLLM:
150
154
  **kwargs: Any,
151
155
  ) -> AsyncGenerator[str, None]:
152
156
  max_tokens = int(kwargs.pop("max_tokens", self._max_tokens))
157
+ on_event = kwargs.pop("on_event", None)
153
158
  extra = self._request_extra(kwargs)
154
159
  async for delta in self._iter_stream(
155
- system, messages, max_tokens=max_tokens, extra=extra, source=source
160
+ system, messages, max_tokens=max_tokens, extra=extra, source=source, on_event=on_event
156
161
  ):
157
162
  yield delta
158
163
 
@@ -189,11 +194,15 @@ class ClaudeCodeLLM:
189
194
  max_tokens: int,
190
195
  extra: dict[str, Any],
191
196
  source: str | None = None,
197
+ on_event: OnEvent | None = None,
192
198
  ) -> AsyncGenerator[str, None]:
193
199
  """Single source of truth: open Anthropic SSE stream, yield text
194
200
  deltas, populate `self.last_usage`. Auth refresh on 401/403
195
201
  happens before any delta is yielded so we never retry mid-stream.
202
+ With `on_event`, server-tool events (searches, results, citations,
203
+ stop reason) are reported alongside; see harness.llm.server_tools.
196
204
  """
205
+ events = ServerToolEvents(on_event) if on_event is not None else None
197
206
  payload = _build_payload(
198
207
  model=self._model,
199
208
  system=system,
@@ -231,6 +240,8 @@ class ClaudeCodeLLM:
231
240
  continue
232
241
  if not isinstance(obj, dict):
233
242
  continue
243
+ if events is not None:
244
+ events.feed(obj)
234
245
  otype = obj.get("type")
235
246
  if otype == "content_block_delta":
236
247
  delta = obj.get("delta")
@@ -385,6 +396,7 @@ def _build_payload(
385
396
  "stop_sequences",
386
397
  "thinking",
387
398
  "output_config",
399
+ "tools",
388
400
  ):
389
401
  if key in extra:
390
402
  payload[key] = extra[key]
@@ -69,7 +69,9 @@ _GATEWAY_COST_HEADERS = (
69
69
  _SENTINEL: Any = object()
70
70
 
71
71
 
72
- # Known OpenAI model context windows (input + output combined). OpenAI's
72
+ # Context windows (input + output combined). GPT-6.1 Sol: 1,050,000 tokens.
73
+ # https://developers.openai.com/api/docs/models/gpt-6.1-sol
74
+ # Callers can override this for their deployment. OpenAI's
73
75
  # ``/v1/models`` endpoint does NOT expose this — we maintain a table and
74
76
  # fall back conservatively for unknowns. Users running new models should
75
77
  # pass ``context_window=N`` to the constructor explicitly.
@@ -77,8 +79,9 @@ _SENTINEL: Any = object()
77
79
  # Keep entries ordered with the most-specific prefixes first so the prefix
78
80
  # match in ``_lookup`` resolves the right cell.
79
81
  _OPENAI_CONTEXT_WINDOWS: dict[str, int] = {
80
- "gpt-5.4-mini": 128_000,
81
- "gpt-5.4": 128_000,
82
+ "gpt-6.1-sol": 1_050_000,
83
+ "gpt-5.4-mini": 256_000,
84
+ "gpt-5.4": 256_000,
82
85
  "gpt-5": 256_000,
83
86
  "gpt-4o-mini": 128_000,
84
87
  "gpt-4o": 128_000,
@@ -100,7 +103,7 @@ class OpenAILLM:
100
103
  def __init__(
101
104
  self,
102
105
  *,
103
- model: str = "gpt-5.4-mini",
106
+ model: str = "gpt-6.1-sol",
104
107
  api_key: str | None = None, # falls back to OPENAI_API_KEY env
105
108
  base_url: str | None = None, # set when routing through a gateway
106
109
  request_timeout_seconds: float = 60.0,
@@ -28,7 +28,7 @@ class OpenAICodexLLM:
28
28
  def __init__(
29
29
  self,
30
30
  *,
31
- model: str = "gpt-5.5",
31
+ model: str = "gpt-6.1-sol",
32
32
  auth_file: str | Path | None = None,
33
33
  credential_provider: AuthFileOAuthProvider | None = None,
34
34
  base_url: str = "https://chatgpt.com/backend-api",
@@ -66,8 +66,7 @@ class OpenAICodexLLM:
66
66
  provider="openai-codex",
67
67
  allowed=OPENAI_REASONING_EFFORTS,
68
68
  )
69
- # Reuse OpenAI's table — Codex models share the gpt-5 / o-series
70
- # lineage so the same context windows apply.
69
+ # Reuse the OpenAI context budget table for the configured model.
71
70
  from harness.llm.openai import ( # noqa: PLC0415
72
71
  _OPENAI_TOKEN_BUDGET_SAFETY,
73
72
  _lookup_openai_context_window,