hermes-agent/tests/run_agent
teknium1 cfd2a38223 fix(conversation): anchor the cwd staleness read to the host-info block
The whole-prompt scan for "Current working directory:" matched USER project
content, not just Hermes' own host-info line. The prompt embeds AGENTS.md /
CLAUDE.md / .cursorrules in the context tier, which sits AFTER the host-info
block, and line_value() takes the LAST match — so any project file containing
a line starting with that label won the scan.

The comparison then ran runtime state against project prose, a mismatch that
never clears: the stored prompt was rejected on EVERY turn, rebuilding the
system prompt each message and destroying the prefix cache for the whole
session. Strictly worse than the staleness the check exists to catch, and
invisible to CI because no test encoded the invariant.

"last match wins" was only ever safe because Model/Provider/Platform live in
the volatile tier at the very END of the prompt. The cwd line is the one field
read from the STABLE tier near the start, so it needs an anchored read:
locate Hermes' own "User home directory:" line and take the working-directory
line that follows it.

Verified against the real builder on a real AIAgent, not a stub:
  - stable cwd, clean project           -> prompt REUSED (0 rebuilds)
  - stable cwd, AGENTS.md naming the
    field                               -> prompt REUSED (was: rebuild/turn)
  - drifted cwd                         -> rebuilt
  - drifted cwd, AGENTS.md naming the
    NEW cwd                             -> rebuilt (prose can't mask drift)

Also re-verified no spurious rebuild across all five cwd-resolution paths
(pinned contextvar, TERMINAL_CWD, launch dir, symlinked workspace,
trailing-slash cwd).

The contributor's fixtures omitted the host-info anchor, so they silently
stopped exercising the cwd path once the read was anchored; reshaped them to
match real prompt structure via a _host_block() helper.
2026-07-25 19:25:34 -07:00
..
__init__.py
conftest.py ci(tests): add pytest-timeout 60s hard cap to break suite-teardown deadlock (#28861) 2026-05-19 17:27:24 -07:00
repro_48013_image_shrink_brick.py fix(agent): accept pixel-correct image downscale when bytes grow (#48013) 2026-06-19 11:37:51 -07:00
test_413_compression.py fix(context_compression): roll back interrupted preflight state pollution 2026-07-23 16:38:06 -07:00
test_860_dedup.py fix: harden gateway startup and turn persistence 2026-06-07 02:15:23 -07:00
test_1630_context_overflow_loop.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_18028_content_policy_blocked.py fix(agent): add MiniMax 'new_sensitive' to content_policy_blocked patterns 2026-06-28 01:15:21 -07:00
test_24996_fallback_exhaustion_cooldown.py test(24996): freeze monotonic clock to de-flake fallback cooldown timing 2026-06-27 21:07:53 -07:00
test_28161_anthropic_stream_pool_cleanup.py fix(agent): request-local Anthropic clients so the stale/interrupt watchdog never corrupts SQLite (#67142) 2026-07-18 21:20:48 -04:00
test_31273_402_not_retried.py fix(agent): abort on HTTP 402 after pool rotation and fallback fail (#31443) 2026-05-24 15:14:13 -07:00
test_32646_fallback_429_after_timeout.py fix(agent): reopen fallback chain after primary recovery 2026-06-28 00:57:42 -07:00
test_63425_credential_pool_auto_detect.py fix(agent): validate credential pool after provider auto-detection (#63425) 2026-07-14 16:51:35 +05:30
test_66267_multimodal_interim.py fix: normalize multimodal list content in build_assistant_message (#66267) 2026-07-18 19:39:07 +05:30
test_70773_shared_client_fd_corruption.py fix(agent): retire replaced shared OpenAI clients instead of cross-thread pool close 2026-07-24 16:04:48 -07:00
test_agent_guardrails.py test: deflake CI and dev-machine flaky tests in bulk (11 tests, 10 files) (#61816) 2026-07-09 20:03:11 -07:00
test_anthropic_prompt_cache_policy.py fix(caching): use canonical Kimi-family matcher in cache policy 2026-07-09 14:27:22 +05:30
test_anthropic_third_party_oauth_guard.py fix(anthropic): complete third-party Anthropic-compatible provider support (#12846) 2026-04-19 22:43:09 -07:00
test_anthropic_truncation_continuation.py chore: ruff auto-fix PLR6201 resweep — tuple → set in membership tests (#27355) 2026-05-17 02:29:41 -07:00
test_api_max_retries_config.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_async_httpx_del_neuter.py fix(auxiliary): honor main fallback chain for auto tasks (#47235) 2026-06-16 06:23:24 -07:00
test_auth_provider_failover.py fix(agent): fail over to fallback provider on persistent auth failure (401/403) 2026-06-20 11:38:01 -07:00
test_background_review.py fix(session): opt the background-review fork out of session finalization 2026-06-21 11:35:09 -07:00
test_background_review_cache_parity.py fix(background_review): gate reasoning_config inheritance on not-routed + dedupe recorder stubs 2026-07-14 17:19:46 +05:30
test_background_review_cost_controls.py fix(runtime): preserve resolved fork metadata 2026-07-10 18:32:32 +05:30
test_background_review_summary.py fix(agent): exclude prior-history tool messages from background review summary 2026-04-24 03:10:19 -07:00
test_background_review_toolset_restriction.py fix(profile): gate bg-review memory tool on memory_enabled (#54937 layer 2) 2026-06-30 15:30:06 -07:00
test_callable_api_key.py refactor(cli): extract agent-construction cluster into CLIAgentSetupMixin (god-file Phase 4) 2026-06-08 09:41:34 -07:00
test_codex_app_server_compaction.py fix(desktop): synchronize context usage and compaction status 2026-07-22 16:58:58 -07:00
test_codex_app_server_integration.py fix(codex): reconcile app-server bridge with #38835, gate commentary on show_commentary 2026-07-17 04:32:56 -07:00
test_codex_multimodal_tool_result.py feat(vision): vision_analyze returns pixels to vision-capable models, not aux text (#22955) 2026-05-09 21:06:19 -07:00
test_codex_no_tools_nonetype.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_codex_silent_hang_hint.py fix(codex): update silent-hang workaround hint 2026-05-27 01:52:34 -07:00
test_codex_xai_oauth_recovery.py fix(credential-pool): refresh the failing entry, not current(), on auth recovery 2026-07-23 07:33:25 -07:00
test_commit_memory_session_context_engine.py refactor: address Phase-2 review findings on /new boundary handoff 2026-07-09 03:21:54 +05:30
test_compress_focus_plugin_fallback.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_compression_abort_state_reset.py test(compression): audit abort paths for per-attempt in-place state reset 2026-07-23 07:25:21 -07:00
test_compression_boundary.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_compression_boundary_hook.py fix(compression): recover rotated session lineage 2026-07-24 16:00:34 -07:00
test_compression_feasibility.py fix(compression): mirror the full trigger recomputation in the suggestion guard 2026-07-22 06:58:58 -07:00
test_compression_lock_defer.py fix(gateway): retry-next-message semantics for compression_deferred + regression suite 2026-07-23 16:23:57 -07:00
test_compression_persistence.py fix(conversation): anchor the cwd staleness read to the host-info block 2026-07-25 19:25:34 -07:00
test_compression_trigger_excludes_reasoning.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_compressor_fallback_update.py
test_concurrent_interrupt.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_context_token_tracking.py refactor(session-log): delete _save_session_log and all callers 2026-05-20 11:44:10 -07:00
test_conversation_fallback_state.py fix(conversation): clear _mute_post_response on substantive tool-only turn 2026-07-14 16:33:14 +05:30
test_copilot_native_vision_headers.py fix(copilot): mark native image requests as vision 2026-04-27 08:35:50 -07:00
test_create_openai_client_disables_sdk_retries.py fix(agent): disable OpenAI SDK auto-retry that double-fires inside the rate-limit loop 2026-06-27 19:23:15 -07:00
test_create_openai_client_kwargs_isolation.py
test_create_openai_client_proxy_env.py fix(agent): replace custom socket_options transport with httpx pool-level keepalive expiry 2026-07-05 03:14:55 -07:00
test_create_openai_client_reuse.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_create_openai_client_ssl_verify.py fix(agent): honor custom CA certs for custom_providers HTTPS endpoints 2026-07-02 04:51:56 +05:30
test_credential_pool_interrupt.py test: make interrupt-pool double's entries callable 2026-07-23 07:33:25 -07:00
test_credential_rotation_route_settings.py fix: restore base_url rstrip, extract should_clear_context_pin helper 2026-07-22 11:19:37 +05:30
test_credits_notices_toggle.py fix(credits): suppress usage gauge when top-up funds exist + add display.credits_notices toggle (#44716) 2026-06-12 01:06:46 -07:00
test_custom_provider_extra_headers_client.py feat(config): extra HTTP headers for LLM API calls (#3526 salvage) 2026-07-02 05:33:25 -07:00
test_deepseek_reasoning_content_echo.py fix(agent): strip stale reasoning_content when falling back to a strict provider (#50480) 2026-06-21 18:05:07 -07:00
test_deepseek_v4_thinking_live.py fix(deepseek): preserve v4 reasoning_content on replay 2026-04-30 11:18:39 -07:00
test_dict_tool_call_args.py test(run_agent): align test_dict_tool_call_args with explainer suffix 2026-05-29 19:23:05 -07:00
test_dropped_tool_call_recovery.py fix(agent): make dropped tool-call nudge pair ephemeral scaffolding 2026-07-24 15:56:39 -07:00
test_empty_response_recovery_persistence.py fix(agent): never persist empty-response recovery scaffolding 2026-07-01 01:08:27 -07:00
test_exit_cleanup_interrupt.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_fallback_credential_isolation.py fix(fallback): attach credential pool after provider switch 2026-06-27 04:39:26 -07:00
test_fallback_reasoning_override.py feat(config): support per-model reasoning_effort overrides 2026-07-14 11:46:40 -07:00
test_file_mutation_verifier.py feat(agent): require verification before finishing edits 2026-06-24 23:02:48 -05:00
test_fireworks_live.py fix(providers): align Fireworks integration with project policy 2026-07-11 05:43:35 -07:00
test_identity_flush.py test(agent): strengthen id-reuse regression + refresh flush docstring (review) 2026-07-01 16:17:46 +05:30
test_image_rejection_fallback.py fix(image-routing): unblock message queue on OpenRouter 'no endpoints' image 404 (#53901) 2026-06-27 19:07:02 -07:00
test_image_shrink_recovery.py fix(agent): shrink anthropic-native image history 2026-06-22 18:23:21 -05:00
test_in_place_compaction.py test: assert durable compression rotation 2026-07-19 08:55:08 +05:30
test_infinite_compaction_loop.py fix(compression): stop compaction thrash — 75% trigger floor under 512K, no summary output cap, reasoning-trace exclusion (#60989) 2026-07-08 11:56:17 -07:00
test_init_fallback_on_exhausted_pool.py fix(agent): try fallback providers at init when primary credential pool is exhausted (#17929) 2026-05-02 02:09:46 -07:00
test_interactive_interrupt.py fix: remove dead f-string prefixes via ruff F541 (216 sites) (#52336) 2026-07-05 13:42:46 -07:00
test_interrupt_propagation.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_invalid_context_length_warning.py fix(compression): harden startup route scoping 2026-07-22 11:19:37 +05:30
test_iteration_budget_race.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_jsondecodeerror_retryable.py fix(agent): classify TypeError('NoneType ... not iterable') as retryable provider shape error 2026-05-27 11:30:55 -07:00
test_last_reasoning_per_turn.py test: pin per-turn reasoning extraction semantics 2026-05-05 05:00:05 -07:00
test_lmstudio_load_mode.py feat: add LM Studio JIT load mode 2026-07-16 15:23:14 +05:30
test_long_context_tier_429.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_malformed_tool_arguments.py fix(agent): reject malformed tool call arguments (#61784) 2026-07-09 20:52:44 -07:00
test_materialize_data_url_cleanup.py fix(misc): three small defensive fixes from PR #1974 2026-05-10 22:28:01 -07:00
test_memory_nudge_counter_hydration.py refactor(agent): extract run_conversation prologue into agent/turn_context.py 2026-06-07 22:17:35 -07:00
test_memory_provider_init.py feat(memory): improve OpenViking setup UX 2026-06-17 01:04:26 +08:00
test_memory_sync_interrupted.py fix(openviking): sanitize skill memory input 2026-06-16 10:37:37 -07:00
test_message_sequence_repair.py test(agent): cover empty tool_calls array stripping in sanitizer (#58755) 2026-07-05 21:36:37 -07:00
test_moa_fanout_cadence.py feat(moa): add every_n fanout cadence with cached-guidance reuse 2026-07-23 17:50:40 -07:00
test_moa_loop_mode.py feat(moa): default advisor fanout to user_turn — the cheapest cadence 2026-07-23 21:07:18 -07:00
test_moa_privacy_filter.py feat(moa): add privacy redaction filter with display/full modes 2026-07-23 17:50:40 -07:00
test_moa_streaming.py feat(analytics): record auxiliary model usage per task in session accounting (#65537) 2026-07-16 04:23:12 -07:00
test_multimodal_tool_content_recovery.py fix(vision): proactive downgrade for providers rejecting list-type tool content (#41072) 2026-06-07 21:50:57 -07:00
test_nonretryable_error_html_summary.py test(agent): cover non-retryable error HTML summarization 2026-06-18 15:46:19 +05:30
test_notice_spine.py feat(credits): usage-aware credits — in-session notices, /usage view, dev readout (#40011) 2026-06-06 13:18:18 +05:30
test_nous_429_fallback_reentry.py test: regression guard for Nous 429 fallback re-entry; AUTHOR_MAP entry 2026-06-12 12:21:29 -07:00
test_nous_fallback_unavailable.py test: avoid OpenRouter dependency in Nous fallback coverage 2026-07-01 05:06:00 -07:00
test_openai_client_lifecycle.py fix(codex): size and propagate timeouts for Responses-API requests; lower stale defaults 2026-05-25 01:47:55 -07:00
test_partial_stream_finish_reason.py fix(streaming): detect text-only stream drops with no finish_reason (#32086) 2026-07-20 13:31:02 +05:30
test_per_model_compression_threshold.py fix: close review gaps for per-model threshold overrides (#63020) 2026-07-22 07:00:27 -07:00
test_per_model_threshold_init_ordering.py fix: close review gaps for per-model threshold overrides (#63020) 2026-07-22 07:00:27 -07:00
test_percentage_clamp.py fix(context): clamp -1 post-compression sentinel in sibling status paths 2026-07-01 13:36:50 +05:30
test_plugin_context_engine_init.py test: expect model slug in autoraise notice dict (follow-up to gpt-5.4 extension) 2026-07-06 12:46:20 -07:00
test_post_tool_compression_attempt_cap.py fix(compression): unify the attempt cap across every compression site 2026-07-22 06:56:42 -07:00
test_pre_compress_memory_context.py fix(redaction): normalize URL credential key aliases 2026-07-20 02:25:57 -07:00
test_preflight_compression_cap_e2e.py fix(compression): unify the attempt cap across every compression site 2026-07-22 06:56:42 -07:00
test_primary_runtime_restore.py fix(agent): retire replaced shared OpenAI clients instead of cross-thread pool close 2026-07-24 16:04:48 -07:00
test_proactive_prune_loop_wiring.py feat(compression): prompt-cache reclaim gate + hardened wiring for proactive prune 2026-07-23 16:44:12 -07:00
test_provider_attribution_headers.py fix(copilot): recognize enterprise subdomains in host checks 2026-06-30 03:27:41 -07:00
test_provider_fallback.py test(fallback): cover xai-oauth → xai same-host same-model failover 2026-07-24 23:22:11 +05:30
test_provider_parity.py test(providers): update Nous parity test for conversation tag 2026-07-16 01:13:43 -07:00
test_real_interrupt_subagent.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_redirect_stdout_issue.py
test_repair_tool_call_arguments.py revert: drop cumulative-resend tool-arg heuristic from shared streaming path (#35718) (#35860) 2026-05-31 06:14:32 -07:00
test_repair_tool_call_name.py fix(volcengine): strip XML attribute fragments from tool_use.name (#33007) 2026-06-07 22:22:01 -07:00
test_retry_status_buffer.py fix: preserve fallback switch notice on successful fallback 2026-07-09 13:40:19 +05:30
test_review_prompt_class_first.py fix(review): tell background reviewer not to capture transient env failures as skills (#23004) 2026-05-09 22:51:25 -07:00
test_run_agent.py fix(agent): retire replaced shared OpenAI clients instead of cross-thread pool close 2026-07-24 16:04:48 -07:00
test_run_agent_codex_responses.py test: update credential-refresh tests for retire-not-close contract 2026-07-24 16:04:48 -07:00
test_run_agent_multimodal_prologue.py refactor: unify transport dispatch + collapse normalize shims 2026-04-22 18:34:25 -07:00
test_sequential_chats_live.py
test_session_id_env.py feat: expose HERMES_SESSION_ID to agent tools via ContextVar + env (#23847) 2026-05-12 00:16:45 +05:30
test_session_meta_filtering.py fix(timeline): persist typed display events (#69771) 2026-07-23 14:46:24 -04:00
test_session_reset_fix.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_session_source.py fix(dashboard): hide sidecar sessions from history (#49269) 2026-06-19 18:06:38 -04:00
test_steer.py feat(agent): add active-turn redirect core primitive 2026-07-22 12:02:40 -05:00
test_stream_drop_logging.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_stream_interrupt_retry.py fix(streaming): block stale stream deltas 2026-07-18 19:55:16 +05:30
test_stream_single_writer_65991.py fix(codex): claim the stream-writer token on the codex_responses path too 2026-07-17 06:49:23 -07:00
test_stream_stale_breaker_reset.py fix: widen stale circuit breaker to non-streaming path + all provider-swap resets 2026-07-08 01:50:14 +05:30
test_stream_stale_circuit_breaker.py fix(agent): request-local Anthropic clients so the stale/interrupt watchdog never corrupts SQLite (#67142) 2026-07-18 21:20:48 -04:00
test_streaming.py fix(agent): close MoA stream on interrupt 2026-07-23 17:26:24 -07:00
test_streaming_tool_call_repair.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_strict_api_validation.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_strip_reasoning_tags_cli.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_summarize_api_error.py style(tests): merge import blocks in test_summarize_api_error 2026-07-09 02:01:56 +05:30
test_switch_model_context.py fix(providers): scope route-owned runtime settings 2026-07-22 11:19:37 +05:30
test_switch_model_fallback_prune.py fix(agent): default missing fallback chain on switch 2026-04-24 05:35:43 -07:00
test_switch_model_pool_reload_52727.py fix(agent): restore primary credential pool after fallback (#62417) 2026-07-11 03:44:02 -07:00
test_switch_model_reapplies_headers.py test: regression coverage for header reapplication on model switch 2026-07-09 18:23:10 -07:00
test_switch_model_reasoning_override.py feat(config): support per-model reasoning_effort overrides 2026-07-14 11:46:40 -07:00
test_switch_model_rollback.py fix(agent): roll back switch_model() state when client rebuild fails (#33228) 2026-05-27 05:43:20 -07:00
test_switch_model_stale_base_url.py fix(agent): stop switch_model from pairing new provider with stale base_url 2026-07-09 16:36:06 -07:00
test_thinking_only_sanitizer.py fix(agent): treat Codex reasoning items as thinking-only 2026-06-13 14:35:00 -07:00
test_thinking_sig_recovery_persistence.py fix(agent): strip api_messages in thinking-signature recovery so the retry actually omits thinking blocks 2026-06-10 12:39:44 -07:00
test_tls_fd_recycle_corruption.py Revert "fix(agent): release pool FDs on owning-thread client close (#61979)" (#62141) 2026-07-10 19:12:32 -07:00
test_token_persistence_non_cli.py fix: make session search initialize session db 2026-05-09 14:36:58 -07:00
test_tool_arg_coercion.py Port from cline/cline#11803: recursively normalize JSON-string tool args by schema (#52220) 2026-07-05 06:42:28 -07:00
test_tool_batch_segmentation.py fix(agent): canonicalise paths in parallel-batch planner to prevent same-file concurrent mutation 2026-07-16 04:26:32 -07:00
test_tool_call_args_sanitizer.py ci(tests): add pytest-timeout 60s hard cap to break suite-teardown deadlock (#28861) 2026-05-19 17:27:24 -07:00
test_tool_call_guardrail_runtime.py feat(plugins): pass approve rule keys to approval gate 2026-07-07 15:14:30 -07:00
test_tool_call_incremental_persistence.py fix(agent): persist tool calls before turn-end flush 2026-06-24 02:15:57 +05:30
test_tool_executor_contextvar_propagation.py fix(code-exec): propagate agent-turn context into tool worker threads 2026-05-29 03:44:49 -07:00
test_tool_name_db_persistence.py fix(agent): set tool_name on tool-result messages at construction time 2026-05-19 20:49:11 +01:00
test_turn_completion_explainer.py test(agent,gateway): cover partial-stream recovery and restart helper salvage 2026-06-27 22:03:14 -07:00
test_unicode_ascii_codec.py
test_verification_continuation_budget.py fix(desktop, ink): don't wipe messages before final message (#65919) 2026-07-20 11:42:29 -04:00
test_vision_aware_preprocessing.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_vision_tool_messages.py fix(vision): proactive downgrade for providers rejecting list-type tool content (#41072) 2026-06-07 21:50:57 -07:00
test_wait_state_visibility.py feat(agent): explain long provider waits on the live status line (#64775) 2026-07-15 00:14:05 -07:00