langchain-trigger-server 0.1.3__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of langchain-trigger-server might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-trigger-server
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Generic event-driven triggers framework
5
5
  Project-URL: Homepage, https://github.com/langchain-ai/open-agent-platform
6
6
  Project-URL: Repository, https://github.com/langchain-ai/open-agent-platform
@@ -527,12 +527,13 @@ class TriggerServer:
527
527
  }
528
528
 
529
529
  try:
530
- await self._invoke_agent(
530
+ success = await self._invoke_agent(
531
531
  agent_id=agent_id,
532
532
  user_id=registration["user_id"],
533
533
  input_data=agent_input,
534
534
  )
535
- agents_invoked += 1
535
+ if success:
536
+ agents_invoked += 1
536
537
  except Exception as e:
537
538
  logger.error(f"Error invoking agent {agent_id}: {e}", exc_info=True)
538
539
 
@@ -558,7 +559,7 @@ class TriggerServer:
558
559
  agent_id: str,
559
560
  user_id: str,
560
561
  input_data: Dict[str, Any],
561
- ) -> Dict[str, Any]:
562
+ ) -> bool:
562
563
  """Invoke LangGraph agent using the SDK."""
563
564
  logger.info(f"Invoking LangGraph agent {agent_id} for user {user_id}")
564
565
 
@@ -572,7 +573,7 @@ class TriggerServer:
572
573
 
573
574
  # Create a background run using the SDK
574
575
  run = await self.langgraph_client.runs.create(
575
- thread_id=None, # Let LangGraph create a new thread
576
+ thread_id=None,
576
577
  assistant_id=agent_id,
577
578
  input=input_data,
578
579
  metadata={
@@ -580,14 +581,20 @@ class TriggerServer:
580
581
  "user_id": user_id,
581
582
  },
582
583
  headers=headers,
584
+ if_not_exists="create",
583
585
  )
584
586
 
585
- logger.info(f"Successfully invoked agent {agent_id}, run_id: {run['run_id']}")
586
- return run
587
+ logger.info(f"Successfully invoked agent {agent_id}, run_id: {run['run_id']}, thread_id: {run['thread_id']}")
588
+ return True
587
589
 
588
590
  except Exception as e:
589
- logger.error(f"Error invoking agent {agent_id}: {e}")
590
- raise
591
+ # Handle 404s (agent not found) as warnings, not errors
592
+ if hasattr(e, 'response') and getattr(e.response, 'status_code', None) == 404:
593
+ logger.warning(f"Agent {agent_id} not found (404) - agent may have been deleted or moved")
594
+ return False
595
+ else:
596
+ logger.error(f"Error invoking agent {agent_id}: {e}")
597
+ raise
591
598
 
592
599
  async def _get_authenticated_user(self, trigger: TriggerTemplate, user_id: str) -> UserAuthInfo:
593
600
  """Get authenticated user with OAuth tokens for the trigger's required providers."""
@@ -116,27 +116,7 @@ class TriggerDatabaseInterface(ABC):
116
116
  async def get_triggers_for_agent(self, agent_id: str) -> List[Dict[str, Any]]:
117
117
  """Get all trigger registrations linked to an agent."""
118
118
  pass
119
-
120
- @abstractmethod
121
- async def set_agent_trigger_links(
122
- self,
123
- agent_id: str,
124
- registration_ids: List[str],
125
- created_by: str
126
- ) -> bool:
127
- """Replace all trigger links for an agent (atomic operation)."""
128
- pass
129
-
130
- @abstractmethod
131
- async def replace_trigger_agent_links(
132
- self,
133
- registration_id: str,
134
- agent_ids: List[str],
135
- created_by: str
136
- ) -> bool:
137
- """Replace all agent links for a trigger (atomic operation)."""
138
- pass
139
-
119
+
140
120
  # ========== Helper Methods ==========
141
121
 
142
122
  @abstractmethod
@@ -277,68 +277,6 @@ class SupabaseTriggerDatabase(TriggerDatabaseInterface):
277
277
  logger.error(f"Error getting triggers for agent: {e}")
278
278
  return []
279
279
 
280
- async def set_agent_trigger_links(
281
- self,
282
- agent_id: str,
283
- registration_ids: List[str],
284
- created_by: str
285
- ) -> bool:
286
- """Replace all trigger links for an agent (atomic operation)."""
287
- try:
288
- # Delete existing links
289
- await self.client.table("agent_trigger_links").delete().eq("agent_id", agent_id).execute()
290
-
291
- # Create new links
292
- if registration_ids:
293
- links = [
294
- {
295
- "agent_id": agent_id,
296
- "registration_id": reg_id,
297
- "created_by": created_by
298
- }
299
- for reg_id in registration_ids
300
- ]
301
-
302
- response = self.client.table("agent_trigger_links").insert(links).execute()
303
- return bool(response.data)
304
-
305
- return True # Successfully cleared all links
306
-
307
- except Exception as e:
308
- logger.error(f"Error setting agent trigger links: {e}")
309
- return False
310
-
311
- async def replace_trigger_agent_links(
312
- self,
313
- registration_id: str,
314
- agent_ids: List[str],
315
- created_by: str
316
- ) -> bool:
317
- """Replace all agent links for a trigger (atomic operation)."""
318
- try:
319
- # Delete existing links
320
- await self.client.table("agent_trigger_links").delete().eq("registration_id", registration_id).execute()
321
-
322
- # Create new links
323
- if agent_ids:
324
- links = [
325
- {
326
- "agent_id": agent_id,
327
- "registration_id": registration_id,
328
- "created_by": created_by
329
- }
330
- for agent_id in agent_ids
331
- ]
332
-
333
- response = self.client.table("agent_trigger_links").insert(links).execute()
334
- return bool(response.data)
335
-
336
- return True # Successfully cleared all links
337
-
338
- except Exception as e:
339
- logger.error(f"Error replacing trigger agent links: {e}")
340
- return False
341
-
342
280
  # ========== Helper Methods ==========
343
281
 
344
282
  async def get_user_from_token(self, token: str) -> Optional[str]:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "langchain-trigger-server"
7
- version = "0.1.3"
7
+ version = "0.1.5"
8
8
  description = "Generic event-driven triggers framework"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"