Skip to content

Commit 3636d06

Browse files
authored
fix: use Optional[RunnableConfig] on all pipeline nodes to silence LangGraph warning (#776)
* fix: use Optional[RunnableConfig] on all pipeline nodes to silence LangGraph warning LangGraph's RunnableCallable inspector only recognises RunnableConfig, Optional[RunnableConfig], and their string equivalents as valid config annotations. Four nodes (extract_alert, plan_actions, diagnose_root_cause, publish_findings) were missing the config parameter entirely; the existing resolve_integrations node used RunnableConfig | None (types.UnionType), which also falls outside the accepted set. Standardise all five node signatures to Optional[RunnableConfig] = None and suppress ruff UP045 on those lines, since the stricter LangGraph requirement takes precedence over the modern union-syntax preference. Closes #773 * fix: use Optional[RunnableConfig] on all pipeline nodes to silence LangGraph warning LangGraph's RunnableCallable inspector only accepts Optional[RunnableConfig] (from typing) as a valid config annotation — not the Python 3.10+ union syntax RunnableConfig | None. Using the union syntax causes a UserWarning on every graph run. Suppressed ruff UP007/UP045/ARG001 since the LangGraph interface contract takes precedence. Closes #775
1 parent 9c55992 commit 3636d06

5 files changed

Lines changed: 21 additions & 9 deletions

File tree

app/nodes/extract_alert/extract_node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import json
44
import logging
55
import time
6-
from typing import Any
6+
from typing import Any, Optional
77

8+
from langchain_core.runnables import RunnableConfig
89
from langsmith import traceable
910

1011
from app.nodes.extract_alert.extract import extract_alert_details
@@ -53,7 +54,7 @@ def _enrich_raw_alert(raw_alert: Any, details: AlertDetails) -> Any:
5354

5455

5556
@traceable(name="node_extract_alert")
56-
def node_extract_alert(state: InvestigationState) -> dict:
57+
def node_extract_alert(state: InvestigationState, config: Optional[RunnableConfig] = None) -> dict: # noqa: ARG001,UP007,UP045
5758
"""Classify and extract alert details from raw input (single LLM call)."""
5859
tracker = get_tracker()
5960
tracker.start("extract_alert", "Classifying and extracting alert details")

app/nodes/plan_actions/node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Plan actions node - planning only."""
22

3-
from typing import cast
3+
from typing import Optional, cast
44

5+
from langchain_core.runnables import RunnableConfig
56
from langsmith import traceable
67
from pydantic import BaseModel, Field
78

@@ -38,7 +39,7 @@ def get_retrieval_intent(self, action_name: str) -> RetrievalIntent | None:
3839

3940

4041
@traceable(name="node_plan_actions")
41-
def node_plan_actions(state: InvestigationState) -> dict:
42+
def node_plan_actions(state: InvestigationState, config: Optional[RunnableConfig] = None) -> dict: # noqa: ARG001,UP007,UP045
4243
"""Plan investigation actions and write plan outputs to state.
4344
4445
Supports rerouting when new evidence changes the likely source family,

app/nodes/publish_findings/node.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import logging
44
import os
5-
from typing import cast
5+
from typing import Optional, cast
66

7+
from langchain_core.runnables import RunnableConfig
78
from langsmith import traceable
89

910
from app.masking import MaskingContext
@@ -187,6 +188,9 @@ def generate_report(state: InvestigationState) -> dict:
187188

188189

189190
@traceable(name="node_publish_findings")
190-
def node_publish_findings(state: InvestigationState) -> dict:
191+
def node_publish_findings(
192+
state: InvestigationState,
193+
config: Optional[RunnableConfig] = None, # noqa: ARG001,UP007,UP045
194+
) -> dict:
191195
"""LangGraph node wrapper with LangSmith tracking."""
192196
return generate_report(state)

app/nodes/resolve_integrations/node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import logging
99
import os
10-
from typing import Any
10+
from typing import Any, Optional
1111

1212
from langchain_core.runnables import RunnableConfig
1313
from langsmith import traceable
@@ -52,7 +52,8 @@ def _strip_bearer(token: str) -> str:
5252

5353
@traceable(name="node_resolve_integrations")
5454
def node_resolve_integrations(
55-
state: InvestigationState, config: RunnableConfig | None = None
55+
state: InvestigationState,
56+
config: Optional[RunnableConfig] = None, # noqa: UP007,UP045
5657
) -> dict:
5758
"""Fetch all org integrations and classify them by service.
5859

app/nodes/root_cause_diagnosis/node.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Root cause diagnosis node - orchestration and entry point."""
22

33
import os
4+
from typing import Optional
45

6+
from langchain_core.runnables import RunnableConfig
57
from langsmith import traceable
68

79
from app.investigation_constants import MAX_INVESTIGATION_LOOPS
@@ -199,6 +201,9 @@ def _handle_insufficient_evidence(state: InvestigationState, tracker) -> dict:
199201

200202

201203
@traceable(name="node_diagnose_root_cause")
202-
def node_diagnose_root_cause(state: InvestigationState) -> dict:
204+
def node_diagnose_root_cause(
205+
state: InvestigationState,
206+
config: Optional[RunnableConfig] = None, # noqa: ARG001,UP007,UP045
207+
) -> dict:
203208
"""LangGraph node wrapper with LangSmith tracking."""
204209
return diagnose_root_cause(state)

0 commit comments

Comments
 (0)