Gaykar commited on
Commit
50828d3
·
1 Parent(s): ecbbc46

chnagd context tolls

Browse files
app/agents/triage_agent.py CHANGED
@@ -19,7 +19,6 @@ triage_agent=ChatGroq(
19
 
20
 
21
  triage_agent=triage_agent.with_structured_output(
22
-
23
  TriageOutput,
24
  method="json_schema",
25
  include_raw=True,
 
19
 
20
 
21
  triage_agent=triage_agent.with_structured_output(
 
22
  TriageOutput,
23
  method="json_schema",
24
  include_raw=True,
app/tools/context_agent_tools.py CHANGED
@@ -11,13 +11,19 @@ from typing import Literal
11
  def search_sender_memory_tool(
12
  query: str,
13
  limit: int = 3,
14
- runtime: ToolRuntime = None # Inject everything natively here
 
15
  ) -> str:
16
- """Accepts a SINGLE string query to search the sender's history. Execute this tool multiple times if you need to search for different facts."""
 
 
17
 
18
- # 1. Pull values from graph state
19
- active_user = runtime.state.get("user_id")
20
- sender_email = runtime.state.get("sender_email_id")
 
 
 
21
 
22
  if not sender_email:
23
  return "Error: Cannot isolate history. Active sender_email_id is missing from state context."
@@ -27,6 +33,9 @@ def search_sender_memory_tool(
27
  }
28
 
29
  # 2. Access the BaseStore directly through runtime.store
 
 
 
30
  results = runtime.store.search(
31
  namespace=("email", active_user, "collection"),
32
  query=query,
@@ -51,7 +60,6 @@ def search_sender_memory_tool(
51
 
52
 
53
 
54
-
55
  @tool
56
  def give_previous_context(memory_summary: str) -> str:
57
  """
 
11
  def search_sender_memory_tool(
12
  query: str,
13
  limit: int = 3,
14
+ state: InjectedState = None, # Inject the LangGraph state here
15
+ runtime: ToolRuntime = None # Retain your runtime for the store
16
  ) -> str:
17
+ """Accepts a SINGLE string query to search the sender's history.
18
+ Execute this tool multiple times if you need to search for different facts.
19
+ """
20
 
21
+ # 1. Pull values directly from the injected graph state safely
22
+ if not state:
23
+ return "Error: Graph state injection failed entirely."
24
+
25
+ active_user = state.get("user_id")
26
+ sender_email = state.get("sender_email_id")
27
 
28
  if not sender_email:
29
  return "Error: Cannot isolate history. Active sender_email_id is missing from state context."
 
33
  }
34
 
35
  # 2. Access the BaseStore directly through runtime.store
36
+ if not runtime or not runtime.store:
37
+ return "Error: Runtime store context is missing."
38
+
39
  results = runtime.store.search(
40
  namespace=("email", active_user, "collection"),
41
  query=query,
 
60
 
61
 
62
 
 
63
  @tool
64
  def give_previous_context(memory_summary: str) -> str:
65
  """