Skip to content

Commit 52e4328

Browse files
bjaggclaude
andauthored
Issue #974: Remove dead code in langchain_agent (summarize_conversation + helpers.py) (#975)
##### Description of Change Pure dead-code removal in the `langchain_agent` component, found during a code review. - **`summarize_conversation()` in `core.py`** referenced a non-existent `self.agent` attribute (the class stores agents in `self.agents`, a dict). It would have raised `AttributeError` if ever called — but it has **no callers** anywhere in `components/` or `bases/`. Removed. - **`helpers.py` (entire module)** — `update_person_interactions()` and its private `_build_mutation_query()` were **unreferenced** across the repo (nothing imports `helpers`). Interaction summaries are persisted via the `lif_mutation` MCP tool driven by the `save_interaction_summary` prompt, not this helper. Removed the file. - Updated the component README layout table to drop the `helpers.py` row. No behavior change for any current caller, since neither symbol was referenced. The public surface (`LIFAIAgent`) is unchanged. **How to test:** `uv run pre-commit run --all-files` — ruff, cspell, ty, and the full pytest suite pass. No runtime path is affected. ##### Related Issues Closes #974 ##### Type of Change - [x] Code refactoring ##### Project Area(s) Affected - [x] components/ --- ##### Checklist - [x] commit message follows commit guidelines (see commitlint.config.mjs) - [x] code passes linting checks (`uv run ruff check`) - [x] code passes formatting checks (`uv run ruff format`) - [x] code passes type checking (`uv run ty check`) - [x] pre-commit hooks have been run successfully ##### Testing - [x] Automated tests added/updated (existing suite green; no new behavior to test) ##### Additional Notes Dead code only — no tests added since there is no new behavior, and the removed code had no test coverage or callers. --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c69532e commit 52e4328

3 files changed

Lines changed: 0 additions & 131 deletions

File tree

components/lif/langchain_agent/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Wraps LangChain/LangGraph into a `LIFAIAgent` purpose-built for the Advisor's ch
77
| File | Contents |
88
|---|---|
99
| `core.py` | `LIFAIAgent` — top-level interface (`setup`, `ask_agent`) |
10-
| `helpers.py` | Prompt + chain construction helpers |
1110
| `memory.py` | LangGraph memory wiring (`langmem`-backed) |
1211
| [`prompts/`](prompts/) | Text-file prompt templates loaded at runtime |
1312

components/lif/langchain_agent/core.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
1111
Environment Variables:
1212
- TOOL_URL: URL for MCP tools
13-
- GRAPHQL_URL: URL for GraphQL endpoint
1413
- LLM_MODEL_NAME: Name of the LLM model to use
1514
"""
1615

@@ -29,7 +28,6 @@
2928

3029

3130
LIF_SEMANTIC_SEARCH_MCP_SERVER_URL = os.environ.get("LIF_SEMANTIC_SEARCH_MCP_SERVER_URL")
32-
LIF_GRAPHQL_API_URL = os.environ.get("LIF_GRAPHQL_API_URL")
3331
LLM_MODEL_NAME = os.environ.get("LIF_ADVISOR_LLM_MODEL_NAME")
3432
LLM_TOKEN_COSTS = {
3533
"gpt-4o-mini": {"input": 1.1, "output": 4.4, "cached": 0.275},
@@ -207,32 +205,6 @@ async def ask_agent(self, task, message: str) -> dict:
207205
logger.info(f"Response: {response}")
208206
return response
209207

210-
async def summarize_conversation(self, config: dict) -> dict:
211-
"""Ask the LLM to summarize the conversation and return the summary.
212-
213-
Args:
214-
config (dict): Configuration for the agent invocation.
215-
216-
Returns:
217-
dict: Agent response containing content, tokens, and cost.
218-
"""
219-
if not self.agent:
220-
raise RuntimeError("Agent not initialized! Call setup() first.")
221-
222-
result = await self.agent.ainvoke(
223-
{"messages": [{"role": "user", "content": "Summarize the conversation so far."}]}, config=config
224-
)
225-
messages = result.get("messages", [])
226-
final_message = messages[-1] if messages else None
227-
228-
if not final_message:
229-
logger.error("No response from agent.")
230-
return {"content": "", "tokens": 0, "cost": 0.0}
231-
232-
final_response = final_message.content
233-
234-
return final_response
235-
236208
def calculate_tokens_and_cost(self, messages: list) -> tuple:
237209
"""
238210
Calculates the total token usage and estimated cost for a list of messages.

components/lif/langchain_agent/helpers.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)