phase: 108_history_wire_check
Final verification pass complete — everything independently re-verified green. Report: **Phase 108 — History wire check (final verification pass; verdict: NO BUG, tests-only per D13)** - Verified all 3 tasks complete in `.agents/phases/complete/108_history_wire_check/`; re-ran every pin and gate myself - Layer 1 (unit): 2 owner-shape pins in `tests/unit/test_history.py` (2-turn keep-whole + A4 thinking mapping) — pass - Layer 2 (integration): `test_endpoint_two_turn_history_reaches_the_llm` — captured LLM request = `[system, user Q1, assistant R1, user Q2]`, `history_msgs=2` — pass - Layer 3 (E2E): `tests/e2e/test_history_wire_check.py` — owner's verbatim 3-message scenario, echo byte-exact (T2: `2 prior messages`+R1 tail; T3: `4 prior messages`+R2 tail) — pass - `VERDICT.md` present in phase dir: layer outcomes + "no bug — model behavior/user error" + pin names **Gates (exact results)** - `uv run pytest --cov=app --cov-report=term-missing` → 2305 passed, TOTAL **99%** (>90%) - `uv run pytest tests/e2e/test_history_wire_check.py -v --no-cov` → 2 passed (isolation, DB up) - `uv run pytest tests/e2e/test_llm_history.py -v --no-cov` (phase-74 regression) → 3 passed - `uv run ruff check .` → clean; `uv run pyright` → 0 errors **Completion criteria:** all six met — no defects found; diff scoped to `tests/**`, `VERDICT.md`, `.agents/phases/**`, `.agents/reports/**` (no `app/`/`frontend/` changes, consistent with no-bug verdict). Per executor rules, no git commit made — left for the harness. **Next pending phase:** `109_turn_progress_loader`
This commit is contained in:
@@ -1733,6 +1733,49 @@ def test_grounded_turn_forwards_history_through_the_agent(
|
||||
assert lines and "history_msgs=4" in lines[-1]
|
||||
|
||||
|
||||
def test_endpoint_two_turn_history_reaches_the_llm(
|
||||
client,
|
||||
db,
|
||||
seeded_kb: FakeRagLLM,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Phase 108 layer 2 (TODO L4 — the owner's follow-up, server wire):
|
||||
the owner's exact 2-turn history (Q1 "What is my name?" / R1 "Your
|
||||
name is Reese.") plus the follow-up "What did I just ask you?" must
|
||||
reach the LLM as ``[system, user Q1, assistant R1, user Q2]`` — the
|
||||
two prior turns NOT dropped (the reported missing-first-turn symptom
|
||||
would be their absence from this captured request). The pin is
|
||||
branch-agnostic BY DESIGN: phase 74 pinned the history splice on
|
||||
BOTH branches, so whichever the seeded KB retrieves to (LOW/deflected
|
||||
or HIGH/grounded), the captured request must carry the full prior
|
||||
exchange. The seeded-KB fixture is used because it is the file's
|
||||
standard idiom (and keeps the cosine gate exercised like production);
|
||||
the canned fake answer ends the turn on exactly one LLM request on
|
||||
either branch."""
|
||||
history = [
|
||||
{"who": "user", "text": "What is my name?"},
|
||||
{"who": "brain", "text": "Your name is Reese."},
|
||||
]
|
||||
fastapi_app.dependency_overrides[chat_api.get_llm] = lambda: seeded_kb
|
||||
try:
|
||||
caplog.set_level(logging.INFO, logger="app.chat")
|
||||
frames = _stream_chat_with_history(client, "What did I just ask you?", history)
|
||||
finally:
|
||||
fastapi_app.dependency_overrides.clear()
|
||||
|
||||
assert frames[-1]["type"] == "done" # the turn completes (either branch)
|
||||
assert len(seeded_kb.seen_messages) == 1 # the canned answer ends the turn
|
||||
(messages,) = seeded_kb.seen_messages
|
||||
assert messages[0]["role"] == "system"
|
||||
assert messages[1:-1] == [
|
||||
{"role": "user", "content": "What is my name?"},
|
||||
{"role": "assistant", "content": "Your name is Reese."},
|
||||
] # the FULL prior exchange — chronological, nothing dropped
|
||||
assert messages[-1] == {"role": "user", "content": "What did I just ask you?"}
|
||||
lines = [r.getMessage() for r in caplog.records if "question=" in r.getMessage()]
|
||||
assert lines and "history_msgs=2" in lines[-1]
|
||||
|
||||
|
||||
def test_request_without_history_sends_exactly_system_and_user(
|
||||
client,
|
||||
db,
|
||||
|
||||
Reference in New Issue
Block a user