docent-python 0.1.59a0__tar.gz → 0.1.60a0__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.
Files changed (88) hide show
  1. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/PKG-INFO +1 -1
  2. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/reading.py +138 -2
  3. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/mcp/server.py +13 -3
  4. docent_python-0.1.60a0/docent/sdk/_agent_runs.py +217 -0
  5. docent_python-0.1.60a0/docent/sdk/_base.py +299 -0
  6. docent_python-0.1.60a0/docent/sdk/_client_util.py +141 -0
  7. docent_python-0.1.60a0/docent/sdk/_collections.py +421 -0
  8. docent_python-0.1.60a0/docent/sdk/_dql.py +297 -0
  9. docent_python-0.1.60a0/docent/sdk/_feedback.py +157 -0
  10. docent_python-0.1.60a0/docent/sdk/_labels.py +225 -0
  11. docent_python-0.1.60a0/docent/sdk/_readings.py +1121 -0
  12. docent_python-0.1.60a0/docent/sdk/_results.py +311 -0
  13. docent_python-0.1.60a0/docent/sdk/_rubrics.py +320 -0
  14. docent_python-0.1.60a0/docent/sdk/_sharing.py +229 -0
  15. docent_python-0.1.60a0/docent/sdk/client.py +45 -0
  16. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/reading.py +6 -4
  17. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/pyproject.toml +1 -1
  18. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/uv.lock +1 -1
  19. docent_python-0.1.59a0/docent/sdk/client.py +0 -3281
  20. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/.gitignore +0 -0
  21. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/LICENSE.md +0 -0
  22. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/README.md +0 -0
  23. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/__init__.py +0 -0
  24. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/__init__.py +0 -0
  25. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/data_models/__init__.py +0 -0
  26. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/data_models/exceptions.py +0 -0
  27. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/data_models/llm_output.py +0 -0
  28. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/llm_cache.py +0 -0
  29. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/llm_svc.py +0 -0
  30. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/model_registry.py +0 -0
  31. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/__init__.py +0 -0
  32. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/anthropic.py +0 -0
  33. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/common.py +0 -0
  34. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/google.py +0 -0
  35. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/openai.py +0 -0
  36. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/openrouter.py +0 -0
  37. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/preference_types.py +0 -0
  38. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_llm_util/providers/provider_registry.py +0 -0
  39. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_log_util/__init__.py +0 -0
  40. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/_log_util/logger.py +0 -0
  41. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/__init__.py +0 -0
  42. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/_tiktoken_util.py +0 -0
  43. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/agent_run.py +0 -0
  44. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/chat/__init__.py +0 -0
  45. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/chat/content.py +0 -0
  46. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/chat/message.py +0 -0
  47. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/chat/response_format.py +0 -0
  48. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/chat/tool.py +0 -0
  49. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/citation.py +0 -0
  50. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/feedback.py +0 -0
  51. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/formatted_objects.py +0 -0
  52. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/judge.py +0 -0
  53. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/metadata_util.py +0 -0
  54. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/regex.py +0 -0
  55. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/transcript.py +0 -0
  56. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/data_models/util.py +0 -0
  57. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/__init__.py +0 -0
  58. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/analysis.py +0 -0
  59. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/impl.py +0 -0
  60. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/runner.py +0 -0
  61. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/stats.py +0 -0
  62. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/types.py +0 -0
  63. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/forgiving_json.py +0 -0
  64. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/meta_schema.json +0 -0
  65. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/meta_schema.py +0 -0
  66. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/parse_output.py +0 -0
  67. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/template_formatter.py +0 -0
  68. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/judges/util/voting.py +0 -0
  69. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/loaders/load_inspect.py +0 -0
  70. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/mcp/__init__.py +0 -0
  71. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/mcp/__main__.py +0 -0
  72. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/py.typed +0 -0
  73. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/samples/__init__.py +0 -0
  74. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/samples/load.py +0 -0
  75. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/samples/log.eval +0 -0
  76. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/samples/tb_airline.json +0 -0
  77. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/__init__.py +0 -0
  78. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/agent_run_writer.py +0 -0
  79. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/integrations/__init__.py +0 -0
  80. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/integrations/harbor.py +0 -0
  81. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/integrations/inspect.py +0 -0
  82. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/integrations/nemogym.py +0 -0
  83. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/integrations/util.py +0 -0
  84. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/llm_context.py +0 -0
  85. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/llm_request.py +0 -0
  86. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/sdk/util.py +0 -0
  87. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/trace.py +0 -0
  88. {docent_python-0.1.59a0 → docent_python-0.1.60a0}/docent/trace_temp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docent-python
3
- Version: 0.1.59a0
3
+ Version: 0.1.60a0
4
4
  Summary: Docent SDK
5
5
  Project-URL: Homepage, https://github.com/TransluceAI/docent
6
6
  Project-URL: Issues, https://github.com/TransluceAI/docent/issues
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Any, Literal, TypeAlias
2
+ from typing import Annotated, Any, Literal, TypeAlias
3
3
  from uuid import uuid4
4
4
 
5
5
  from pydantic import BaseModel, Field
@@ -41,6 +41,7 @@ prompt segments, model config, output schema, and user-supplied arguments.
41
41
  re-evaluation.
42
42
  """
43
43
  ReadingCacheMode = Literal["reading", "results", "none"]
44
+ ReadingStatus = Literal["completed", "failed", "pending", "cached", "needs_approval", "unresolved"]
44
45
 
45
46
 
46
47
  class ContextFilterSection(BaseModel):
@@ -73,6 +74,7 @@ class ReadingPreset(BaseModel):
73
74
  collection_id: str
74
75
  name: str
75
76
  created_at: datetime | None = None
77
+ created_by: str | None = None
76
78
  updated_at: datetime | None = None
77
79
 
78
80
 
@@ -117,6 +119,7 @@ class Reading(BaseModel):
117
119
  user_metadata: dict[str, Any] | None = None
118
120
  source_reading_preset_id: str | None = None
119
121
  created_at: datetime | None = None
122
+ created_by: str | None = None
120
123
 
121
124
 
122
125
  class ReadingResult(BaseModel):
@@ -226,6 +229,7 @@ class ReadingPlan(BaseModel):
226
229
  name: str | None = None
227
230
  steps: list[PlanStep] = Field(default_factory=list) # type: ignore[reportUnknownVariableType]
228
231
  created_at: datetime | None = None
232
+ created_by: str | None = None
229
233
  updated_at: datetime | None = None
230
234
 
231
235
 
@@ -306,23 +310,140 @@ class PlanSubmissionRequest(BaseModel):
306
310
  entries: list[PlanStepSubmission]
307
311
 
308
312
 
313
+ class DqlPreview(BaseModel):
314
+ columns: list[str]
315
+ rows: list[list[Any]]
316
+ truncated: bool
317
+ row_count: int
318
+
319
+
320
+ class ReadingResultPreview(BaseModel):
321
+ id: str
322
+ output: dict[str, Any] | None = None
323
+ error: dict[str, Any] | None = None
324
+
325
+
309
326
  class PlanStepSubmissionStatus(BaseModel):
310
327
  alias: str
311
- status: Literal["cached", "needs_approval", "unresolved"]
328
+ entry_type: str
329
+ status: ReadingStatus
312
330
  reading_id: str | None = None
331
+ result_count: int | None = None
332
+ dql_preview: DqlPreview | None = None
333
+ result_preview: list[ReadingResultPreview] | None = None
313
334
 
314
335
 
315
336
  class PlanSubmissionResponse(BaseModel):
316
337
  plan_id: str
338
+ plan_name: str | None = None
339
+ previous_latest_plan_id: str | None = None
340
+ has_active_listeners: bool = False
317
341
  entry_statuses: list[PlanStepSubmissionStatus]
318
342
 
319
343
 
344
+ # ── Plan SSE stream events (server → SDK) ────────────────────────────
345
+
346
+
347
+ class PlanStreamStepStatus(BaseModel):
348
+ """Minimal step shape carried inside a snapshot event."""
349
+
350
+ alias: str
351
+ reading_id: str | None = None
352
+ derived_status: str
353
+
354
+
355
+ class PlanSnapshotEvent(BaseModel):
356
+ type: Literal["snapshot"] = "snapshot"
357
+ steps: list[PlanStreamStepStatus]
358
+
359
+
360
+ class PlanStepError(BaseModel):
361
+ message: str
362
+
363
+
364
+ class PlanStepStartedEvent(BaseModel):
365
+ type: Literal["step_started"] = "step_started"
366
+ plan_id: str
367
+ step_alias: str
368
+ job_id: str
369
+ reading_id: str
370
+
371
+
372
+ class PlanStepCompletedEvent(BaseModel):
373
+ type: Literal["step_completed"] = "step_completed"
374
+ plan_id: str
375
+ step_alias: str
376
+ job_id: str
377
+ reading_id: str
378
+ result_count: int | None = None
379
+
380
+
381
+ class PlanStepFailedEvent(BaseModel):
382
+ type: Literal["step_failed"] = "step_failed"
383
+ plan_id: str
384
+ step_alias: str
385
+ job_id: str
386
+ error: PlanStepError | None = None
387
+
388
+
389
+ class PlanStepsUpdatedEvent(BaseModel):
390
+ type: Literal["steps_updated"] = "steps_updated"
391
+ plan_id: str
392
+
393
+
394
+ class PlanJobStartedEvent(BaseModel):
395
+ type: Literal["job_started"] = "job_started"
396
+ plan_id: str
397
+ job_id: str
398
+
399
+
400
+ class PlanJobCompletedEvent(BaseModel):
401
+ type: Literal["job_completed"] = "job_completed"
402
+ plan_id: str
403
+ job_id: str
404
+
405
+
406
+ class PlanJobFailedEvent(BaseModel):
407
+ type: Literal["job_failed"] = "job_failed"
408
+ plan_id: str
409
+ job_id: str
410
+ error: PlanStepError | None = None
411
+
412
+
413
+ class PlanSupersededEvent(BaseModel):
414
+ type: Literal["plan_superseded"] = "plan_superseded"
415
+ plan_id: str
416
+ superseded_by_plan_id: str
417
+ name: str | None = None
418
+
419
+
420
+ class PlanJobCancelledEvent(BaseModel):
421
+ type: Literal["job_cancelled"] = "job_cancelled"
422
+ plan_id: str
423
+
424
+
425
+ PlanStreamEvent: TypeAlias = Annotated[
426
+ PlanSnapshotEvent
427
+ | PlanStepStartedEvent
428
+ | PlanStepCompletedEvent
429
+ | PlanStepFailedEvent
430
+ | PlanStepsUpdatedEvent
431
+ | PlanJobStartedEvent
432
+ | PlanJobCompletedEvent
433
+ | PlanJobFailedEvent
434
+ | PlanJobCancelledEvent
435
+ | PlanSupersededEvent,
436
+ Field(discriminator="type"),
437
+ ]
438
+
439
+
320
440
  __all__ = [
321
441
  "AnnotatableReadingParamType",
322
442
  "BeginGroupStep",
323
443
  "ContextFilterSection",
324
444
  "DqlOnlyStep",
325
445
  "DqlOnlyStepSubmission",
446
+ "DqlPreview",
326
447
  "EndGroupStep",
327
448
  "EndStepGroupSubmission",
328
449
  "ScriptedRequest",
@@ -335,6 +456,8 @@ __all__ = [
335
456
  "ReadingCacheMode",
336
457
  "ReadingParamPlaceholder",
337
458
  "ReadingParamType",
459
+ "ReadingResultPreview",
460
+ "ReadingStatus",
338
461
  "ReadingStep",
339
462
  "ReadingStepSubmission",
340
463
  "ReadingTemplateSegment",
@@ -346,4 +469,17 @@ __all__ = [
346
469
  "ReadingResult",
347
470
  "StepGroupSubmission",
348
471
  "PresetReadingStepSubmission",
472
+ "PlanStreamEvent",
473
+ "PlanStreamStepStatus",
474
+ "PlanSnapshotEvent",
475
+ "PlanStepStartedEvent",
476
+ "PlanStepCompletedEvent",
477
+ "PlanStepError",
478
+ "PlanStepFailedEvent",
479
+ "PlanStepsUpdatedEvent",
480
+ "PlanJobStartedEvent",
481
+ "PlanJobCompletedEvent",
482
+ "PlanJobFailedEvent",
483
+ "PlanJobCancelledEvent",
484
+ "PlanSupersededEvent",
349
485
  ]
@@ -33,10 +33,13 @@ def get_metadata_fields(collection_id: str) -> str:
33
33
  """
34
34
  client = get_client()
35
35
  try:
36
- fields = client.get_metadata_fields(
36
+ response = client.get_metadata_fields(
37
37
  collection_id, include_sample_values=True, sample_limit=10
38
38
  )
39
39
 
40
+ fields = response.get("fields", [])
41
+ total_runs = response.get("total_runs")
42
+
40
43
  if not fields:
41
44
  return f"No metadata fields found for collection {collection_id}"
42
45
 
@@ -71,7 +74,10 @@ def get_metadata_fields(collection_id: str) -> str:
71
74
  lines.append(line)
72
75
 
73
76
  field_list = "\n".join(lines)
74
- return f"Metadata fields for collection {collection_id}:\n{field_list}"
77
+ tool_output = f"Metadata fields for collection {collection_id}:\n{field_list}"
78
+ if total_runs is not None:
79
+ tool_output += f"\n\nTotal runs: {total_runs}"
80
+ return tool_output
75
81
  except Exception as e:
76
82
  error_msg = str(e)
77
83
  if "404" in error_msg:
@@ -321,7 +327,11 @@ def get_reading_plan_results(
321
327
  for step in steps:
322
328
  if step.get("type") == "reading" and step.get("reading_id"):
323
329
  try:
324
- results = client.get_reading_results(collection_id, step["reading_id"])
330
+ results = client.get_reading_results(
331
+ collection_id,
332
+ step["reading_id"],
333
+ include_output=False,
334
+ )
325
335
  result_counts[step["alias"]] = len(results)
326
336
  except Exception:
327
337
  pass
@@ -0,0 +1,217 @@
1
+ """Agent run fetch, metadata, transcript groups, and chat sessions."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from docent.data_models.agent_run import AgentRun
8
+ from docent.sdk._base import DocentBase
9
+
10
+
11
+ class DocentAgentRunsMixin(DocentBase):
12
+ """Agent run and transcript-group operations."""
13
+
14
+ def get_agent_run(self, collection_id: str, agent_run_id: str) -> AgentRun | None:
15
+ """Get a specific agent run by its ID.
16
+
17
+ Args:
18
+ collection_id: ID of the Collection.
19
+ agent_run_id: The ID of the agent run to retrieve.
20
+
21
+ Returns:
22
+ dict: Dictionary containing the agent run information.
23
+
24
+ Raises:
25
+ requests.exceptions.HTTPError: If the API request fails.
26
+ """
27
+ url = f"{self._api_url}/{collection_id}/agent_run"
28
+ response = self._session.get(url, params={"agent_run_id": agent_run_id})
29
+ self._handle_response_errors(response)
30
+ if response.json() is None:
31
+ return None
32
+ else:
33
+ # We do this to avoid metadata validation failing
34
+ # TODO(mengk): kinda hacky
35
+ return AgentRun.model_validate(response.json())
36
+
37
+ def update_agent_run_metadata(
38
+ self,
39
+ collection_id: str,
40
+ agent_run_id: str,
41
+ metadata: dict[str, Any],
42
+ ) -> dict[str, Any]:
43
+ """Merge metadata into an agent run's existing metadata.
44
+
45
+ Uses a deep merge: nested dictionaries are merged recursively so
46
+ existing keys are preserved, while non-dict values are overwritten.
47
+ Keys not present in ``metadata`` are left unchanged.
48
+
49
+ Requires WRITE permission on the collection.
50
+
51
+ Args:
52
+ collection_id: ID of the Collection containing the agent run.
53
+ agent_run_id: ID of the agent run to update.
54
+ metadata: Dictionary of metadata fields to merge.
55
+
56
+ Returns:
57
+ The full merged metadata dictionary after the update.
58
+
59
+ Raises:
60
+ requests.exceptions.HTTPError: If the API request fails (e.g., 404 if the agent run is not found).
61
+ """
62
+ url = f"{self._server_url}/{collection_id}/agent_run/{agent_run_id}/metadata"
63
+ response = self._session.put(url, json={"metadata": metadata})
64
+ self._handle_response_errors(response)
65
+ data: dict[str, Any] = response.json()
66
+ return data
67
+
68
+ def delete_agent_run_metadata_keys(
69
+ self,
70
+ collection_id: str,
71
+ agent_run_id: str,
72
+ keys: list[str],
73
+ ) -> tuple[dict[str, Any], list[str]]:
74
+ """Remove keys from an agent run's metadata.
75
+
76
+ Supports dot-delimited paths for nested deletion. For example,
77
+ ``"config.model"`` removes the ``model`` key inside ``config``
78
+ without affecting other keys in that dict.
79
+
80
+ Requires WRITE permission on the collection.
81
+
82
+ Args:
83
+ collection_id: ID of the Collection containing the agent run.
84
+ agent_run_id: ID of the agent run to modify.
85
+ keys: Metadata keys to remove. Use dot-delimited paths for nested
86
+ keys (e.g. ``["top_level_key", "nested.child_key"]``).
87
+
88
+ Returns:
89
+ A tuple of (metadata after deletion, list of keys that were not found).
90
+
91
+ Raises:
92
+ requests.exceptions.HTTPError: If the API request fails (e.g., 404 if the agent run is not found).
93
+ """
94
+ url = f"{self._server_url}/{collection_id}/agent_run/{agent_run_id}/metadata/delete"
95
+ response = self._session.post(url, json={"keys": keys})
96
+ self._handle_response_errors(response)
97
+ data: dict[str, Any] = response.json()
98
+ metadata: dict[str, Any] = data["metadata"]
99
+ not_found: list[str] = data["not_found"]
100
+ return metadata, not_found
101
+
102
+ def get_agent_run_metadata(
103
+ self,
104
+ collection_id: str,
105
+ agent_run_id: str,
106
+ ) -> dict[str, Any]:
107
+ """Get an agent run's metadata.
108
+
109
+ Args:
110
+ collection_id: ID of the Collection containing the agent run.
111
+ agent_run_id: ID of the agent run.
112
+
113
+ Returns:
114
+ The agent run's metadata dict.
115
+
116
+ Raises:
117
+ requests.exceptions.HTTPError: If the API request fails.
118
+ """
119
+ url = f"{self._server_url}/{collection_id}/agent_run/{agent_run_id}/metadata"
120
+ response = self._session.get(url)
121
+ self._handle_response_errors(response)
122
+ return response.json()
123
+
124
+ # ──────────────────────────────────────────
125
+ # Transcript group metadata
126
+ # ──────────────────────────────────────────
127
+
128
+ def get_transcript_group_metadata(
129
+ self,
130
+ collection_id: str,
131
+ transcript_group_id: str,
132
+ ) -> dict[str, Any]:
133
+ """Get a transcript group's metadata.
134
+
135
+ Args:
136
+ collection_id: ID of the Collection containing the transcript group.
137
+ transcript_group_id: ID of the transcript group.
138
+
139
+ Returns:
140
+ The transcript group's metadata dict.
141
+
142
+ Raises:
143
+ requests.exceptions.HTTPError: If the API request fails.
144
+ """
145
+ url = f"{self._server_url}/{collection_id}/transcript_group/{transcript_group_id}/metadata"
146
+ response = self._session.get(url)
147
+ self._handle_response_errors(response)
148
+ return response.json()
149
+
150
+ def update_transcript_group_metadata(
151
+ self,
152
+ collection_id: str,
153
+ transcript_group_id: str,
154
+ metadata: dict[str, Any],
155
+ ) -> dict[str, Any]:
156
+ """Deep-merge metadata into a transcript group's existing metadata.
157
+
158
+ Args:
159
+ collection_id: ID of the Collection containing the transcript group.
160
+ transcript_group_id: ID of the transcript group.
161
+ metadata: Metadata dict to merge into the existing metadata.
162
+
163
+ Returns:
164
+ The full merged metadata dict.
165
+
166
+ Raises:
167
+ requests.exceptions.HTTPError: If the API request fails.
168
+ """
169
+ url = f"{self._server_url}/{collection_id}/transcript_group/{transcript_group_id}/metadata"
170
+ response = self._session.put(url, json={"metadata": metadata})
171
+ self._handle_response_errors(response)
172
+ return response.json()
173
+
174
+ def delete_transcript_group_metadata_keys(
175
+ self,
176
+ collection_id: str,
177
+ transcript_group_id: str,
178
+ keys: list[str],
179
+ ) -> tuple[dict[str, Any], list[str]]:
180
+ """Remove keys from a transcript group's metadata.
181
+
182
+ Supports dot-delimited paths for nested deletion.
183
+
184
+ Args:
185
+ collection_id: ID of the Collection containing the transcript group.
186
+ transcript_group_id: ID of the transcript group.
187
+ keys: Keys to remove. Use dot notation for nested keys.
188
+
189
+ Returns:
190
+ Tuple of (metadata after deletion, list of keys that were not found).
191
+
192
+ Raises:
193
+ requests.exceptions.HTTPError: If the API request fails.
194
+ """
195
+ url = f"{self._server_url}/{collection_id}/transcript_group/{transcript_group_id}/metadata/delete"
196
+ response = self._session.post(url, json={"keys": keys})
197
+ self._handle_response_errors(response)
198
+ data = response.json()
199
+ return data["metadata"], data["not_found"]
200
+
201
+ def get_chat_sessions(self, collection_id: str, agent_run_id: str) -> list[dict[str, Any]]:
202
+ """Get all chat sessions for an agent run, excluding judge result sessions.
203
+
204
+ Args:
205
+ collection_id: ID of the Collection.
206
+ agent_run_id: The ID of the agent run to retrieve chat sessions for.
207
+
208
+ Returns:
209
+ list: List of chat session dictionaries.
210
+
211
+ Raises:
212
+ requests.exceptions.HTTPError: If the API request fails.
213
+ """
214
+ url = f"{self._api_url}/chat/{collection_id}/{agent_run_id}/sessions"
215
+ response = self._session.get(url)
216
+ self._handle_response_errors(response)
217
+ return response.json()