managed-deepagents 0.9.3.dev18__py3-none-win_amd64.whl → 0.9.3.dev20__py3-none-win_amd64.whl

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.
Binary file
@@ -39,6 +39,7 @@ from managed_deepagents._channels.trigger.ingress import (
39
39
  resume_ingress_agent,
40
40
  start_ingress_agent,
41
41
  )
42
+ from managed_deepagents._channels.trigger.tracing_project import tracer_session_id
42
43
  from managed_deepagents._channels.trigger.transport import TriggerTransport
43
44
  from managed_deepagents._channels.trigger.types import (
44
45
  TRIGGER_SERVICE_KEY_HEADER,
@@ -420,12 +421,15 @@ async def _observe_accepted_run(
420
421
  logger.log_identifier(event["channel_id"]),
421
422
  logger.log_identifier(started["run_id"]),
422
423
  )
423
- await _best_effort(
424
- client.post_runtime_event(
425
- event["channel_id"],
426
- _runtime_event(event_type, event, started, interrupts, message),
427
- )
424
+ request = _runtime_event(
425
+ event_type,
426
+ event,
427
+ started,
428
+ interrupts,
429
+ message,
430
+ tracer_session_id=await tracer_session_id(),
428
431
  )
432
+ await _best_effort(client.post_runtime_event(event["channel_id"], request))
429
433
 
430
434
  await lifecycle("run.started")
431
435
  # Not awaited here, so the reaction never delays the reply. The `finally`
@@ -636,6 +640,8 @@ def _runtime_event(
636
640
  started: StartedIngressRun,
637
641
  interrupts: list[TriggerChannelInterrupt] | None = None,
638
642
  message: str | None = None,
643
+ *,
644
+ tracer_session_id: str | None = None,
639
645
  ) -> TriggerChannelRuntimeEventRequest:
640
646
  request: TriggerChannelRuntimeEventRequest = {
641
647
  "id": str(uuid.uuid4()),
@@ -646,6 +652,8 @@ def _runtime_event(
646
652
  "run_thread_id": started["thread_id"],
647
653
  "run_id": started["run_id"],
648
654
  }
655
+ if tracer_session_id:
656
+ request["tracer_session_id"] = tracer_session_id
649
657
  if message:
650
658
  request["message"] = {"text": message}
651
659
  if interrupts:
@@ -0,0 +1,58 @@
1
+ """The LangSmith tracing project this deployment writes runs to."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ from time import monotonic
7
+
8
+ from managed_deepagents._log import logger
9
+
10
+ _LOOKUP_TIMEOUT_SECONDS = 2.0
11
+ _RETRY_AFTER_SECONDS = 60.0
12
+ _project_ids: dict[str, str] = {}
13
+ _next_lookup_at: dict[str, float] = {}
14
+
15
+
16
+ async def tracer_session_id() -> str | None:
17
+ """Id of the project the tracer writes this process's runs to.
18
+
19
+ The tracer addresses its project by name, so the id comes from that same
20
+ name. An id recorded at deploy time goes stale when someone renames the
21
+ project, because new traces then land in a fresh project under the old name.
22
+
23
+ ``None`` when tracing is off or no id is known yet, which costs a runtime
24
+ event its trace link and nothing else. A found id is cached for the
25
+ process. At most one lookup starts per minute, so a failing lookup cannot
26
+ hold up every event, and a caller that arrives while one is in flight
27
+ returns at once rather than starting another.
28
+ """
29
+ from langsmith import utils as ls_utils # noqa: PLC0415
30
+
31
+ # "local" traces never reach LangSmith, so they have nothing to link.
32
+ if ls_utils.tracing_is_enabled() is not True:
33
+ return None
34
+ name = ls_utils.get_tracer_project()
35
+ if not name:
36
+ return None
37
+ if cached := _project_ids.get(name):
38
+ return cached
39
+ now = monotonic()
40
+ if now < _next_lookup_at.get(name, 0.0):
41
+ return None
42
+ _next_lookup_at[name] = now + _RETRY_AFTER_SECONDS
43
+ try:
44
+ project_id = await asyncio.wait_for(
45
+ asyncio.to_thread(_read_project_id, name),
46
+ _LOOKUP_TIMEOUT_SECONDS,
47
+ )
48
+ except Exception as error: # noqa: BLE001 - a missing link must not cost the event
49
+ logger.warning("Tracing project lookup failed (%s).", logger.safe_error_label(error))
50
+ return None
51
+ _project_ids[name] = project_id
52
+ return project_id
53
+
54
+
55
+ def _read_project_id(name: str) -> str:
56
+ from langsmith import Client # noqa: PLC0415
57
+
58
+ return str(Client().read_project(project_name=name).id)
@@ -192,6 +192,10 @@ class TriggerChannelRuntimeEventRequest(TriggerChannelRuntimeEventRequestRequire
192
192
  # Present on `run.interrupted`. The Trigger Server cannot read the
193
193
  # deployment's threads, so pending interrupts travel on the event itself.
194
194
  interrupts: list[TriggerChannelInterrupt]
195
+ # The LangSmith tracing project this deployment writes runs to, so the
196
+ # channel can deep-link a run's trace. An opaque id, never a URL: a URL
197
+ # from here would let the deployment choose where a rendered link points.
198
+ tracer_session_id: str
195
199
 
196
200
 
197
201
  class TriggerChannelRuntimeEventResponse(TypedDict):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: managed-deepagents
3
- Version: 0.9.3.dev18
3
+ Version: 0.9.3.dev20
4
4
  Summary: Managed Deep Agents — the define_deep_agent authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.
5
5
  Author: LangChain
6
6
  License: MIT
@@ -680,7 +680,10 @@ is missing, including access from a custom tool or middleware. Connector
680
680
  declarations use the same behavior in a pre-run gate, so all known grants can be
681
681
  requested before the first model call. This path works in `mda deploy` and
682
682
  `mda dev` when `LANGSMITH_API_KEY` and `LANGSMITH_WORKSPACE_ID` are set and
683
- the workspace connection rows exist. Signed-in Studio users are identified by
683
+ the workspace connection rows exist. Reading a user-owned grant needs the
684
+ `workspaces:manage` permission for that `LANGSMITH_API_KEY`. Without it, the run
685
+ fails with `credential access requires workspaces:manage or permission on the
686
+ owning deployment` (status 403). Signed-in Studio users are identified by
684
687
  their LangSmith `ls_user_id`. Local development uses separate user connections
685
688
  from deployed Studio. OAuth completes on
686
689
  LangSmith’s platform callback URL. The local UI must show
@@ -40,7 +40,7 @@ managed_deepagents/run_context.py,sha256=1Nc3pew_nROgKi18PAKhn7vOAed-PmxArqUTpce
40
40
  managed_deepagents/runtime.py,sha256=88QmwIzEVCyq4p2BWOmw20xJJLSyemfbPneVfNnx7C0,95214
41
41
  managed_deepagents/sandbox.py,sha256=8qaswX6F2LYJX1uGq_7XwAGHZjGOD9VQ0WISqPK_ohs,4734
42
42
  managed_deepagents/schedules.py,sha256=-xyzJToGtLOiQMrPp6IcEVtWmZmqZWWHKgjHfDo_DmE,9447
43
- managed_deepagents/_binaries/mda.exe,sha256=kk2pWdoOGLTfJCU51YXZFNiMVV09VAYwRExjQpeQUQk,4539392
43
+ managed_deepagents/_binaries/mda.exe,sha256=6-SGfXp_uuJ0p9watNP8VE2-UuEDaJBHEfYSRoK-uj0,4539392
44
44
  managed_deepagents/_channels/__init__.py,sha256=mrsTLw4H5xpRsqJxbBxr6WpCVQHsmx782GwIiYQqt-Y,720
45
45
  managed_deepagents/_channels/assistant_text.py,sha256=ZLYAF1MQVE5_EN49MoPJdB8Ckf3vNPpXNBhkdA4egF0,3414
46
46
  managed_deepagents/_channels/binding.py,sha256=DnxB7FXkbY5B3PCEAGz3JJBCCnQSdWz8PU8ze4fdcZU,5302
@@ -67,11 +67,12 @@ managed_deepagents/_channels/slack/transport.py,sha256=_BuHwmP5-qNh3o86QE1hEgzcN
67
67
  managed_deepagents/_channels/trigger/__init__.py,sha256=bWj66XoPbDdrztPUCKBuSJBBS2pBocn4EA8FDE3WeBA,48
68
68
  managed_deepagents/_channels/trigger/channel.py,sha256=4ndfYw8HiWvSr-zFA4Xj3qkwZ015aLJGjP57Z43n6NQ,6690
69
69
  managed_deepagents/_channels/trigger/client.py,sha256=cM97gzYWUTFC9o3uoveFe9-HxZc6_VqiqC8u4fKqjXc,8572
70
- managed_deepagents/_channels/trigger/http.py,sha256=hiVUNrVgo6taqPU2-_tSrAHMlFT-LObx7B2c7SJZSMo,26222
70
+ managed_deepagents/_channels/trigger/http.py,sha256=TkKkl9g0g0jHvAbL4KTA_yjj8Cy6f_pvfOcyGrZTk8c,26522
71
71
  managed_deepagents/_channels/trigger/identity_context.py,sha256=vZFcb5N9i-rvmA19Fa7ccP57t1CSHZnEHRB33MRKOsI,8129
72
72
  managed_deepagents/_channels/trigger/ingress.py,sha256=9SQkldNrGnasFAsde13hoTqxHiuhUp4FLkYWcYDTbxE,6787
73
+ managed_deepagents/_channels/trigger/tracing_project.py,sha256=iBFGDboFcCClXJvNV4PgTO8TeAhna5ms-NTXlTd8uV0,2091
73
74
  managed_deepagents/_channels/trigger/transport.py,sha256=h4tNQ__MlfH5NtpR3DoiMO7__Z_H4Ygq8wew6W2uzKw,1830
74
- managed_deepagents/_channels/trigger/types.py,sha256=K8uvaNKzpx-zn3hd1GBZOMQPDqL2JbRLxJnxAhd_pOE,10236
75
+ managed_deepagents/_channels/trigger/types.py,sha256=_OhA-WrlIf5ueI3O9-M_0645L_1dmN4ekRupgmuhJbw,10492
75
76
  managed_deepagents/_connectors/__init__.py,sha256=Ei-DvDmA-F2Bord6WuM7UtWtnuVt3u7CRSPKFqpHFhA,537
76
77
  managed_deepagents/_connectors/tool_selection.py,sha256=-dtrHi8o4FsXG70V4CWgzL2UVG-89P3TU1Xk8UEdyDU,3029
77
78
  managed_deepagents/_connectors/mcp/__init__.py,sha256=GILRaVSbQNgclmJcgmXpG6R_C63R_y2gEfvyFBlSRZM,17455
@@ -103,9 +104,9 @@ managed_deepagents/identity/__init__.py,sha256=YMB5p2DRyyY_82gGNVfGHjfjnUFRTtMne
103
104
  managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
104
105
  managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
105
106
  managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
106
- managed_deepagents-0.9.3.dev18.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
107
- managed_deepagents-0.9.3.dev18.dist-info/METADATA,sha256=vrPJ6g0Z8OqZLBpc5zKzYz7D9fZ__pPuxGWwDicyVeA,35047
108
- managed_deepagents-0.9.3.dev18.dist-info/WHEEL,sha256=3I5VVWZdsFlU417aCS2bMRuerS8wsfvBq99MyatBV3A,97
109
- managed_deepagents-0.9.3.dev18.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
110
- managed_deepagents-0.9.3.dev18.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
111
- managed_deepagents-0.9.3.dev18.dist-info/RECORD,,
107
+ managed_deepagents-0.9.3.dev20.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
108
+ managed_deepagents-0.9.3.dev20.dist-info/METADATA,sha256=aoyfnsV4CnlN8HAOWmNFf5bYu_hdj4aZ2NhH8SE5rRE,35276
109
+ managed_deepagents-0.9.3.dev20.dist-info/WHEEL,sha256=3I5VVWZdsFlU417aCS2bMRuerS8wsfvBq99MyatBV3A,97
110
+ managed_deepagents-0.9.3.dev20.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
111
+ managed_deepagents-0.9.3.dev20.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
112
+ managed_deepagents-0.9.3.dev20.dist-info/RECORD,,