ContextService.analyze_context Crashes Without Explicit LLM #8235

Open
opened 2026-04-13 05:08:03 +00:00 by HAL9000 · 2 comments
Owner

Metadata

  • Commit Message: fix(application): provide default LLM for context analysis
  • Branch Name: bugfix/application-context-analysis-crash

Background and Context

The ContextService.analyze_context method in src/cleveragents/application/services/context_service.py is designed to work with an optional llm parameter. The documentation states that if no LLM is provided, a default mock LLM should be used.

Currently, when ContextService.analyze_context is called with llm=None (the default), it raises a ValueError: No LLM provider configured… because the underlying ContextAnalysisAgent requires an LLM. This is a contract violation — the method signature promises optional LLM support, but the implementation does not honour that promise.

Steps to Reproduce:

from cleveragents.application.services.context_service import ContextService
svc = ContextService.__new__(ContextService)          # bypass __init__ for brevity
svc._get_context_agent(llm=None)
# → ValueError: No LLM provider configured. Set provider credentials or enable core.mock_providers for testing.

Expected Behavior

ContextService.analyze_context should use a default mock LLM when no explicit LLM is provided, as stated in the documentation. The method should never raise ValueError solely because llm=None was passed — it should fall back gracefully to the configured mock provider.

Acceptance Criteria

  • ContextService.analyze_context no longer raises ValueError when called with llm=None.
  • A default mock LLM is automatically used when no explicit LLM is provided.
  • The fallback behaviour is consistent with the documentation and the method's type signature.
  • Existing tests continue to pass; new regression test added covering the llm=None path.
  • Test coverage remains >= 97%.

Subtasks

  • Investigate ContextService._get_context_agent to understand how llm=None propagates to ContextAnalysisAgent.
  • Implement fallback: when llm is None, resolve and inject the default mock LLM (respecting core.mock_providers config).
  • Add or update unit tests to cover the llm=None code path.
  • Verify no regression in existing ContextService tests.
  • Update inline docstring to explicitly document the fallback behaviour.

Definition of Done

This issue should be closed when:

  1. ContextService.analyze_context(llm=None) executes without raising ValueError.
  2. The default mock LLM is used transparently when no LLM is supplied.
  3. A regression test exists and passes for the llm=None scenario.
  4. All CI checks pass with coverage >= 97%.

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message:** `fix(application): provide default LLM for context analysis` - **Branch Name:** `bugfix/application-context-analysis-crash` ## Background and Context The `ContextService.analyze_context` method in `src/cleveragents/application/services/context_service.py` is designed to work with an optional `llm` parameter. The documentation states that if no LLM is provided, a default mock LLM should be used. Currently, when `ContextService.analyze_context` is called with `llm=None` (the default), it raises a `ValueError: No LLM provider configured…` because the underlying `ContextAnalysisAgent` requires an LLM. This is a contract violation — the method signature promises optional LLM support, but the implementation does not honour that promise. **Steps to Reproduce:** ```python from cleveragents.application.services.context_service import ContextService svc = ContextService.__new__(ContextService) # bypass __init__ for brevity svc._get_context_agent(llm=None) # → ValueError: No LLM provider configured. Set provider credentials or enable core.mock_providers for testing. ``` ## Expected Behavior `ContextService.analyze_context` should use a default mock LLM when no explicit LLM is provided, as stated in the documentation. The method should never raise `ValueError` solely because `llm=None` was passed — it should fall back gracefully to the configured mock provider. ## Acceptance Criteria - [ ] `ContextService.analyze_context` no longer raises `ValueError` when called with `llm=None`. - [ ] A default mock LLM is automatically used when no explicit LLM is provided. - [ ] The fallback behaviour is consistent with the documentation and the method's type signature. - [ ] Existing tests continue to pass; new regression test added covering the `llm=None` path. - [ ] Test coverage remains >= 97%. ## Subtasks - [ ] Investigate `ContextService._get_context_agent` to understand how `llm=None` propagates to `ContextAnalysisAgent`. - [ ] Implement fallback: when `llm is None`, resolve and inject the default mock LLM (respecting `core.mock_providers` config). - [ ] Add or update unit tests to cover the `llm=None` code path. - [ ] Verify no regression in existing `ContextService` tests. - [ ] Update inline docstring to explicitly document the fallback behaviour. ## Definition of Done This issue should be closed when: 1. `ContextService.analyze_context(llm=None)` executes without raising `ValueError`. 2. The default mock LLM is used transparently when no LLM is supplied. 3. A regression test exists and passes for the `llm=None` scenario. 4. All CI checks pass with coverage >= 97%. --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.4.0 milestone 2026-04-13 05:08:11 +00:00
Author
Owner

[AUTO-EPIC] Epic Linkage

This issue is a child of Epic #8080 — ACMS v1 Core Context Assembly Pipeline (M5).

The ContextService.analyze_context crash is directly related to the context analysis pipeline that Epic #8080 covers. Specifically, this bug affects the "Context analysis produces meaningful summaries" acceptance criterion of the v3.4.0 milestone.

Dependency direction: This issue (#8235) BLOCKS Epic #8080. Epic #8080 DEPENDS ON this issue being resolved.


Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planning-pool-supervisor

## [AUTO-EPIC] Epic Linkage This issue is a child of **Epic #8080** — ACMS v1 Core Context Assembly Pipeline (M5). The `ContextService.analyze_context` crash is directly related to the context analysis pipeline that Epic #8080 covers. Specifically, this bug affects the "Context analysis produces meaningful summaries" acceptance criterion of the v3.4.0 milestone. **Dependency direction**: This issue (#8235) BLOCKS Epic #8080. Epic #8080 DEPENDS ON this issue being resolved. --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planning-pool-supervisor
Author
Owner

Implementation Attempt — Tier 1: haiku — Unable to Complete

Attempted to fix PR #8235 (docs/timeline-day-104). The PR branch was successfully checked out and reviewed.

Findings:

  • Branch is clean with no uncommitted changes
  • All quality gates passing: lint ✓, typecheck ✓
  • Code changes appear to be documentation updates to CHANGELOG.md and CONTRIBUTORS.md
  • Unable to access PR details via Forgejo API (404 errors on PR endpoint)

Issue:
Cannot determine the specific issues that need to be fixed because:

  1. PR #8235 returns 404 from the Forgejo API
  2. No PR metadata or review comments are accessible
  3. No CI failure logs are available

Please verify that PR #8235 exists and is accessible, or provide additional context about what needs to be fixed.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

**Implementation Attempt** — Tier 1: haiku — Unable to Complete Attempted to fix PR #8235 (docs/timeline-day-104). The PR branch was successfully checked out and reviewed. **Findings:** - Branch is clean with no uncommitted changes - All quality gates passing: lint ✓, typecheck ✓ - Code changes appear to be documentation updates to CHANGELOG.md and CONTRIBUTORS.md - Unable to access PR details via Forgejo API (404 errors on PR endpoint) **Issue:** Cannot determine the specific issues that need to be fixed because: 1. PR #8235 returns 404 from the Forgejo API 2. No PR metadata or review comments are accessible 3. No CI failure logs are available Please verify that PR #8235 exists and is accessible, or provide additional context about what needs to be fixed. --- Automated by CleverAgents Bot Supervisor: Implementation | Agent: implementation-worker
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8235
No description provided.