BUG-HUNT: [cross-module] Context hydration failure silently continues execution — LLM runs with zero project context but plan state does not reflect the degraded condition #6636

Open
opened 2026-04-09 22:38:12 +00:00 by HAL9000 · 0 comments
Owner

Bug Report: [cross-module] — Context hydration failure swallowed; plan proceeds with empty context

Severity Assessment

  • Impact: If context tier hydration fails (e.g., resource registry unavailable, project files inaccessible), the LLM receives a prompt with zero file context. The plan is not marked as degraded and there is no signal to the user that execution happened with empty context. The resulting changeset is likely to be wrong, incomplete, or based purely on the task description with no project awareness.
  • Likelihood: Medium. Hydration can fail whenever the resource registry, project repository, or filesystem is temporarily unavailable.
  • Priority: High

Location

File Lines Role
src/cleveragents/application/services/llm_actors.py 329–359 Hydration failure swallowed with logger.warning only
src/cleveragents/application/services/llm_actors.py 362–370 Context assembly failure also swallowed

Description

LLMExecuteActor.execute() calls hydrate_tiers_for_plan() inside a broad except Exception that silently continues after logging a warning:

# llm_actors.py, lines 329-359
try:
    from cleveragents.application.services.context_tier_hydrator import (
        hydrate_tiers_for_plan,
    )
    ...
    hydrate_tiers_for_plan(
        tier_service=self._tier_service,
        project_names=project_names,
        project_repository=self._project_repository,
        resource_registry=self._resource_registry,
    )
except Exception as _hydration_exc:
    self._logger.warning(            # ← only a warning log
        "context_hydration_failed",
        error=str(_hydration_exc),
        plan_id=plan_id,
    )
    # ← execution continues with empty tier service

Immediately after, if context assembly produces None (because the tier service is empty), execution still continues:

# llm_actors.py, lines 362-370
assembled_context: AssembledContext | None = None
if self._context_assembler is not None:
    try:
        assembled_context = self._context_assembler.assemble(plan)
    except Exception as _asm_err:
        self._logger.warning(
            "execute_context_assembly_failed",
            ...
        )
        # ← assembled_context remains None, execution continues

When assembled_context is None, the prompt includes no context section at all:

# llm_actors.py, lines 373-389
context_section = ""
if assembled_context is not None:
    context_section = "..."  # only populated if assembly succeeded
prompt = (
    "..."
    f"{context_section}"   # empty string when assembly failed
    ...
)

This means the LLM runs with only the task description (decisions text) and no project context. This issue is distinct from #6401 (silent fallback for the entire LLMExecuteActor): this is specifically about hydration and assembly failure happening silently at the cross-module boundary between context_tier_hydratorexecute_phase_context_assemblerLLMExecuteActor.

Files Involved

File Role
src/cleveragents/application/services/llm_actors.py Silently swallows hydration and assembly failures
src/cleveragents/application/services/context_tier_hydrator.py Populates context tiers from project files
src/cleveragents/application/services/execute_phase_context_assembler.py Assembles fragments into AssembledContext

Data Flow Where It Breaks

LLMExecuteActor.execute()
  ↓
hydrate_tiers_for_plan(...)   ← raises e.g. DatabaseError
  ↓ caught by "except Exception", only warning logged
  ↓ tier_service remains empty
context_assembler.assemble(plan)
  ↓ scoped view is empty → returns None
assembled_context = None
  ↓
LLM prompt has empty context_section
  ↓
LLM generates changeset with ZERO project file context
  ↓
Plan state = COMPLETE (no error recorded)

Expected Behavior

When context hydration fails and the assembled context is None, the plan should either:

  1. Fail with ProcessingState.ERRORED and a meaningful error message, or
  2. Emit a structured warning (not just a log line) that is visible in agents plan status output, so the user knows the changeset was produced without project context.

At minimum, the plan's error_details should record "context_hydration_failed": "true" so operators can identify degraded executions.

Actual Behavior

Hydration and assembly failures are silently swallowed. The plan completes normally with ProcessingState.COMPLETE and the user has no way to know that the LLM ran without project context.

Suggested Fix

After hydration and assembly, if context is still empty, record a warning in the plan's error details:

if assembled_context is None:
    # Record degraded execution in plan state
    self._lifecycle.get_plan(plan_id).error_details = {
        **(plan.error_details or {}),
        "context_assembly_warning": "execute_ran_with_empty_context",
    }
    self._lifecycle._commit_plan(plan)

Or raise a recoverable PlanError to abort execution with an informative message rather than producing a low-quality changeset.

Category

error-handling / cross-module

TDD Note

After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_, and @tdd_expected_fail to prove the bug exists before fixing it.


Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: bug-hunter

## Bug Report: [cross-module] — Context hydration failure swallowed; plan proceeds with empty context ### Severity Assessment - **Impact**: If context tier hydration fails (e.g., resource registry unavailable, project files inaccessible), the LLM receives a prompt with zero file context. The plan is not marked as degraded and there is no signal to the user that execution happened with empty context. The resulting changeset is likely to be wrong, incomplete, or based purely on the task description with no project awareness. - **Likelihood**: Medium. Hydration can fail whenever the resource registry, project repository, or filesystem is temporarily unavailable. - **Priority**: High ### Location | File | Lines | Role | |------|-------|------| | `src/cleveragents/application/services/llm_actors.py` | 329–359 | Hydration failure swallowed with `logger.warning` only | | `src/cleveragents/application/services/llm_actors.py` | 362–370 | Context assembly failure also swallowed | ### Description `LLMExecuteActor.execute()` calls `hydrate_tiers_for_plan()` inside a broad `except Exception` that silently continues after logging a warning: ```python # llm_actors.py, lines 329-359 try: from cleveragents.application.services.context_tier_hydrator import ( hydrate_tiers_for_plan, ) ... hydrate_tiers_for_plan( tier_service=self._tier_service, project_names=project_names, project_repository=self._project_repository, resource_registry=self._resource_registry, ) except Exception as _hydration_exc: self._logger.warning( # ← only a warning log "context_hydration_failed", error=str(_hydration_exc), plan_id=plan_id, ) # ← execution continues with empty tier service ``` Immediately after, if context assembly produces `None` (because the tier service is empty), execution still continues: ```python # llm_actors.py, lines 362-370 assembled_context: AssembledContext | None = None if self._context_assembler is not None: try: assembled_context = self._context_assembler.assemble(plan) except Exception as _asm_err: self._logger.warning( "execute_context_assembly_failed", ... ) # ← assembled_context remains None, execution continues ``` When `assembled_context is None`, the prompt includes no context section at all: ```python # llm_actors.py, lines 373-389 context_section = "" if assembled_context is not None: context_section = "..." # only populated if assembly succeeded prompt = ( "..." f"{context_section}" # empty string when assembly failed ... ) ``` This means the LLM runs with only the task description (decisions text) and no project context. This issue is distinct from #6401 (silent fallback for the entire LLMExecuteActor): this is specifically about hydration and assembly failure happening silently at the cross-module boundary between `context_tier_hydrator` → `execute_phase_context_assembler` → `LLMExecuteActor`. ### Files Involved | File | Role | |------|------| | `src/cleveragents/application/services/llm_actors.py` | Silently swallows hydration and assembly failures | | `src/cleveragents/application/services/context_tier_hydrator.py` | Populates context tiers from project files | | `src/cleveragents/application/services/execute_phase_context_assembler.py` | Assembles fragments into `AssembledContext` | ### Data Flow Where It Breaks ``` LLMExecuteActor.execute() ↓ hydrate_tiers_for_plan(...) ← raises e.g. DatabaseError ↓ caught by "except Exception", only warning logged ↓ tier_service remains empty context_assembler.assemble(plan) ↓ scoped view is empty → returns None assembled_context = None ↓ LLM prompt has empty context_section ↓ LLM generates changeset with ZERO project file context ↓ Plan state = COMPLETE (no error recorded) ``` ### Expected Behavior When context hydration fails and the assembled context is `None`, the plan should either: 1. Fail with `ProcessingState.ERRORED` and a meaningful error message, **or** 2. Emit a structured warning (not just a log line) that is visible in `agents plan status` output, so the user knows the changeset was produced without project context. At minimum, the plan's `error_details` should record `"context_hydration_failed": "true"` so operators can identify degraded executions. ### Actual Behavior Hydration and assembly failures are silently swallowed. The plan completes normally with `ProcessingState.COMPLETE` and the user has no way to know that the LLM ran without project context. ### Suggested Fix After hydration and assembly, if context is still empty, record a warning in the plan's error details: ```python if assembled_context is None: # Record degraded execution in plan state self._lifecycle.get_plan(plan_id).error_details = { **(plan.error_details or {}), "context_assembly_warning": "execute_ran_with_empty_context", } self._lifecycle._commit_plan(plan) ``` Or raise a recoverable `PlanError` to abort execution with an informative message rather than producing a low-quality changeset. ### Category error-handling / cross-module ### TDD Note After this bug issue is verified, a corresponding Type/Testing issue will be created for TDD. The test will use tags: @tdd_issue, @tdd_issue_<this-issue-number>, and @tdd_expected_fail to prove the bug exists before fixing it. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: bug-hunter
HAL9000 added this to the v3.2.0 milestone 2026-04-09 22:47:14 +00:00
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#6636
No description provided.