Deferred and optional features that can be implemented for the resource control subsystem. The current system is production-ready without these; they are enhancements for specific use cases.
Status: Deferred
Description:
Automatic expiry of Redis keys (afw:res:*, afw:circuit:*) after a configurable time-to-live. Keys would be removed by Redis when they are idle for longer than the TTL, reducing manual cleanup for long-lived deployments.
Current workaround:
Use cleanup_orphan_keys() after policy removal or renames. Call remove_resource_policy_and_sync() when removing policies.
Implementation outline:
- Add
ttl_seconds: float | None = NonetoResourcePolicy(None = no TTL) - In
_LUA_INIT_KEY, after HSETNX: ifttl_seconds > 0, callredis.call('EXPIRE', k, ttl_seconds) - On each
acquire/release/_lua_on_successetc., refresh TTL:redis.call('EXPIRE', k, ttl_seconds)so active keys do not expire - Circuit keys: same pattern in circuit Lua scripts
Files: resource_policy.py, resource_manager.py (Lua scripts, acquire/release paths)
Status: Not implemented
Description:
Support for Redis instances that require a password (and optionally a username). Useful for managed Redis (ElastiCache, Redis Cloud, etc.).
Implementation outline:
- Add
redis_password: str | None = None,redis_username: str | None = NonetoResourceManager.__init__andinit_resource_manager - Pass to
aioredis.ConnectionPoolviapasswordandusernamekwargs - Add
REDIS_PASSWORD,REDIS_USERNAMEenv var support inAgentFrameworkand worker - Include in
redis_configbroadcast to workers
Files: resource_manager.py, aframework/aframework.py, worker/worker.py
Status: Not implemented
Description:
Accept a single redis_url (e.g. redis://user:pass@host:6379/0) instead of separate host/port/db/password parameters. Simplifies configuration for cloud deployments.
Implementation outline:
- Add
redis_url: str | None = NonetoResourceManager.__init__ - If
redis_urlis set, useaioredis.from_url(redis_url)instead ofConnectionPool(host=..., port=..., ...) - Precedence:
redis_urlover host/port/db when both provided - Add
REDIS_URLenv var support
Files: resource_manager.py, aframework/aframework.py, worker/worker.py
Status: Not implemented
Description:
Resource keys containing double quotes (") or backslashes (\) can produce invalid Prometheus exposition format. The current PrometheusMetricsBackend does not escape these characters in label values.
Impact: Low. Resource keys are typically alphanumeric with colons (e.g. openai:gpt-4). Only affects deployments with unusual key names.
Implementation outline:
- In
PrometheusMetricsBackend.format_snapshot, escape label values per Prometheus text format:"→\",\→\\, newline →\n - Apply to
resourcelabel and any other user-provided labels
Files: engine/metrics_backend.py
Status: Reserved for future use
Description:
The MetricsBackend.format_snapshot signature includes queue_stats: dict[str, Any] | None = None, but it is not used. Intended for per-worker queue depth, backlog, etc.
Implementation outline:
- Define a standard shape for
queue_stats(e.g.{"worker_0": {"queue_depth": 5, "backlog": 10}, ...}) - Wire queue metrics from the dispatch/routing layer into
get_metrics_for_pull() - Extend
PrometheusMetricsBackendto emit queue-related metrics
Files: engine/metrics_backend.py, aframework/aframework.py, routing/dispatch code
Status: Not implemented
Description:
Allow different metrics backends per resource (e.g. Prometheus for openai, OpenTelemetry for mcp:browser). Useful when different teams own different resources and have different observability stacks.
Implementation outline:
- Add optional
metrics_backend: MetricsBackend | NonetoResourcePolicy - In
run_with_retry, when recording events, resolve backend: policy-specific or global - Requires
record_eventto be called per-key with the appropriate backend
Files: resource_policy.py, resource_manager.py
Status: Not implemented
Description:
Alternative to token bucket: a sliding-window rate limiter that enforces “at most N requests per window W”. Some APIs (e.g. OpenAI) use this model.
Implementation outline:
- Add
algorithm: "sliding_window"toResourcePolicy - New Lua script: maintain a sorted set or list of timestamps, trim old entries, check count before allowing
- More Redis operations per request than token bucket; consider trade-offs
Files: resource_policy.py, resource_manager.py (new Lua script, algo constant)
| # | Feature | Priority | Effort |
|---|---|---|---|
| 1 | TTL on Redis keys | Medium | Medium |
| 2 | Redis authentication | High* | Low |
| 3 | Redis URL support | Medium | Low |
| 4 | Prometheus label escaping | Low | Low |
| 5 | Queue stats in metrics | Low | Medium |
| 6 | Per-resource metrics | Low | Medium |
| 7 | Sliding window rate limit | Low | High |
* High if using managed Redis with auth; N/A if using local Redis without auth.