AgentSessionManager.Config (AgentSessionManager v0.8.0)

Copy Markdown View Source

Centralized configuration with process-local overrides.

Every operational default in AgentSessionManager — timeouts, buffer sizes, concurrency limits, query limits, and more — is defined here as a single source of truth. Individual modules reference get/1 instead of scattering @default_* module attributes.

Resolution Order

When you call get/1, the value is resolved as follows:

  1. Process-local override — set via put/2, scoped to the calling process. Automatically cleaned up when the process exits.
  2. Application environment — set via config :agent_session_manager, key: value or Application.put_env/3.
  3. Built-in default — hardcoded fallback per key.

This layering follows the same pattern as Elixir's Logger module for per-process log levels. It enables fully concurrent (async: true) testing because each test process can override configuration without affecting any other process.

Application Config Example

# config/config.exs
config :agent_session_manager,
  command_timeout_ms: 60_000,
  max_parallel_sessions: 200

See the Configuration Reference guide for the full list of keys, types, and defaults.

Supported Keys

Feature Flags

KeyTypeDefaultUsed By
:telemetry_enabledbooleantrueTelemetry
:audit_logging_enabledbooleantrueAuditLogger
:redaction_enabledbooleanfalseEventBuilder

Redaction

KeyTypeDefaultUsed By
:redaction_patterns`:defaultlist`:defaultEventBuilder
:redaction_replacement`String.t():categorized`"[REDACTED]"EventBuilder
:redaction_deep_scanbooleantrueEventBuilder
:redaction_scan_metadatabooleanfalseEventBuilder

Timeouts (milliseconds)

KeyDefaultUsed By
:stream_idle_timeout_ms120_000StreamSession
:task_shutdown_timeout_ms5_000StreamSession
:await_run_timeout_ms60_000SessionServer
:drain_timeout_buffer_ms1_000SessionServer.drain/2
:command_timeout_ms30_000Exec, ShellAdapter
:execute_timeout_ms60_000ProviderAdapter
:execute_grace_timeout_ms5_000ProviderAdapter
:circuit_breaker_cooldown_ms30_000CircuitBreaker, Router
:sticky_session_ttl_ms300_000ProviderRouter
:event_stream_poll_interval_ms250SessionManager
:genserver_call_timeout_ms5_000ProviderAdapter, SessionStore

Buffer & Memory Limits

KeyDefaultUsed By
:event_buffer_size1_000EventStream
:max_output_bytes1_048_576Exec, ShellAdapter
:max_patch_bytes1_048_576GitBackend

Concurrency

KeyDefaultUsed By
:max_parallel_sessions100ConcurrencyLimiter
:max_parallel_runs50ConcurrencyLimiter
:max_queued_runs100SessionServer, RunQueue

Circuit Breaker

KeyDefaultUsed By
:circuit_breaker_failure_threshold5CircuitBreaker
:circuit_breaker_half_open_max_probes1CircuitBreaker

SQLite

KeyDefaultUsed By
:sqlite_max_bind_params32_766EctoSessionStore
:sqlite_busy_retry_attempts25EctoSessionStore
:sqlite_busy_retry_sleep_ms10EctoSessionStore

Query Limits

KeyDefaultUsed By
:max_query_limit1_000EctoQueryAPI
:default_session_query_limit50EctoQueryAPI, AshQueryAPI
:default_run_query_limit50EctoQueryAPI, AshQueryAPI
:default_event_query_limit100EctoQueryAPI, AshQueryAPI, SessionManager

Retention

KeyDefault
:retention_max_completed_age_days90
:retention_hard_delete_after_days30
:retention_batch_size100
:retention_exempt_statuses[:active, :paused]
:retention_exempt_tags["pinned"]
:retention_prune_event_types_first[:message_streamed, :token_usage_updated]

Cost

KeyDefaultUsed By
:chars_per_token4TranscriptBuilder

Shell Adapter

KeyDefaultUsed By
:default_shell"/bin/sh"ShellAdapter
:default_success_exit_codes[0]ShellAdapter

Workspace

KeyDefaultUsed By
:excluded_workspace_roots[".git", "deps", "_build", "node_modules"]HashBackend

Routing

KeyDefaultUsed By
:default_router_name"router"ProviderRouter

Summary

Types

Configuration keys supported by this module.

Functions

Returns the built-in default for key, ignoring process-local and application environment overrides.

Removes the process-local override for key.

Returns the resolved value for key.

Sets a process-local override for key.

Returns the list of valid configuration keys.

Types

key()

@type key() ::
  :telemetry_enabled
  | :audit_logging_enabled
  | :redaction_enabled
  | :redaction_patterns
  | :redaction_replacement
  | :redaction_deep_scan
  | :redaction_scan_metadata
  | :stream_idle_timeout_ms
  | :task_shutdown_timeout_ms
  | :await_run_timeout_ms
  | :drain_timeout_buffer_ms
  | :command_timeout_ms
  | :execute_timeout_ms
  | :execute_grace_timeout_ms
  | :circuit_breaker_cooldown_ms
  | :sticky_session_ttl_ms
  | :event_stream_poll_interval_ms
  | :genserver_call_timeout_ms
  | :event_buffer_size
  | :max_output_bytes
  | :max_patch_bytes
  | :error_text_max_bytes
  | :error_text_max_lines
  | :max_parallel_sessions
  | :max_parallel_runs
  | :max_queued_runs
  | :circuit_breaker_failure_threshold
  | :circuit_breaker_half_open_max_probes
  | :sqlite_max_bind_params
  | :sqlite_busy_retry_attempts
  | :sqlite_busy_retry_sleep_ms
  | :max_query_limit
  | :default_session_query_limit
  | :default_run_query_limit
  | :default_event_query_limit
  | :retention_max_completed_age_days
  | :retention_hard_delete_after_days
  | :retention_batch_size
  | :retention_exempt_statuses
  | :retention_exempt_tags
  | :retention_prune_event_types_first
  | :chars_per_token
  | :default_shell
  | :default_success_exit_codes
  | :excluded_workspace_roots
  | :default_router_name

Configuration keys supported by this module.

Functions

default(atom)

@spec default(key()) :: term()

Returns the built-in default for key, ignoring process-local and application environment overrides.

delete(key)

@spec delete(key()) :: :ok

Removes the process-local override for key.

After deletion, get/1 falls back to Application environment or the built-in default.

get(key)

@spec get(key()) :: term()

Returns the resolved value for key.

Checks the process dictionary first, then Application environment, then falls back to the built-in default.

put(key, value)

@spec put(key(), term()) :: :ok

Sets a process-local override for key.

This override is visible only to the calling process and is automatically cleaned up when the process exits. It takes priority over Application environment and built-in defaults.

valid_keys()

@spec valid_keys() :: [key()]

Returns the list of valid configuration keys.