- Removed legacy agent profile settings from the .env.example and README, streamlining the configuration process. - Introduced a new local YAML configuration adapter for assistant settings, allowing for easier management of assistant profiles. - Updated backend integration documentation to clarify the behavior of assistant config sourcing based on backend URL settings. - Adjusted various service implementations to directly utilize API keys from the new configuration structure. - Enhanced test coverage for the new local YAML adapter and its integration with backend services.
1.7 KiB
1.7 KiB
Backend Integration and History Bridge
This engine uses adapter-based backend integration so core runtime logic can run with or without an external backend service.
Runtime Modes
Configure with environment variables:
BACKEND_MODE=auto|http|disabledBACKEND_URLBACKEND_TIMEOUT_SECASSISTANT_LOCAL_CONFIG_DIR(default:engine/config/agents)HISTORY_ENABLED=true|false
Mode behavior:
auto: use HTTP backend adapter only whenBACKEND_URLis set.http: force HTTP backend adapter (falls back to null adapter when URL is missing).disabled: force null adapter and run engine-only.
Assistant config source behavior:
- If
BACKEND_URLexists and backend mode is enabled, fetch assistant config from backend. - If
BACKEND_URLis missing (or backend mode is disabled), load assistant config from local YAML. assistant_idquery parameter is still required and maps toengine/config/agents/<assistant_id>.yamlwhen local YAML source is active.
Architecture
- Ports:
core/ports/backend.py - Adapters:
app/backend_adapters.py - Compatibility wrappers:
app/backend_client.py
Session and DuplexPipeline receive backend capabilities via injected adapter
methods instead of hard-coding backend client imports.
Async History Writes
Session history persistence is handled by core/history_bridge.py.
Design:
- transcript writes are queued with
put_nowait(non-blocking turn path) - background worker drains queue
- failed writes retry with exponential backoff
- finalize waits briefly for queue drain before sending call finalize
- finalize is idempotent
Related settings:
HISTORY_QUEUE_MAX_SIZEHISTORY_RETRY_MAX_ATTEMPTSHISTORY_RETRY_BACKOFF_SECHISTORY_FINALIZE_DRAIN_TIMEOUT_SEC