hermes-agent/tests/agent
Ben Barclay f52feed1ef
fix(azure-foundry): scope Responses reasoning suppression to post-tool turns (#84320)
Azure Foundry's OpenAI-compatible Responses surface rejects the post-tool
follow-up payload with HTTP 400 `invalid_payload` when a replayed encrypted
`reasoning` item is sent alongside `function_call` / `function_call_output`.
The initial function-call request and ordinary multi-turn continuity are both
accepted, so the failure only appears after the first tool executes.

Detect the Foundry endpoint in `ResponsesApiTransport.build_kwargs` and drop
only the encrypted reasoning replay on that follow-up turn, leaving
function_call / function_call_output continuity intact.

Salvage of #59981, rebuilt on current main. Same root cause and fix direction
as the original, which was correct; this version resolves three defects:

- No `chat_completion_helpers.py` change. main already forwards `provider`
  and `base_url` to the Responses transport, so the original's re-added
  arguments produced `SyntaxError: keyword argument repeated: provider` on
  merge. Dropping the hunk removed the syntax error and the conflict.

- Host matching uses `utils.base_url_host_matches`, not a substring test.
  `".services.ai.azure.com" in base_url` also matches URLs carrying the
  domain in a path or query segment, which would silently disable reasoning
  replay on an unrelated provider.

- The post-tool predicate tests the trailing messages, not the whole history.
  Scanning for any tool call plus any tool result made it sticky: one tool
  call early in a conversation suppressed reasoning on every later turn.

- Tool calls pair on `call_id` as well as `id`. Responses histories carry the
  function call id in `call_id` while `id` holds the response item id
  (`fc_...`). Identity is resolved via the converter's own
  `_split_responses_tool_id`, covering composite `"call_x|fc_y"` ids and bare
  `fc_` ids on both sides of the pairing.

Tests: 27 cases across the transport and the live `build_api_kwargs` bridge,
including six parametrized tool-call id shapes, non-Foundry host lookalikes,
the sticky-history guard, parallel tool results, and an unpaired tool result.
Each guard was confirmed to catch its defect by reverting the fix.

Verified with `scripts/run_tests.sh tests/agent/ tests/run_agent/`:
532 files, 5602 tests passed, 0 failed.

Not verified against a live Azure Foundry endpoint — no credentials. The
original HTTP 400 reproduction and post-fix Foundry Project / Azure Container
Apps harness runs are @AshuJoshi's, from #59981. This change is verified at
the payload-construction layer only.

Closes #59981.

Co-authored-by: Ashu Joshi <AshuJoshi@users.noreply.github.com>
2026-08-14 12:41:26 +10:00
..
lsp
transports fix(azure-foundry): scope Responses reasoning suppression to post-tool turns (#84320) 2026-08-14 12:41:26 +10:00
__init__.py
test_account_usage.py
test_anthropic_adapter.py fix: send Hermes Agent attribution headers to OpenCode Zen and Go 2026-08-13 02:03:40 -07:00
test_anthropic_billing_guidance.py
test_anthropic_keychain.py
test_anthropic_kimi_signed_thinking_replay.py
test_anthropic_kwargs_sanitize.py
test_anthropic_mcp_prefix_strip.py
test_anthropic_oauth_pkce.py
test_anthropic_oauth_ua_prefix.py
test_anthropic_output_field_leak.py
test_anthropic_thinking_block_order.py
test_anthropic_token_scope_isolation.py
test_anthropic_whitespace_text_blocks.py
test_api_content_sidecar.py
test_arcee_trinity_overrides.py
test_async_token_accounting.py
test_async_utils.py
test_aux_progress_streaming.py
test_auxiliary_anthropic_pool_fallback_regression.py
test_auxiliary_client.py
test_auxiliary_client_anthropic_custom.py
test_auxiliary_client_azure_foundry.py
test_auxiliary_client_base_url_host_validation_52608.py fix(auxiliary): honor /anthropic-suffixed gateway base_url on aux + fallback calls 2026-08-13 11:41:59 -07:00
test_auxiliary_client_bootstrap_skew.py
test_auxiliary_client_proxy_env.py
test_auxiliary_client_resolve_dedup.py
test_auxiliary_client_ssl_verify.py
test_auxiliary_client_xai_oauth_recovery.py
test_auxiliary_compression_timeout_floor.py
test_auxiliary_concurrency.py
test_auxiliary_config_bridge.py
test_auxiliary_explicit_base_anthropic.py test(agent): align explicit-base auxiliary tests with host-anchored rewrite policy 2026-08-13 11:45:27 -07:00
test_auxiliary_explicit_cancellation.py
test_auxiliary_main_first.py
test_auxiliary_named_custom_providers.py
test_auxiliary_relay.py
test_auxiliary_runtime_cache_key.py
test_auxiliary_transient_retry.py
test_auxiliary_transport_autodetect.py
test_auxiliary_user_default_headers.py
test_azure_identity_adapter.py
test_backend_identity.py
test_battery.py
test_bedrock_1m_context.py
test_bedrock_adapter.py
test_bedrock_empty_text_blocks.py
test_bedrock_integration.py
test_bedrock_interrupt_post_worker.py
test_billing_links.py
test_billing_usage.py
test_billing_view.py
test_bounded_response.py
test_budget_reasoning_details_exclusion.py
test_cache_disabled_on_stubs.py
test_canon_args_memo_parity.py
test_cascading_interrupt_6600.py
test_chat_completion_helpers_provider_sort.py
test_cjk_token_estimation.py
test_close_interrupted_tool_sequence.py
test_codex_app_server_event_bridge.py
test_codex_app_server_persist.py
test_codex_cloudflare_headers.py
test_codex_gpt55_autoraise_notice.py
test_codex_request_transport_diagnostics.py
test_codex_responses_adapter.py
test_codex_runtime_live_events.py
test_codex_ttfb_watchdog.py
test_coding_context.py
test_compaction_anti_thrash.py
test_compaction_redaction_boundaries.py
test_compress_context_progress_timeout.py
test_compress_focus.py
test_compress_signal_leak.py
test_compressed_summary_metadata.py
test_compression_adoption_preserves_live_tail.py
test_compression_anti_thrash_persistence.py
test_compression_anti_thrash_recovery.py
test_compression_attempt_telemetry.py
test_compression_concurrent_fork.py
test_compression_count_warning_36908.py
test_compression_fallback_budget.py
test_compression_interrupt_protection.py
test_compression_logging_session_context.py
test_compression_max_attempts_config.py
test_compression_orphan_recovery.py
test_compression_progress.py
test_compression_review_76354.py
test_compression_rotation_state.py
test_compression_small_ctx_threshold_floor.py
test_compression_worker_isolation_76354.py
test_compressor_actionable_tail_anchor.py
test_compressor_assistant_tail_anchor.py
test_compressor_historical_media.py
test_compressor_image_tokens.py
test_compressor_media_stripping.py
test_compressor_tail_cut_oob_fix.py
test_compressor_tail_cut_tool_pair_floor.py
test_compressor_tool_call_budget.py
test_compressor_zero_user_guard.py
test_context_breakdown.py
test_context_compressor.py
test_context_compressor_cross_session_guard.py
test_context_compressor_session_end_clears_state.py
test_context_compressor_summary_continuity.py
test_context_compressor_temporal_anchoring.py
test_context_compressor_zero_user_provenance.py
test_context_engine.py
test_context_engine_host_contract.py
test_context_engine_on_turn_complete_usage.py
test_context_engine_select_context.py
test_context_references.py
test_context_refs_concurrent.py
test_context_route_mismatch.py
test_copilot_acp_client.py
test_copilot_acp_deprecation.py
test_credential_pool.py
test_credential_pool_deferred_refresh.py
test_credential_pool_key_rotation.py
test_credential_pool_lease_refresh_reselect.py
test_credential_pool_no_entries_log_throttle.py
test_credential_pool_oat_authtype.py
test_credential_pool_oauth_writethrough.py
test_credential_pool_provider_boundary.py
test_credential_pool_quarantine_locking.py
test_credential_pool_routing.py
test_credential_pool_sole_cooldown.py
test_credential_pool_unmatched_rotation_bound.py
test_credits_cold_start.py
test_credits_fixture_snapshot.py
test_credits_policy.py
test_credits_tracker.py
test_credits_view.py
test_cron_inline_api_call_62151.py
test_crossloop_client_cache.py
test_curator.py
test_curator_activity.py
test_curator_backup.py
test_curator_classification.py
test_curator_reports.py
test_cursor_optimizations_parity.py
test_custom_pool_mismatch_guard.py
test_custom_provider_extra_body.py
test_custom_provider_extra_body_matching.py
test_custom_providers_vision.py
test_deepseek_anthropic_thinking.py
test_direct_provider_url_detection.py
test_display.py
test_display_emoji.py
test_display_todo_progress.py
test_display_tool_failure.py
test_empty_tool_name_loop_dampening.py
test_endpoint_blackhole.py
test_engine_preflight_wire.py
test_error_classifier.py
test_external_skills.py
test_external_skills_dirs_cache.py
test_failover_identity.py fix: restore empty-response fallback retry, dedupe alibaba set, thread TTL into aux replan 2026-08-13 15:24:47 +05:30
test_file_safety.py
test_file_safety_container_mirror.py
test_file_safety_credentials.py
test_file_safety_cross_profile.py
test_file_safety_sandbox_mirror.py
test_file_safety_session_state.py
test_gateway_turn_sidecar.py
test_gemini_fast_fallback.py
test_gemini_free_tier_gate.py
test_gemini_native_adapter.py
test_gemini_schema.py
test_gemini_standard_key_guidance.py
test_ghost_skill_pruning.py
test_i18n.py
test_idle_compaction.py
test_idle_compaction_lock_and_guards.py
test_image_gen_registry.py
test_image_routing.py
test_insights.py refactor(usage): simplify-pass follow-ups 2026-08-14 02:04:24 +05:30
test_intent_ack_continuation.py
test_interrupt_compat.py
test_jiter_preload.py
test_kanban_stop.py
test_kimi_coding_anthropic_thinking.py
test_last_total_tokens.py
test_learn_prompt.py
test_learning_graph.py
test_learning_graph_render.py
test_learning_mutations.py
test_lmstudio_reasoning.py
test_local_probe_disk_cache.py
test_local_stream_timeout.py
test_manual_compression_feedback.py
test_markdown_tables.py
test_memory_async_sync.py
test_memory_boundary_commit.py
test_memory_provider.py fix: support packaged memory provider skills 2026-08-13 11:49:14 -07:00
test_memory_provider_unavailable_warning.py feat(hindsight): memory provider improvements — recall_sync, retain_source, setup templates, memory indicators, error hints 2026-08-13 23:15:25 +05:30
test_memory_recall_indicator.py fix: security + efficiency review fixes for salvaged PR #74379 2026-08-13 23:15:25 +05:30
test_memory_session_switch.py
test_memory_skill_scaffolding.py
test_memory_user_id.py
test_memory_write_bridge.py
test_message_content.py
test_message_sanitization_policy.py
test_micro_compaction.py
test_minimax_auxiliary_url.py fix(auxiliary): keep ZAI Coding Plan routing 2026-08-13 12:30:29 -07:00
test_minimax_provider.py
test_moa_aggregator_cache_control.py
test_moa_aggregator_cost_slot.py
test_moa_cold_start_cache_66793.py
test_moa_context_max_tokens.py
test_moa_observability_bridge.py feat(langfuse): widen tracing to errors, sessions, subagents, and MoA fan-out 2026-08-13 23:10:16 +05:30
test_moa_progress.py
test_moa_quiet_reference_output.py
test_moa_reasoning_effort.py
test_moa_reference_system_prompt.py
test_moa_slot_api_mode.py fix(agent): propagate prompt-cache TTL to MoA/aux, clamp Qwen 1h, re-preflight on failover (#84733) 2026-08-13 15:24:47 +05:30
test_moa_slot_max_tokens.py fix(agent): propagate prompt-cache TTL to MoA/aux, clamp Qwen 1h, re-preflight on failover (#84733) 2026-08-13 15:24:47 +05:30
test_moa_switch_api_mode.py
test_moa_trace_streamed_capture.py
test_model_extra_type_guard.py
test_model_metadata.py fix(agent): reject stale 32k metadata for MiniMax 2026-08-13 11:12:05 -07:00
test_model_metadata_local_ctx.py
test_model_metadata_ssl.py
test_models_dev.py refactor(models): simplify-pass follow-ups on the refresh path 2026-08-14 03:31:22 +05:30
test_models_dev_meta_mapping.py
test_moonshot_schema.py
test_non_stream_stale_timeout.py
test_none_deref_guards.py
test_nous_credits_gauge.py
test_nous_credits_snapshot.py
test_nous_oauth_401_guidance.py
test_nous_portal_anthropic_wire.py
test_nous_rate_guard.py
test_onboarding.py
test_oneshot.py
test_openrouter_response_cache.py
test_org_skill_namespace.py
test_outbound_webhooks.py
test_pet_engine.py
test_pet_generate.py
test_platform_hint_desktop.py
test_platform_hint_overrides.py
test_plugin_context_references.py
test_plugin_llm.py
test_plugin_llm_task_routing.py
test_plugin_prompt_sections.py
test_portal_tags.py
test_post_compression_trim.py
test_pre_compress_memory_context.py
test_preflight_compression_gate.py
test_preflight_lock_defer.py
test_proactive_prune_config.py
test_proactive_prune_restart_safety.py
test_proactive_tool_result_pruning.py
test_probe_cache_followups.py
test_prompt_builder.py
test_prompt_cache_boundary.py
test_prompt_cache_ttl_propagation.py refactor: hoist preflight clear into restart handler, single-source qwen predicate 2026-08-13 15:24:47 +05:30
test_prompt_caching.py fix(agent): propagate prompt-cache TTL to MoA/aux, clamp Qwen 1h, re-preflight on failover (#84733) 2026-08-13 15:24:47 +05:30
test_protected_tail_pressure_61932.py
test_proxy_and_url_validation.py
test_pydantic_dump_warning_leak.py
test_rate_limit_tracker.py
test_reactions.py
test_reasoning_stale_timeout_floor.py
test_reasoning_summaries.py
test_redact.py
test_reference_handoff_active_turn.py
test_refine_focus.py
test_relay_llm.py
test_relay_nested_execution.py
test_relay_runtime_bounded_scope_ops.py
test_relay_session_segments.py fix(relay): defer rotating-compaction session close while a turn is live 2026-08-13 10:45:15 -07:00
test_relay_tools.py
test_replay_budget_accounting.py
test_replay_cleanup.py
test_request_client_reuse.py
test_restore_primary_pool_reselect.py
test_resume_stale_active_task.py
test_rotation_flush_persisted_boundary_68196.py
test_runtime_cwd.py
test_save_url_image.py
test_secret_scope.py
test_secret_scope_tier1_migration.py
test_send_path_history_isolation.py
test_session_activity.py
test_session_rotation_flush_cold_resume_68454.py
test_set_runtime_main_custom_provider.py
test_shell_hooks.py feat(plugins): rename hook to transform_api_error_classification per #64231 verdict 2026-08-13 09:36:02 -07:00
test_shell_hooks_consent.py
test_shell_hooks_tree_kill.py
test_skill_bundles.py
test_skill_commands.py
test_skill_commands_reload.py
test_skill_invocation_description.py
test_skill_utils.py
test_skip_background_review.py
test_skip_memory_store_65429.py
test_ssl_ca_guard.py
test_ssl_verify.py
test_stale_replay_prune.py
test_stream_chunk_byte_estimate.py
test_stream_read_timeout_floor.py
test_stream_single_writer_guard.py
test_streaming_context_scrubber.py
test_subagent_lifecycle.py
test_subagent_progress.py
test_subagent_stop_hook.py
test_subdirectory_hints.py
test_subdirectory_hints_tilde.py
test_subprocess_env_guard.py
test_subscription_view.py
test_summarize_tool_result_type_safety.py
test_summary_prefix_semantics.py
test_summary_prefix_tool_use.py
test_summary_role_template_alternation.py
test_surrogate_chokepoints.py
test_synthetic_turn_display_kind.py
test_system_prompt.py
test_system_prompt_restore.py
test_think_scrubber.py
test_thinking_timeout_guidance.py
test_thread_scoped_output.py
test_title_generator.py
test_tool_call_arg_no_redaction.py
test_tool_dispatch_helpers.py
test_tool_executor_checkpoint_paths.py
test_tool_guardrails.py
test_tool_result_classification.py
test_trace_upload.py
test_transcription_registry.py
test_tts_registry.py
test_turn_context.py feat(hindsight): memory provider improvements — recall_sync, retain_source, setup templates, memory indicators, error hints 2026-08-13 23:15:25 +05:30
test_turn_context_overflow_warning.py
test_turn_finalizer_cleanup_guard.py
test_turn_finalizer_final_response_persistence.py
test_turn_finalizer_interrupt_alternation.py
test_turn_finalizer_iteration_limit_exit.py
test_turn_overlap_tripwire.py
test_turn_retry_state.py
test_turn_summary.py
test_unsupported_parameter_retry.py
test_unsupported_temperature_retry.py
test_usage_pricing.py refactor(usage): simplify-pass follow-ups 2026-08-14 02:04:24 +05:30
test_verification_evidence.py
test_verification_evidence_fd_leak.py
test_verification_stop.py
test_verification_stop_caching.py
test_verify_hooks.py
test_vertex_adapter.py
test_video_gen_registry.py
test_vision_resolved_args.py
test_vision_routing_31179.py