hermes-agent/tests/run_agent
ethernet a4bc1ca502
fix(timeline): persist typed display events (#69771)
* fix(desktop): hide persisted agent-only history scaffolding

Filter verification-stop nudges and context-compaction handoffs at the
stored-history mapper boundary. Preserve a real reply when a compaction
handoff shares its stored message.

* test(desktop): build persisted E2E sessions through the real agent

Drive tui_gateway.entry over its stdio JSON-RPC transport against the mock
provider, wait for real completion events, and persist normal session history
through AIAgent and SessionDB. Migrate resume and hidden-history coverage,
including real compression and live verify-on-stop scaffolding, then remove
the unused direct SessionDB import scripts.

* fix(desktop): use the provisioned Python for real-session E2Es

Run the stdio gateway through uv's synced project environment outside the
Nix dev shell, while retaining the fully provisioned Nix Python when the
shell advertises HERMES_PYTHON_SRC_ROOT.

* fix(nix): expose the provisioned Python environment to uv

Mark the Nix-built Python environment active in the dev shell so the shared
E2E session builder can always run through `uv run --active --no-sync`.

* fix(timeline): persist typed display events

* fix(timeline): strip display-only fields from provider payloads, preserve through rewrites, fix /resume display history

Three review findings from PR #69771:

1. Provider payload leak: display_kind and display_metadata were forwarded
   to the provider API as unknown message fields. Strict OpenAI-compatible
   backends can reject the next request after a model switch or resumed
   typed event. Strip both from the per-request api_msg copy in
   conversation_loop alongside the existing api_content pop.

2. Rewrite/import data loss: _insert_message_rows preserved display_kind
   but silently dropped display_metadata. After replace_messages,
   archive_and_compact, or session import, async-delegation completion
   events lost their task counts and fell back to generic display text.
   Add display_metadata to the INSERT columns and bind tuple.

3. CLI /resume stale recap: startup --resume A set _resume_display_history
   from A's lineage. A subsequent in-session /resume B loaded B only into
   conversation_history via get_messages_as_conversation, leaving the stale
   A display projection. _display_resumed_history preferentially read the
   stale attribute, showing A's recap for B. Switch /resume to
   get_resume_conversations and update _resume_display_history alongside
   conversation_history.

Tests: 890 Python (5 files), 35 desktop TS — all green.

* feat(tui): render typed display events as ◈ markers in the Ink TUI

The TUI was not handling display_kind at all — model switch markers and
async delegation completions rendered as opaque user messages with the
full [System: ...] text, and hidden compaction handoffs were visible.

Wire display_kind through the full TUI chain:

- _history_to_messages (tui_gateway/server.py) forwards display_kind
  and display_metadata to the gateway transcript payload.
- GatewayTranscriptMessage (gatewayTypes.ts) gains both fields.
- Msg.kind (types.ts) gains 'event' value.
- toTranscriptMessages (domain/messages.ts) maps:
  - hidden → skip entirely
  - model_switch → event "model changed"
  - async_delegation_complete → event "N background agents finished"
    (or "background agent work finished" without metadata)
- messageGroup (blockLayout.ts) routes event to its own group, with
  SELF_SPACED + PAINTS_TRAILING_GAP so it owns its margins.
- messageLine.tsx renders event-kind as a dim ◈ marker with no gutter,
  matching the CLI's ◈ event rendering.
- 4 new TUI tests for hidden/model_switch/async_delegation mapping.

TUI typecheck: clean. TUI lint: 0 errors (2 pre-existing warnings).
TUI tests: 9 passed (1 pre-existing failure on main, unrelated).
2026-07-23 14:46:24 -04:00
..
__init__.py
…
conftest.py
…
repro_48013_image_shrink_brick.py
…
test_413_compression.py fix(context-engine): route pre-API and idle compaction status through the quiet-engine resolver 2026-07-23 07:26:15 -07:00
test_860_dedup.py
…
test_1630_context_overflow_loop.py
…
test_18028_content_policy_blocked.py
…
test_24996_fallback_exhaustion_cooldown.py
…
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
…
test_32646_fallback_429_after_timeout.py
…
test_63425_credential_pool_auto_detect.py
…
test_66267_multimodal_interim.py fix: normalize multimodal list content in build_assistant_message (#66267) 2026-07-18 19:39:07 +05:30
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
…
test_async_httpx_del_neuter.py
…
test_auth_provider_failover.py
…
test_background_review.py
…
test_background_review_cache_parity.py
…
test_background_review_cost_controls.py
…
test_background_review_summary.py
…
test_background_review_toolset_restriction.py
…
test_callable_api_key.py
…
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
…
test_codex_multimodal_tool_result.py
…
test_codex_no_tools_nonetype.py
…
test_codex_silent_hang_hint.py
…
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
…
test_compress_focus_plugin_fallback.py
…
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
…
test_compression_boundary_hook.py fix(compression): notify context engine after commit 2026-07-22 06:58:16 -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_persistence.py test(compression): verify abort persistence after restart 2026-07-23 07:25:21 -07:00
test_compression_trigger_excludes_reasoning.py
…
test_compressor_fallback_update.py
…
test_concurrent_interrupt.py
…
test_context_token_tracking.py
…
test_conversation_fallback_state.py
…
test_copilot_native_vision_headers.py
…
test_create_openai_client_disables_sdk_retries.py
…
test_create_openai_client_kwargs_isolation.py
…
test_create_openai_client_proxy_env.py
…
test_create_openai_client_reuse.py
…
test_create_openai_client_ssl_verify.py
…
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
…
test_custom_provider_extra_headers_client.py
…
test_deepseek_reasoning_content_echo.py
…
test_deepseek_v4_thinking_live.py
…
test_dict_tool_call_args.py
…
test_empty_response_recovery_persistence.py
…
test_exit_cleanup_interrupt.py
…
test_fallback_credential_isolation.py
…
test_fallback_reasoning_override.py
…
test_file_mutation_verifier.py
…
test_fireworks_live.py
…
test_identity_flush.py
…
test_image_rejection_fallback.py
…
test_image_shrink_recovery.py
…
test_in_place_compaction.py test: assert durable compression rotation 2026-07-19 08:55:08 +05:30
test_infinite_compaction_loop.py
…
test_init_fallback_on_exhausted_pool.py
…
test_interactive_interrupt.py
…
test_interrupt_propagation.py
…
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
…
test_jsondecodeerror_retryable.py
…
test_last_reasoning_per_turn.py
…
test_lmstudio_load_mode.py
…
test_long_context_tier_429.py
…
test_malformed_tool_arguments.py
…
test_materialize_data_url_cleanup.py
…
test_memory_nudge_counter_hydration.py
…
test_memory_provider_init.py
…
test_memory_sync_interrupted.py
…
test_message_sequence_repair.py
…
test_moa_loop_mode.py fix(moa): measure advisor guidance before compression 2026-07-22 06:57:54 -07:00
test_moa_streaming.py
…
test_multimodal_tool_content_recovery.py
…
test_nonretryable_error_html_summary.py
…
test_notice_spine.py
…
test_nous_429_fallback_reentry.py
…
test_nous_fallback_unavailable.py
…
test_openai_client_lifecycle.py
…
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
…
test_plugin_context_engine_init.py
…
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
…
test_provider_attribution_headers.py
…
test_provider_fallback.py
…
test_provider_parity.py
…
test_real_interrupt_subagent.py
…
test_redirect_stdout_issue.py
…
test_repair_tool_call_arguments.py
…
test_repair_tool_call_name.py
…
test_retry_status_buffer.py
…
test_review_prompt_class_first.py
…
test_run_agent.py fix(credential-pool): refresh the failing entry, not current(), on auth recovery 2026-07-23 07:33:25 -07:00
test_run_agent_codex_responses.py fix(desktop, ink): don't wipe messages before final message (#65919) 2026-07-20 11:42:29 -04:00
test_run_agent_multimodal_prologue.py
…
test_sequential_chats_live.py
…
test_session_id_env.py
…
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
…
test_session_source.py
…
test_steer.py feat(agent): add active-turn redirect core primitive 2026-07-22 12:02:40 -05:00
test_stream_drop_logging.py
…
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
…
test_stream_stale_breaker_reset.py
…
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): request-local Anthropic clients so the stale/interrupt watchdog never corrupts SQLite (#67142) 2026-07-18 21:20:48 -04:00
test_streaming_tool_call_repair.py
…
test_strict_api_validation.py
…
test_strip_reasoning_tags_cli.py
…
test_summarize_api_error.py
…
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
…
test_switch_model_pool_reload_52727.py
…
test_switch_model_reapplies_headers.py
…
test_switch_model_reasoning_override.py
…
test_switch_model_rollback.py
…
test_switch_model_stale_base_url.py
…
test_thinking_only_sanitizer.py
…
test_thinking_sig_recovery_persistence.py
…
test_tls_fd_recycle_corruption.py
…
test_token_persistence_non_cli.py
…
test_tool_arg_coercion.py
…
test_tool_batch_segmentation.py
…
test_tool_call_args_sanitizer.py
…
test_tool_call_guardrail_runtime.py
…
test_tool_call_incremental_persistence.py
…
test_tool_executor_contextvar_propagation.py
…
test_tool_name_db_persistence.py
…
test_turn_completion_explainer.py
…
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
…
test_vision_tool_messages.py
…
test_wait_state_visibility.py
…