hermes-agent/tests/run_agent
Teknium ec46f5912e
fix(gemini): default native maxOutputTokens + strip OpenAI extra_body on Gemini endpoints (#39730)
* fix: respect disabled auto-compaction on context overflow

Port from anomalyco/opencode#30749.

When compression.enabled is false, NO automatic compaction trigger may
fire. The proactive token-threshold paths (preflight + post-response
should_compress gate) already honoured the setting, but the three
provider-overflow recovery paths in the agent loop — long-context-tier
429, 413 payload-too-large, and context-overflow — called
_compress_context() unconditionally, silently compressing and rotating
the session against the user's explicit choice.

Add a single guard at the top of the overflow-recovery dispatch: when
compression is disabled and the error is one of those three overflow
classes, surface a terminal error (compaction_disabled: True) telling the
user to /compress manually, /new, switch to a larger-context model, or
reduce attachments. Manual /compress (force=True) is unaffected — it never
enters this loop.

Tests: new TestOverflowWithCompactionDisabled (413 + 400 overflow don't
compress when disabled; control case still compresses when enabled).
Existing overflow-recovery tests updated to enable compaction explicitly
(they verify the recovery fires); fixture defaults flipped to True to
match production (compression.enabled defaults to True).

* fix(gemini): default native maxOutputTokens + strip OpenAI extra_body on Gemini endpoints

Two distinct failures hit users on the gemini provider with only Google
AI Studio keys set.

1. Truncation loop: build_gemini_request() only set maxOutputTokens when
   max_tokens was non-None. Hermes passes None to mean "unlimited", but
   Gemini's native generateContent does NOT treat an absent maxOutputTokens
   as full budget — it applies a low internal default and stops early with
   finishReason=MAX_TOKENS, truncating tool calls. The agent then retries
   3x and refuses the incomplete call. Now default to the published 65,535
   ceiling (shared by all current Gemini text models) when max_tokens=None.

2. HTTP 400 on Gemini endpoint: the chat_completions transport assembles
   profile extra_body (Nous portal 'tags', reasoning, provider prefs) and
   sends it via the OpenAI client to whatever base_url is resolved. When a
   profile that emits extra_body (e.g. Nous) is active but the endpoint is a
   native Gemini base_url — typical when only Google creds exist and a
   fallback/aux call lands on Gemini — Google rejects the unknown 'tags'
   field with a non-retryable 400. Strip all non-thinking_config extra_body
   keys when the resolved endpoint is native Gemini.

Verified E2E against real transport code: tags stripped on native Gemini,
preserved on Nous and the /openai compat endpoint; maxOutputTokens=65535
on None, explicit values respected.
2026-06-05 03:53:59 -07:00
..
__init__.py
conftest.py
test_413_compression.py fix(gemini): default native maxOutputTokens + strip OpenAI extra_body on Gemini endpoints (#39730) 2026-06-05 03:53:59 -07:00
test_860_dedup.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -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): fallback immediately on provider content-policy blocks (#33883) 2026-05-28 07:28:24 -07:00
test_31273_402_not_retried.py
test_agent_guardrails.py
test_anthropic_prompt_cache_policy.py
test_anthropic_third_party_oauth_guard.py
test_anthropic_truncation_continuation.py
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 chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_background_review.py
test_background_review_cache_parity.py
test_background_review_summary.py
test_background_review_toolset_restriction.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_callable_api_key.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_codex_app_server_integration.py
test_codex_multimodal_tool_result.py
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
test_codex_xai_oauth_recovery.py Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
test_commit_memory_session_context_engine.py
test_compress_focus_plugin_fallback.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -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 chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_compression_feasibility.py
test_compression_persistence.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -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
test_copilot_native_vision_headers.py
test_create_openai_client_kwargs_isolation.py
test_create_openai_client_proxy_env.py
test_create_openai_client_reuse.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_credential_pool_interrupt.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_deepseek_reasoning_content_echo.py fix(agent): re-pad reasoning_content on cross-provider fallback to require-side providers 2026-05-28 03:21:00 -07:00
test_deepseek_v4_thinking_live.py
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_empty_response_recovery_persistence.py
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 chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_file_mutation_verifier.py fix(security): neutralize file paths in mutation-verifier footer (#35584) (#35684) 2026-05-30 23:05:23 -07:00
test_image_rejection_fallback.py
test_image_shrink_recovery.py fix(vision): guard image pixel dimensions, not just bytes (#37677) 2026-06-04 06:16:45 -07:00
test_init_fallback_on_exhausted_pool.py
test_interactive_interrupt.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -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 chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
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
test_last_reasoning_per_turn.py
test_long_context_tier_429.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_materialize_data_url_cleanup.py
test_memory_nudge_counter_hydration.py
test_memory_provider_init.py
test_memory_sync_interrupted.py feat: expose completed-turn message context to memory providers 2026-05-29 02:16:43 +05:30
test_message_sequence_repair.py
test_multimodal_tool_content_recovery.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_openai_client_lifecycle.py
test_partial_stream_finish_reason.py
test_percentage_clamp.py
test_plugin_context_engine_init.py
test_primary_runtime_restore.py Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
test_provider_attribution_headers.py
test_provider_fallback.py
test_provider_parity.py fix: strip extra_content from tool_calls for strict APIs (Fireworks, Mistral) 2026-06-03 16:42:52 -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
test_retry_status_buffer.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_review_prompt_class_first.py
test_run_agent.py fix(gemini): default native maxOutputTokens + strip OpenAI extra_body on Gemini endpoints (#39730) 2026-06-05 03:53:59 -07:00
test_run_agent_codex_responses.py fix(xai-sanitize): deepcopy tools_for_api before in-place mutation (#27907) 2026-05-28 23:29:59 -07:00
test_run_agent_multimodal_prologue.py
test_sequential_chats_live.py
test_session_id_env.py
test_session_meta_filtering.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_session_reset_fix.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_steer.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07: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
test_streaming.py Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05: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_switch_model_context.py
test_switch_model_fallback_prune.py
test_switch_model_rollback.py
test_thinking_only_sanitizer.py
test_tls_fd_recycle_corruption.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_token_persistence_non_cli.py
test_tool_arg_coercion.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_tool_call_args_sanitizer.py
test_tool_call_guardrail_runtime.py
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
test_turn_completion_explainer.py fix(agent): register explainer config key + shorten footer prefix 2026-05-29 19:23:05 -07:00
test_unicode_ascii_codec.py
test_vision_aware_preprocessing.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00