ADR-004: PSR-14 Event System
Status
Superseded by ADR-026 (2024-02, superseded 2026)
Note
The PSR-14 events described below (Before /
After) were never implemented and no longer reflect
the code — there is no Classes/Event/ directory and
Llm dispatches no events. The extension points this ADR
set out to provide (request modification, response processing, cost tracking,
rate limiting) are delivered instead by the provider middleware pipeline
(ADR-026): FallbackMiddleware, BudgetMiddleware,
UsageMiddleware and CacheMiddleware wrap every provider call. New
cross-cutting behaviour should be added as a middleware, not an event
listener. The original decision is kept below for historical context.
Context
Consumers need extension points for:
- Logging and monitoring.
- Request modification.
- Response processing.
- Cost tracking and rate limiting.
Decision
Use TYPO3's PSR-14 event system with events:
Before: Modify requests before sending.Request Event After: Process responses after receiving.Response Event
Events are dispatched by Llm and provide:
- Full context (messages, options, provider).
- Mutable options (before request).
- Response data (after response).
- Timing information.
Consequences
Positive:
- ●● Follows TYPO3 conventions.
- ●● Decoupled extension mechanism.
- ● Multiple listeners without modification.
- ● Testable event handlers.
Negative:
- ◑ Event overhead on every request.
- ◑ Listener ordering considerations.
- ◑ Debugging event flow complexity.
Net Score: +6.5 (Strong positive impact - standard TYPO3 integration with decoupled extensibility)