clarion-app / llm-client
Handles interactions with Large Language Models
Requires
- clarion-app/backend: dev-main
- clarion-app/eloquent-multichain-bridge: dev-main
- clarion-app/http-queue: dev-main
- justinrainbow/json-schema: ^6.0
- php-webdriver/webdriver: dev-main
- symfony/process: ^7.0
- symfony/yaml: ^7.0.3
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- dev-129-speckit-verify-acceptance
- dev-128-project-command-indexing
- dev-127-command-packs
- dev-126-git-operations-confirmation
- dev-125-language-runtime-execution
- dev-124-command-limit-controls
- dev-123-sandboxed-shell-execution
- dev-122-workspace-browser-ui
- dev-121-workspace-boundary-hardening
- dev-120-workspace-file-tools
- dev-119-mcp-server-management-ui
- dev-118-external-tool-search-indexing
- dev-117-external-tool-safety-parity
- dev-116-mcp-client-support
- dev-115-agent-scaffold-templates
- dev-114-scheduler-agent
- dev-113-data-agent
- dev-112-coding-agent
- dev-111-research-agent
- dev-110-delegation-deadlock-timeout
- dev-109-agent-as-capability
- dev-108-shared-task-workspace
- dev-107-agent-message-protocol
- dev-106-multi-agent-run-view
- dev-105-stage-pipeline
- dev-104-multi-agent-consensus
- dev-103-manager-agent
- dev-102-router-pattern
- dev-101-parallel-subagent-execution
- dev-100-subagent-tool-restrictions
- dev-099-result-aggregation
- dev-088-agent-definition-validator
- dev-087-agent-model-versioning
- dev-086-agent-yaml-schema
- dev-085-graceful-degradation
- dev-084-predictive-cost-quota
- dev-083-per-conversation-rate-limit
- dev-082-per-user-rate-limit
- dev-081-eval-dashboard
- dev-080-eval-regression-detection
- dev-079-llm-judge-rubrics
- dev-078-run-eval-suites
- dev-077-agent-eval-suites
- dev-076-cost-budget-quotas
- dev-075-tool-reliability-rates
- dev-074-latency-metrics
- dev-073-usage-cost-rollups
- dev-072-usage-cache-agent-attribution
- dev-071-trace-export-retention
- dev-070-run-execution-graph
- dev-069-trace-id-propagation
This package is auto-updated.
Last update: 2026-08-20 12:50:32 UTC
README
Memory Scopes
The package provides four memory scopes for agents:
| Scope | Table | Retention | Eviction | Entry Cap |
|---|---|---|---|---|
| Scratch | — | Cleared per turn | N/A | N/A |
| Short-term | — | Cleared on conversation end | N/A | N/A |
| Long-term | llm_memory_entries |
Permanent | LRU eviction | Configurable cap |
| Episodic | episodic_memories |
Configurable (retention_days) |
Time-based cleanup | None |
| Declarative | declarative_memories |
Permanent | None | None |
Declarative Memory (Permanent Facts, Preferences, Rules)
The declarative scope stores explicit user-created facts, preferences, and behavioral rules that must be reliably available in every conversation. Unlike long-term (LRU-evicted) and episodic (time-expiring) scopes, declarative entries are permanent by design:
- No retention config — no
retention_days, no expiration - No eviction — no LRU, no cleanup command, no scheduled task
- No entry cap — deliberately unbounded (user-managed, expected to stay small)
- Strict per-user scoping — no cross-user access, no admin override
- Confirmation gate — agent-sourced writes require explicit user confirmation before persistence
- Semantic conflict detection — reworded restatements supersede existing entries in place
- Immediate edit/delete — edits and deletes take effect in the same and all later conversations
Entries record a type (fact | preference | rule) and source (provenance: user_stated | agent_learned).
Learned Patterns and Confidence
The store holds both user-stated entries and patterns learned on the user's behalf, in a single table (no parallel model). A learned pattern (source = agent_learned) carries a confidence_level — a nullable integer from 0 to 100 reflecting how much consistent evidence supports it:
confidence_levelisNULLfor user-stated entries and set to 0–100 for learned patterns. Values outside 0–100 are rejected at the service layer.- User-stated always wins — when a learned pattern semantically conflicts with a user-stated entry, the user-stated entry is never superseded. A higher-confidence learned pattern may supersede an older learned pattern; a lower-confidence one does not.
- Editing a learned entry converts it to
source = user_statedand clearsconfidence_leveltoNULL. - Confidence is visible everywhere — surfaced on recall, in every API response, and carried in the
ConfirmationRequiredExceptionpayload so the confirmation prompt can show it.
applyAgentWrite() accepts an optional $confidenceLevel parameter; the confirmation gate still throws before any DB access when the write is not confirmed.
See specs/041-declarative-memory-store/quickstart.md for base API usage and specs/046-learned-patterns-store/quickstart.md for learned-pattern behavior verification.
Testing
Test Suites
The package maintains three test suites:
- Unit — Fast unit tests for individual classes.
- Feature — Feature-level tests with mocked dependencies.
- Integration — Assembled-system tests that exercise the full stack (container-resolved services, real database, scripted HTTP boundary) without mocks on
llm-clientclasses.
Running Tests
# All suites composer test # Specific suite ./vendor/bin/phpunit --testsuite Integration # Single test file ./vendor/bin/phpunit tests/Integration/ToolUseJourneyTest.php
Integration Suite
The Integration suite verifies end-to-end behavior through the container-wired composition chain. One rule: no mocks on llm-client classes — the suite exercises real services through a scripted HTTP boundary. This catches wiring defects, missing service registrations, and integration failures that unit tests with mocks cannot detect.