Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent_fox/engine/session_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ async def _extract_knowledge_and_findings(
knowledge_db=self._knowledge_db,
sink_dispatcher=self._sink,
run_id=self._run_id,
embedder=self._embedder,
causal_context_limit=self._config.orchestrator.causal_context_limit,
)
except Exception:
Expand Down
47 changes: 45 additions & 2 deletions tests/unit/cli/test_knowledge_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,51 @@ async def test_extract_called_on_completed_session(self, tmp_path: Path) -> None
call_args = mock_extract.call_args
assert call_args.kwargs["spec_name"] == "test_spec"

@pytest.mark.asyncio
async def test_embedder_passed_to_extract(self, tmp_path: Path) -> None:
"""Regression: embedder must be forwarded to extract_and_store_knowledge (fixes #453)."""
workspace = _make_workspace(tmp_path)
outcome = _make_outcome(status="completed")

summary = {"summary": "Implemented feature X.", "tests_added_or_modified": []}
(tmp_path / ".agent-fox").mkdir(exist_ok=True)
(tmp_path / ".agent-fox" / "session-summary.json").write_text(json.dumps(summary))

spec_dir = Path.cwd() / ".specs" / "test_spec"
spec_dir.mkdir(parents=True, exist_ok=True)

config = AgentFoxConfig()
mock_embedder = MagicMock()
runner = NodeSessionRunner("test_spec:1", config, knowledge_db=_MOCK_KB, embedder=mock_embedder)

mock_extract = AsyncMock()

with (
patch(
"agent_fox.engine.session_lifecycle.run_session",
new_callable=AsyncMock,
return_value=outcome,
),
patch("agent_fox.engine.session_lifecycle.harvest", new_callable=AsyncMock),
patch(
"agent_fox.engine.session_lifecycle.create_worktree",
new_callable=AsyncMock,
return_value=workspace,
),
patch(
"agent_fox.engine.session_lifecycle.destroy_worktree",
new_callable=AsyncMock,
),
patch(
"agent_fox.engine.session_lifecycle.extract_and_store_knowledge",
mock_extract,
),
):
await runner.execute("test_spec:1", 1)

mock_extract.assert_called_once()
assert mock_extract.call_args.kwargs["embedder"] is mock_embedder

@pytest.mark.asyncio
async def test_extract_not_called_on_failed_session(self, tmp_path: Path) -> None:
"""extract_and_store_knowledge is NOT invoked when the session fails."""
Expand Down Expand Up @@ -177,5 +222,3 @@ async def test_extract_failure_does_not_block_session(self, tmp_path: Path) -> N

# Session is still completed despite extraction failure
assert record.status == "completed"